Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions src/Layers/CZ/Tests/ERM/ERMAccountScheduleII.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
RowNotFoundErr: Label 'Row %1 is not visible.';
WrongValueErr: Label 'Wrong value of the field %1 in table %2.', Comment = '%1 = Field name, %2 = Table name';
MissingSheetDataErr: Label 'Sheet %1 is either missing or does not contain the correct data.', Comment = '%1 = Sheet number';
TextValueDuplicateErr: Label 'Text value %1 should appear exactly once in Excel export, but found %2 occurrences', Comment = '%1 = Text value, %2 = Occurrence count';
Comment thread
v-praghav marked this conversation as resolved.
IsInitialized: Boolean;

[Test]
Expand Down Expand Up @@ -2971,6 +2972,58 @@
Assert.IsFalse(ColumnLayoutNames.First(), 'Blocked column definitions are not visible to users without write permission on status.');
end;

[Test]
[TransactionModel(TransactionModel::AutoRollback)]
[Scope('OnPrem')]
procedure ExportAccScheduleToExcelWithDimFilter2()
var
GLAccount: Record "G/L Account";
GenJournalLine: Record "Gen. Journal Line";
DimensionValue: array[4] of Record "Dimension Value";
AccScheduleName: Record "Acc. Schedule Name";
begin
// [SCENARIO 637755] Account Schedule must be exported to excel values with filters of dimensions
Initialize();

// [GIVEN] 4 Dimensions with Dimension Values:
// [GIVEN] First - "DIM1" with "DIMVALUE1"
LibraryDimension.CreateDimensionValue(DimensionValue[1], LibraryERM.GetGlobalDimensionCode(1));

// [GIVEN] Second - "DIM2" with "DIMVALUE2"
LibraryDimension.CreateDimWithDimValue(DimensionValue[2]);

// [GIVEN] Third - "DIM3" with "DIMVALUE3"
LibraryDimension.CreateDimWithDimValue(DimensionValue[3]);

// [GIVEN] Fourth - "DIM4" with "DIMVALUE4"
LibraryDimension.CreateDimWithDimValue(DimensionValue[4]);

// [GIVEN] G/L Account with posted entries and the dimension value assigned
LibraryERM.CreateGLAccount(GLAccount);
LibraryJournals.CreateGenJournalLineWithBatch(
GenJournalLine,
GenJournalLine."Document Type"::" ",
GenJournalLine."Account Type"::"G/L Account",
GLAccount."No.",
LibraryRandom.RandDecInRange(1000, 5000, 2));
GenJournalLine.Validate("Shortcut Dimension 1 Code", DimensionValue[1].Code);
GenJournalLine.Modify(true);
LibraryERM.PostGeneralJnlLine(GenJournalLine);

// [GIVEN] Account Schedule with Analysis View with dimensions: "DIM1", "DIM2", "DIM3" and "DIM4"
CreateAccScheduleNameWithViewAndDimensions(AccScheduleName, DimensionValue);
LibraryReportValidation.SetFileName(AccScheduleName.Name);

// [WHEN] Run export Account Schedule to Excel - Report 29 (Export Acc. Sched. to Excel)
RunExportAccScheduleToExcel(AccScheduleName, DimensionValue);

// [THEN] Excel file contains values of dimensions filters
VerifyDimensionsAndValueInExcel(DimensionValue);

// [THEN] Verify that the Currency appears only once in the export
VerifyTextValueAppearsOnce('Currency');
Comment thread
v-praghav marked this conversation as resolved.
end;

local procedure Initialize()
var
FinancialReportMgt: Codeunit "Financial Report Mgt.";
Expand Down Expand Up @@ -3431,6 +3484,24 @@
FinRepStatus.Insert(true);
end;

local procedure VerifyTextValueAppearsOnce(TextValue: Text[20])
var
RowNo: Integer;
ColumnNo: Integer;
ValueFound: Boolean;
CellValue: Text[250];
OccurrenceCount: Integer;
begin
OccurrenceCount := 0;
for RowNo := 1 to 200 do
for ColumnNo := 1 to 20 do begin
CellValue := LibraryReportValidation.GetValueAt(ValueFound, RowNo, ColumnNo);
if ValueFound and (StrPos(CellValue, TextValue) > 0) then
OccurrenceCount += 1;
Comment thread
v-praghav marked this conversation as resolved.
end;
Assert.AreEqual(1, OccurrenceCount, StrSubstNo(TextValueDuplicateErr, TextValue, OccurrenceCount));
end;

[RequestPageHandler]
[Scope('OnPrem')]
procedure RHAccountSchedule(var AccountSchedule: TestRequestPage "Account Schedule")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,18 +257,19 @@ report 29 "Export Acc. Sched. to Excel"
EnterFilterInCell(
RowNo, AccSchedLine.GetFilter("Dimension 4 Filter"), GetDimFilterCaption(4), '', TempExcelBuffer."Cell Type"::Text);

RowNo := RowNo + 1;
InsertBlankRowAndFillCells(RowNo, 3, true, false);
if UseAmtsInAddCurr then
EnterFilterInCell(
RowNo, GLSetup."Additional Reporting Currency", Currency.TableCaption(), '', TempExcelBuffer."Cell Type"::Text)
else
EnterFilterInCell(
RowNo, GLSetup."LCY Code", Currency.TableCaption(), '', TempExcelBuffer."Cell Type"::Text);

RowNo := RowNo + 1;
InsertBlankRowAndFillCells(RowNo, 3, false, true);
InsertBlankRowAndFillCells(RowNo, 3, true, false);
if AccSchedLine.Find('-') then begin
if ColumnLayout.Find('-') then begin
RowNo := RowNo + 1;
InsertBlankRowAndFillCells(RowNo, 2, true, false);
ColumnNo := 2; // Skip the "Row No." column.
repeat
ColumnNo := ColumnNo + 1;
Expand Down Expand Up @@ -544,6 +545,22 @@ report 29 "Export Acc. Sched. to Excel"
RunForExport := true;
end;

local procedure InsertBlankRowAndFillCells(var RowNo: Integer; ColumnNo: Integer; InsertNewRow: Boolean; FillSingleCellOnly: Boolean)
var
ColumnIndex: Integer;
begin
if InsertNewRow then
RowNo := RowNo + 1;

if FillSingleCellOnly then begin
EnterCell(RowNo, ColumnNo, '', false, false, false, false, '', TempExcelBuffer."Cell Type"::Text);
exit;
end;

for ColumnIndex := 1 to ColumnNo do
EnterCell(RowNo, ColumnIndex, '', false, false, false, false, '', TempExcelBuffer."Cell Type"::Text);
end;
Comment thread
v-praghav marked this conversation as resolved.

/// <summary>
/// Integration event raised before calculating column values during Excel export.
/// Enables custom modification of currency settings and column layout parameters.
Expand Down
71 changes: 71 additions & 0 deletions src/Layers/NA/Tests/ERM/ERMAccountScheduleII.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
RowNotFoundErr: Label 'Row %1 is not visible.';
WrongValueErr: Label 'Wrong value of the field %1 in table %2.', Comment = '%1 = Field name, %2 = Table name';
MissingSheetDataErr: Label 'Sheet %1 is either missing or does not contain the correct data.', Comment = '%1 = Sheet number';
TextValueDuplicateErr: Label 'Text value %1 should appear exactly once in Excel export, but found %2 occurrences', Comment = '%1 = Text value, %2 = Occurrence count';
Comment thread
v-praghav marked this conversation as resolved.
IsInitialized: Boolean;

[Test]
Expand Down Expand Up @@ -3009,6 +3010,58 @@
Assert.IsFalse(ColumnLayoutNames.First(), 'Blocked column definitions are not visible to users without write permission on status.');
end;

[Test]
[TransactionModel(TransactionModel::AutoRollback)]
[Scope('OnPrem')]
procedure ExportAccScheduleToExcelWithDimFilter2()
var
GLAccount: Record "G/L Account";
GenJournalLine: Record "Gen. Journal Line";
DimensionValue: array[4] of Record "Dimension Value";
AccScheduleName: Record "Acc. Schedule Name";
begin
// [SCENARIO 637755] Account Schedule must be exported to excel values with filters of dimensions
Initialize();

// [GIVEN] 4 Dimensions with Dimension Values:
// [GIVEN] First - "DIM1" with "DIMVALUE1"
LibraryDimension.CreateDimensionValue(DimensionValue[1], LibraryERM.GetGlobalDimensionCode(1));

// [GIVEN] Second - "DIM2" with "DIMVALUE2"
LibraryDimension.CreateDimWithDimValue(DimensionValue[2]);

// [GIVEN] Third - "DIM3" with "DIMVALUE3"
LibraryDimension.CreateDimWithDimValue(DimensionValue[3]);

// [GIVEN] Fourth - "DIM4" with "DIMVALUE4"
LibraryDimension.CreateDimWithDimValue(DimensionValue[4]);

// [GIVEN] G/L Account with posted entries and the dimension value assigned
LibraryERM.CreateGLAccount(GLAccount);
LibraryJournals.CreateGenJournalLineWithBatch(
GenJournalLine,
GenJournalLine."Document Type"::" ",
GenJournalLine."Account Type"::"G/L Account",
GLAccount."No.",
LibraryRandom.RandDecInRange(1000, 5000, 2));
GenJournalLine.Validate("Shortcut Dimension 1 Code", DimensionValue[1].Code);
GenJournalLine.Modify(true);
LibraryERM.PostGeneralJnlLine(GenJournalLine);

// [GIVEN] Account Schedule with Analysis View with dimensions: "DIM1", "DIM2", "DIM3" and "DIM4"
CreateAccScheduleNameWithViewAndDimensions(AccScheduleName, DimensionValue);
LibraryReportValidation.SetFileName(AccScheduleName.Name);

// [WHEN] Run export Account Schedule to Excel - Report 29 (Export Acc. Sched. to Excel)
RunExportAccScheduleToExcel(AccScheduleName, DimensionValue);

// [THEN] Excel file contains values of dimensions filters
VerifyDimensionsAndValueInExcel(DimensionValue);

// [THEN] Verify that the Currency appears only once in the export
VerifyTextValueAppearsOnce('Currency');
Comment thread
v-praghav marked this conversation as resolved.
end;

local procedure Initialize()
var
FinancialReportMgt: Codeunit "Financial Report Mgt.";
Expand Down Expand Up @@ -3469,6 +3522,24 @@
FinRepStatus.Insert(true);
end;

local procedure VerifyTextValueAppearsOnce(TextValue: Text[20])
var
RowNo: Integer;
ColumnNo: Integer;
ValueFound: Boolean;
CellValue: Text[250];
OccurrenceCount: Integer;
begin
OccurrenceCount := 0;
for RowNo := 1 to 200 do
for ColumnNo := 1 to 20 do begin
CellValue := LibraryReportValidation.GetValueAt(ValueFound, RowNo, ColumnNo);
if ValueFound and (StrPos(CellValue, TextValue) > 0) then
OccurrenceCount += 1;
Comment thread
v-praghav marked this conversation as resolved.
end;
Assert.AreEqual(1, OccurrenceCount, StrSubstNo(TextValueDuplicateErr, TextValue, OccurrenceCount));
end;

[RequestPageHandler]
[Scope('OnPrem')]
procedure RHAccountSchedule(var AccountSchedule: TestRequestPage "Account Schedule")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,18 +257,19 @@ report 29 "Export Acc. Sched. to Excel"
EnterFilterInCell(
RowNo, AccSchedLine.GetFilter("Dimension 4 Filter"), GetDimFilterCaption(4), '', TempExcelBuffer."Cell Type"::Text);

RowNo := RowNo + 1;
InsertBlankRowAndFillCells(RowNo, 3, true, false);
if UseAmtsInAddCurr then
EnterFilterInCell(
RowNo, GLSetup."Additional Reporting Currency", Currency.TableCaption(), '', TempExcelBuffer."Cell Type"::Text)
else
EnterFilterInCell(
RowNo, GLSetup."LCY Code", Currency.TableCaption(), '', TempExcelBuffer."Cell Type"::Text);

RowNo := RowNo + 1;
InsertBlankRowAndFillCells(RowNo, 3, false, true);
InsertBlankRowAndFillCells(RowNo, 3, true, false);
if AccSchedLine.Find('-') then begin
if ColumnLayout.Find('-') then begin
RowNo := RowNo + 1;
InsertBlankRowAndFillCells(RowNo, 2, true, false);
ColumnNo := 2; // Skip the "Row No." column.
repeat
ColumnNo := ColumnNo + 1;
Expand Down Expand Up @@ -527,6 +528,22 @@ report 29 "Export Acc. Sched. to Excel"
RunForExport := true;
end;

local procedure InsertBlankRowAndFillCells(var RowNo: Integer; ColumnNo: Integer; InsertNewRow: Boolean; FillSingleCellOnly: Boolean)
var
ColumnIndex: Integer;
begin
if InsertNewRow then
RowNo := RowNo + 1;

if FillSingleCellOnly then begin
EnterCell(RowNo, ColumnNo, '', false, false, false, false, '', TempExcelBuffer."Cell Type"::Text);
exit;
end;

for ColumnIndex := 1 to ColumnNo do
EnterCell(RowNo, ColumnIndex, '', false, false, false, false, '', TempExcelBuffer."Cell Type"::Text);
end;
Comment thread
v-praghav marked this conversation as resolved.

/// <summary>
/// Integration event raised before calculating column values during Excel export.
/// Enables custom modification of currency settings and column layout parameters.
Expand Down
71 changes: 71 additions & 0 deletions src/Layers/W1/Tests/ERM/ERMAccountScheduleII.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
RowNotFoundErr: Label 'Row %1 is not visible.';
WrongValueErr: Label 'Wrong value of the field %1 in table %2.', Comment = '%1 = Field name, %2 = Table name';
MissingSheetDataErr: Label 'Sheet %1 is either missing or does not contain the correct data.', Comment = '%1 = Sheet number';
TextValueDuplicateErr: Label 'Text value %1 should appear exactly once in Excel export, but found %2 occurrences', Comment = '%1 = Text value, %2 = Occurrence count';
Comment thread
v-praghav marked this conversation as resolved.
IsInitialized: Boolean;

[Test]
Expand Down Expand Up @@ -2971,6 +2972,58 @@
Assert.IsFalse(ColumnLayoutNames.First(), 'Blocked column definitions are not visible to users without write permission on status.');
end;

[Test]
[TransactionModel(TransactionModel::AutoRollback)]
[Scope('OnPrem')]
procedure ExportAccScheduleToExcelWithDimFilter2()
var
GLAccount: Record "G/L Account";
GenJournalLine: Record "Gen. Journal Line";
DimensionValue: array[4] of Record "Dimension Value";
AccScheduleName: Record "Acc. Schedule Name";
begin
// [SCENARIO 637755] Account Schedule must be exported to excel values with filters of dimensions
Initialize();

// [GIVEN] 4 Dimensions with Dimension Values:
// [GIVEN] First - "DIM1" with "DIMVALUE1"
LibraryDimension.CreateDimensionValue(DimensionValue[1], LibraryERM.GetGlobalDimensionCode(1));

// [GIVEN] Second - "DIM2" with "DIMVALUE2"
LibraryDimension.CreateDimWithDimValue(DimensionValue[2]);

// [GIVEN] Third - "DIM3" with "DIMVALUE3"
LibraryDimension.CreateDimWithDimValue(DimensionValue[3]);

// [GIVEN] Fourth - "DIM4" with "DIMVALUE4"
LibraryDimension.CreateDimWithDimValue(DimensionValue[4]);

// [GIVEN] G/L Account with posted entries and the dimension value assigned
LibraryERM.CreateGLAccount(GLAccount);
LibraryJournals.CreateGenJournalLineWithBatch(
GenJournalLine,
GenJournalLine."Document Type"::" ",
GenJournalLine."Account Type"::"G/L Account",
GLAccount."No.",
LibraryRandom.RandDecInRange(1000, 5000, 2));
GenJournalLine.Validate("Shortcut Dimension 1 Code", DimensionValue[1].Code);
GenJournalLine.Modify(true);
LibraryERM.PostGeneralJnlLine(GenJournalLine);

// [GIVEN] Account Schedule with Analysis View with dimensions: "DIM1", "DIM2", "DIM3" and "DIM4"
CreateAccScheduleNameWithViewAndDimensions(AccScheduleName, DimensionValue);
LibraryReportValidation.SetFileName(AccScheduleName.Name);

// [WHEN] Run export Account Schedule to Excel - Report 29 (Export Acc. Sched. to Excel)
RunExportAccScheduleToExcel(AccScheduleName, DimensionValue);

// [THEN] Excel file contains values of dimensions filters
VerifyDimensionsAndValueInExcel(DimensionValue);

// [THEN] Verify that the Currency appears only once in the export
VerifyTextValueAppearsOnce('Currency');
Comment thread
v-praghav marked this conversation as resolved.
end;

local procedure Initialize()
var
FinancialReportMgt: Codeunit "Financial Report Mgt.";
Expand Down Expand Up @@ -3431,6 +3484,24 @@
FinRepStatus.Insert(true);
end;

local procedure VerifyTextValueAppearsOnce(TextValue: Text[20])
var
RowNo: Integer;
ColumnNo: Integer;
ValueFound: Boolean;
CellValue: Text[250];
OccurrenceCount: Integer;
begin
OccurrenceCount := 0;
for RowNo := 1 to 200 do
for ColumnNo := 1 to 20 do begin
CellValue := LibraryReportValidation.GetValueAt(ValueFound, RowNo, ColumnNo);
if ValueFound and (StrPos(CellValue, TextValue) > 0) then
OccurrenceCount += 1;
Comment thread
v-praghav marked this conversation as resolved.
end;
Assert.AreEqual(1, OccurrenceCount, StrSubstNo(TextValueDuplicateErr, TextValue, OccurrenceCount));
end;

[RequestPageHandler]
[Scope('OnPrem')]
procedure RHAccountSchedule(var AccountSchedule: TestRequestPage "Account Schedule")
Expand Down
Loading