-
Notifications
You must be signed in to change notification settings - Fork 380
28.0: Render per-row Currency Code in Aged Accounts Receivable/Payable Excel #8427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mynjj
wants to merge
6
commits into
releases/28.0
Choose a base branch
from
bugs/637446-28.0
base: releases/28.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a0ffac5
Render per-row Currency Code in Aged Accounts Receivable/Payable Excel
3e79446
28.0: Keep only currency-code tests in AgedAccountsExcelReports
73f61ec
Repopulate CurrencyCodeDisplayCode to satisfy analyzer
0e4f098
Use codeunit ID 139550 to avoid conflict
10a787f
Remove unused using directive to satisfy AL0792
d8ba809
gate failures
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,10 @@ | |
| { | ||
| "from": 139543, | ||
| "to": 139547 | ||
| }, | ||
| { | ||
| "from": 139555, | ||
| "to": 139555 | ||
| } | ||
| ], | ||
| "resourceExposurePolicy": { | ||
|
|
||
261 changes: 261 additions & 0 deletions
261
src/Apps/W1/ExcelReports/Test/src/AgedAccountsExcelReports.Codeunit.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,261 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
| // ------------------------------------------------------------------------------------------------ | ||
|
|
||
| namespace Microsoft.Finance.ExcelReports.Test; | ||
|
|
||
| using Microsoft.Finance.ExcelReports; | ||
| using Microsoft.Finance.GeneralLedger.Journal; | ||
| using Microsoft.Finance.GeneralLedger.Setup; | ||
| using Microsoft.Purchases.Payables; | ||
| using Microsoft.Purchases.Vendor; | ||
| using Microsoft.Sales.Customer; | ||
| using Microsoft.Sales.Receivables; | ||
|
|
||
| codeunit 139555 "Aged Accounts Excel Reports" | ||
| { | ||
| Subtype = Test; | ||
| RequiredTestIsolation = Disabled; | ||
| TestPermissions = Disabled; | ||
|
|
||
| var | ||
| LibraryRandom: Codeunit "Library - Random"; | ||
| LibraryReportDataset: Codeunit "Library - Report Dataset"; | ||
| Assert: Codeunit Assert; | ||
|
|
||
| [Test] | ||
| [HandlerFunctions('EXRAgedAccountsRecExcelHandler')] | ||
| procedure AgedAccountsRecRendersCurrencyCodePerEntry() | ||
| var | ||
| Customer: Record Customer; | ||
| GeneralLedgerSetup: Record "General Ledger Setup"; | ||
| UsdEntry, LcyEntry : Record "Cust. Ledger Entry"; | ||
| Variant: Variant; | ||
| RequestPageXml: Text; | ||
| LcyCode: Code[10]; | ||
| ForeignCurrencyCode: Code[10]; | ||
| DocNo, CurrencyCode : Text; | ||
| i: Integer; | ||
| UsdRowSeen, LcyRowSeen : Boolean; | ||
| begin | ||
| // [SCENARIO 637444] Aged Accounts Receivable Excel renders each row's own Currency Code, not a single per-customer value | ||
| InitializeAgingData(); | ||
|
|
||
| // [GIVEN] G/L Setup with a distinct LCY Code | ||
| LcyCode := 'LCY'; | ||
| ForeignCurrencyCode := 'USD'; | ||
| if not GeneralLedgerSetup.Get() then | ||
| GeneralLedgerSetup.Insert(); | ||
| GeneralLedgerSetup."LCY Code" := LcyCode; | ||
| GeneralLedgerSetup.Modify(); | ||
|
|
||
| // [GIVEN] A customer with one foreign-currency entry and one LCY (empty Currency Code) entry | ||
| CreateMinimalCustomer(Customer); | ||
| CreateCustLedgerEntry(UsdEntry, Customer."No.", "Gen. Journal Document Type"::Invoice, ForeignCurrencyCode); | ||
| CreateCustLedgerEntry(LcyEntry, Customer."No.", "Gen. Journal Document Type"::Invoice, ''); | ||
| Commit(); | ||
|
|
||
| // [WHEN] Running the Aged Accounts Receivable Excel report | ||
| RequestPageXml := Report.RunRequestPage(Report::"EXR Aged Accounts Rec Excel", RequestPageXml); | ||
| LibraryReportDataset.RunReportAndLoad(Report::"EXR Aged Accounts Rec Excel", Variant, RequestPageXml); | ||
|
|
||
| // [THEN] The foreign-currency row shows the foreign code and the LCY row shows the LCY code | ||
| LibraryReportDataset.SetXmlNodeList('DataItem[@name="AgingData"]'); | ||
| Assert.AreEqual(2, LibraryReportDataset.RowCount(), 'Two aging entries should be exported'); | ||
| for i := 1 to 2 do begin | ||
| LibraryReportDataset.GetNextRow(); | ||
| LibraryReportDataset.FindCurrentRowValue('DocumentNo', Variant); | ||
| DocNo := Variant; | ||
| LibraryReportDataset.FindCurrentRowValue('CurrencyCode', Variant); | ||
| CurrencyCode := Variant; | ||
| if DocNo = UsdEntry."Document No." then begin | ||
| Assert.AreEqual(ForeignCurrencyCode, CurrencyCode, 'Foreign-currency row should show its own currency code'); | ||
| UsdRowSeen := true; | ||
| end else | ||
| if DocNo = LcyEntry."Document No." then begin | ||
| Assert.AreEqual(LcyCode, CurrencyCode, 'LCY (empty Currency Code) row should fall back to G/L Setup LCY Code'); | ||
| LcyRowSeen := true; | ||
| end; | ||
| end; | ||
| Assert.IsTrue(UsdRowSeen, 'Foreign-currency row should be present'); | ||
| Assert.IsTrue(LcyRowSeen, 'LCY row should be present'); | ||
| end; | ||
|
|
||
| [Test] | ||
| [HandlerFunctions('EXRAgedAccPayableExcelHandler')] | ||
| procedure AgedAccountsPayableRendersCurrencyCodePerEntry() | ||
| var | ||
| Vendor: Record Vendor; | ||
| GeneralLedgerSetup: Record "General Ledger Setup"; | ||
| UsdEntry, LcyEntry : Record "Vendor Ledger Entry"; | ||
| Variant: Variant; | ||
| RequestPageXml: Text; | ||
| LcyCode: Code[10]; | ||
| ForeignCurrencyCode: Code[10]; | ||
| DocNo, CurrencyCode : Text; | ||
| i: Integer; | ||
| UsdRowSeen, LcyRowSeen : Boolean; | ||
| begin | ||
| // [SCENARIO 637444] Aged Accounts Payable Excel renders each row's own Currency Code, not a single per-vendor value | ||
| InitializeAgingData(); | ||
|
|
||
| // [GIVEN] G/L Setup with a distinct LCY Code | ||
| LcyCode := 'LCY'; | ||
| ForeignCurrencyCode := 'USD'; | ||
| if not GeneralLedgerSetup.Get() then | ||
| GeneralLedgerSetup.Insert(); | ||
| GeneralLedgerSetup."LCY Code" := LcyCode; | ||
| GeneralLedgerSetup.Modify(); | ||
|
|
||
| // [GIVEN] A vendor with one foreign-currency entry and one LCY (empty Currency Code) entry | ||
| CreateMinimalVendor(Vendor); | ||
| CreateVendorLedgerEntry(UsdEntry, Vendor."No.", "Gen. Journal Document Type"::Invoice, ForeignCurrencyCode); | ||
| CreateVendorLedgerEntry(LcyEntry, Vendor."No.", "Gen. Journal Document Type"::Invoice, ''); | ||
| Commit(); | ||
|
|
||
| // [WHEN] Running the Aged Accounts Payable Excel report | ||
| RequestPageXml := Report.RunRequestPage(Report::"EXR Aged Acc Payable Excel", RequestPageXml); | ||
| LibraryReportDataset.RunReportAndLoad(Report::"EXR Aged Acc Payable Excel", Variant, RequestPageXml); | ||
|
|
||
| // [THEN] The foreign-currency row shows the foreign code and the LCY row shows the LCY code | ||
| LibraryReportDataset.SetXmlNodeList('DataItem[@name="AgingData"]'); | ||
| Assert.AreEqual(2, LibraryReportDataset.RowCount(), 'Two aging entries should be exported'); | ||
| for i := 1 to 2 do begin | ||
| LibraryReportDataset.GetNextRow(); | ||
| LibraryReportDataset.FindCurrentRowValue('DocumentNo', Variant); | ||
| DocNo := Variant; | ||
| LibraryReportDataset.FindCurrentRowValue('CurrencyCode', Variant); | ||
| CurrencyCode := Variant; | ||
| if DocNo = UsdEntry."Document No." then begin | ||
| Assert.AreEqual(ForeignCurrencyCode, CurrencyCode, 'Foreign-currency row should show its own currency code'); | ||
| UsdRowSeen := true; | ||
| end else | ||
| if DocNo = LcyEntry."Document No." then begin | ||
| Assert.AreEqual(LcyCode, CurrencyCode, 'LCY (empty Currency Code) row should fall back to G/L Setup LCY Code'); | ||
| LcyRowSeen := true; | ||
| end; | ||
| end; | ||
| Assert.IsTrue(UsdRowSeen, 'Foreign-currency row should be present'); | ||
| Assert.IsTrue(LcyRowSeen, 'LCY row should be present'); | ||
| end; | ||
|
|
||
| local procedure InitializeAgingData() | ||
| var | ||
| Vendor: Record Vendor; | ||
| Customer: Record Customer; | ||
| VendorLedgerEntry: Record "Vendor Ledger Entry"; | ||
| CustLedgerEntry: Record "Cust. Ledger Entry"; | ||
| DetailedVendorLedgEntry: Record "Detailed Vendor Ledg. Entry"; | ||
| DetailedCustLedgEntry: Record "Detailed Cust. Ledg. Entry"; | ||
| begin | ||
| DetailedVendorLedgEntry.DeleteAll(); | ||
| DetailedCustLedgEntry.DeleteAll(); | ||
| VendorLedgerEntry.DeleteAll(); | ||
| CustLedgerEntry.DeleteAll(); | ||
| Vendor.DeleteAll(); | ||
| Customer.DeleteAll(); | ||
| end; | ||
|
|
||
| local procedure CreateMinimalVendor(var Vendor: Record Vendor) | ||
| begin | ||
| Vendor.Init(); | ||
| Vendor."No." := CopyStr(Format(CreateGuid()), 1, MaxStrLen(Vendor."No.")); | ||
| Vendor.Name := Vendor."No."; | ||
| Vendor.Insert(); | ||
| end; | ||
|
|
||
| local procedure CreateMinimalCustomer(var Customer: Record Customer) | ||
| begin | ||
| Customer.Init(); | ||
| Customer."No." := CopyStr(Format(CreateGuid()), 1, MaxStrLen(Customer."No.")); | ||
| Customer.Name := Customer."No."; | ||
| Customer.Insert(); | ||
| end; | ||
|
|
||
| local procedure CreateVendorLedgerEntry(var VendorLedgerEntry: Record "Vendor Ledger Entry"; VendorNo: Code[20]; DocumentType: Enum "Gen. Journal Document Type"; CurrencyCode: Code[10]) | ||
| var | ||
| DetailedVendorLedgEntry: Record "Detailed Vendor Ledg. Entry"; | ||
| EntryNo: Integer; | ||
| Amount: Decimal; | ||
| begin | ||
| if VendorLedgerEntry.FindLast() then; | ||
| EntryNo := VendorLedgerEntry."Entry No." + 1; | ||
|
|
||
| VendorLedgerEntry.Init(); | ||
| VendorLedgerEntry."Entry No." := EntryNo; | ||
| VendorLedgerEntry."Vendor No." := VendorNo; | ||
| VendorLedgerEntry."Vendor Name" := VendorNo; | ||
| VendorLedgerEntry."Document Type" := DocumentType; | ||
| VendorLedgerEntry."Document No." := 'DOC' + Format(EntryNo); | ||
| VendorLedgerEntry."Posting Date" := WorkDate(); | ||
| VendorLedgerEntry."Document Date" := WorkDate(); | ||
| VendorLedgerEntry."Due Date" := WorkDate() + 30; | ||
| VendorLedgerEntry."Currency Code" := CurrencyCode; | ||
| VendorLedgerEntry.Open := true; | ||
| VendorLedgerEntry.Insert(); | ||
|
|
||
| // Create detailed vendor ledger entry for remaining amount | ||
| Amount := -LibraryRandom.RandDec(1000, 2); | ||
| if DetailedVendorLedgEntry.FindLast() then; | ||
| DetailedVendorLedgEntry.Init(); | ||
| DetailedVendorLedgEntry."Entry No." := DetailedVendorLedgEntry."Entry No." + 1; | ||
| DetailedVendorLedgEntry."Vendor Ledger Entry No." := VendorLedgerEntry."Entry No."; | ||
| DetailedVendorLedgEntry."Vendor No." := VendorNo; | ||
| DetailedVendorLedgEntry."Posting Date" := WorkDate(); | ||
| DetailedVendorLedgEntry."Entry Type" := DetailedVendorLedgEntry."Entry Type"::"Initial Entry"; | ||
| DetailedVendorLedgEntry.Amount := Amount; | ||
| DetailedVendorLedgEntry."Amount (LCY)" := Amount; | ||
| DetailedVendorLedgEntry.Insert(); | ||
| end; | ||
|
|
||
| local procedure CreateCustLedgerEntry(var CustLedgerEntry: Record "Cust. Ledger Entry"; CustomerNo: Code[20]; DocumentType: Enum "Gen. Journal Document Type"; CurrencyCode: Code[10]) | ||
| var | ||
| DetailedCustLedgEntry: Record "Detailed Cust. Ledg. Entry"; | ||
| EntryNo: Integer; | ||
| Amount: Decimal; | ||
| begin | ||
| if CustLedgerEntry.FindLast() then; | ||
| EntryNo := CustLedgerEntry."Entry No." + 1; | ||
|
|
||
| CustLedgerEntry.Init(); | ||
| CustLedgerEntry."Entry No." := EntryNo; | ||
| CustLedgerEntry."Customer No." := CustomerNo; | ||
| CustLedgerEntry."Customer Name" := CustomerNo; | ||
| CustLedgerEntry."Document Type" := DocumentType; | ||
| CustLedgerEntry."Document No." := 'DOC' + Format(EntryNo); | ||
| CustLedgerEntry."Posting Date" := WorkDate(); | ||
| CustLedgerEntry."Document Date" := WorkDate(); | ||
| CustLedgerEntry."Due Date" := WorkDate() + 30; | ||
| CustLedgerEntry."Currency Code" := CurrencyCode; | ||
| CustLedgerEntry.Open := true; | ||
| CustLedgerEntry.Insert(); | ||
|
|
||
| // Create detailed customer ledger entry for remaining amount | ||
| Amount := LibraryRandom.RandDec(1000, 2); | ||
| if DetailedCustLedgEntry.FindLast() then; | ||
| DetailedCustLedgEntry.Init(); | ||
| DetailedCustLedgEntry."Entry No." := DetailedCustLedgEntry."Entry No." + 1; | ||
| DetailedCustLedgEntry."Cust. Ledger Entry No." := CustLedgerEntry."Entry No."; | ||
| DetailedCustLedgEntry."Customer No." := CustomerNo; | ||
| DetailedCustLedgEntry."Posting Date" := WorkDate(); | ||
| DetailedCustLedgEntry."Entry Type" := DetailedCustLedgEntry."Entry Type"::"Initial Entry"; | ||
| DetailedCustLedgEntry.Amount := Amount; | ||
| DetailedCustLedgEntry."Amount (LCY)" := Amount; | ||
| DetailedCustLedgEntry.Insert(); | ||
| end; | ||
|
|
||
| [RequestPageHandler] | ||
| procedure EXRAgedAccPayableExcelHandler(var EXRAgedAccPayableExcel: TestRequestPage "EXR Aged Acc Payable Excel") | ||
| begin | ||
| EXRAgedAccPayableExcel.AgedAsOfOption.SetValue(WorkDate()); | ||
| EXRAgedAccPayableExcel.OK().Invoke(); | ||
| end; | ||
|
|
||
| [RequestPageHandler] | ||
| procedure EXRAgedAccountsRecExcelHandler(var EXRAgedAccountsRecExcel: TestRequestPage "EXR Aged Accounts Rec Excel") | ||
| begin | ||
| EXRAgedAccountsRecExcel.AgedAsOfOption.SetValue(WorkDate()); | ||
| EXRAgedAccountsRecExcel.OK().Invoke(); | ||
| end; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.