From dc9b8316e37fbcb1875722c7a691644f7828aed9 Mon Sep 17 00:00:00 2001 From: v-nesinghal Date: Wed, 25 Mar 2026 12:13:26 +0545 Subject: [PATCH] 622247 initial commit --- .../EXRAgedAccPayableExcel.Report.al | 9 + .../EXRAgedAccountsRecExcel.Report.al | 10 +- .../Financials/EXRAgingReportBuffer.Table.al | 6 + .../src/TrialBalanceExcelReports.Codeunit.al | 176 ++++++++++++++++++ 4 files changed, 200 insertions(+), 1 deletion(-) diff --git a/src/Apps/W1/ExcelReports/App/src/Financials/EXRAgedAccPayableExcel.Report.al b/src/Apps/W1/ExcelReports/App/src/Financials/EXRAgedAccPayableExcel.Report.al index e4de74d342..a09b3759b3 100644 --- a/src/Apps/W1/ExcelReports/App/src/Financials/EXRAgedAccPayableExcel.Report.al +++ b/src/Apps/W1/ExcelReports/App/src/Financials/EXRAgedAccPayableExcel.Report.al @@ -43,6 +43,14 @@ report 4403 "EXR Aged Acc Payable Excel" DataItemTableView = sorting("Vendor Source No."); DataItemLink = "Vendor Source No." = field("No."); + column(DocumentType; "Document Type") + { + IncludeCaption = true; + } + column(DocumentNo; "Document No.") + { + IncludeCaption = true; + } column(PeriodStart; "Period Start Date") { @@ -355,6 +363,7 @@ report 4403 "EXR Aged Acc Payable Excel" AgingData."Vendor Source No." := VendorLedgerEntry."Vendor No."; AgingData."Source Name" := VendorLedgerEntry."Vendor Name"; AgingData."Document No." := VendorLedgerEntry."Document No."; + AgingData."Document Type" := VendorLedgerEntry."Document Type"; AgingData."Dimension 1 Code" := VendorLedgerEntry."Global Dimension 1 Code"; AgingData."Dimension 2 Code" := VendorLedgerEntry."Global Dimension 2 Code"; AgingData."Currency Code" := VendorLedgerEntry."Currency Code"; diff --git a/src/Apps/W1/ExcelReports/App/src/Financials/EXRAgedAccountsRecExcel.Report.al b/src/Apps/W1/ExcelReports/App/src/Financials/EXRAgedAccountsRecExcel.Report.al index 1aad3b6cd9..b16e1ca692 100644 --- a/src/Apps/W1/ExcelReports/App/src/Financials/EXRAgedAccountsRecExcel.Report.al +++ b/src/Apps/W1/ExcelReports/App/src/Financials/EXRAgedAccountsRecExcel.Report.al @@ -42,7 +42,14 @@ report 4402 "EXR Aged Accounts Rec Excel" { DataItemTableView = sorting("Vendor Source No."); DataItemLink = "Vendor Source No." = field("No."); - + column(DocumentType; "Document Type") + { + IncludeCaption = true; + } + column(DocumentNo; "Document No.") + { + IncludeCaption = true; + } column(PeriodStart; "Period Start Date") { @@ -355,6 +362,7 @@ report 4402 "EXR Aged Accounts Rec Excel" AgingData."Vendor Source No." := CustLedgerEntry."Customer No."; AgingData."Source Name" := CustLedgerEntry."Customer Name"; AgingData."Document No." := CustLedgerEntry."Document No."; + AgingData."Document Type" := CustLedgerEntry."Document Type"; AgingData."Dimension 1 Code" := CustLedgerEntry."Global Dimension 1 Code"; AgingData."Dimension 2 Code" := CustLedgerEntry."Global Dimension 2 Code"; AgingData."Currency Code" := CustLedgerEntry."Currency Code"; diff --git a/src/Apps/W1/ExcelReports/App/src/Financials/EXRAgingReportBuffer.Table.al b/src/Apps/W1/ExcelReports/App/src/Financials/EXRAgingReportBuffer.Table.al index c28309749e..2a5bd69c80 100644 --- a/src/Apps/W1/ExcelReports/App/src/Financials/EXRAgingReportBuffer.Table.al +++ b/src/Apps/W1/ExcelReports/App/src/Financials/EXRAgingReportBuffer.Table.al @@ -5,6 +5,8 @@ namespace Microsoft.Finance.ExcelReports; +using Microsoft.Finance.GeneralLedger.Journal; + table 4401 "EXR Aging Report Buffer" { AllowInCustomizations = Never; @@ -35,6 +37,10 @@ table 4401 "EXR Aging Report Buffer" { Caption = 'Document No.'; } + field(9; "Document Type"; Enum "Gen. Journal Document Type") + { + Caption = 'Document Type'; + } field(11; "Posting Date"; Date) { Caption = 'Posting Date'; diff --git a/src/Apps/W1/ExcelReports/Test/src/TrialBalanceExcelReports.Codeunit.al b/src/Apps/W1/ExcelReports/Test/src/TrialBalanceExcelReports.Codeunit.al index 5df379f161..3ebbf06453 100644 --- a/src/Apps/W1/ExcelReports/Test/src/TrialBalanceExcelReports.Codeunit.al +++ b/src/Apps/W1/ExcelReports/Test/src/TrialBalanceExcelReports.Codeunit.al @@ -10,7 +10,12 @@ using Microsoft.Finance.Dimension; using Microsoft.Finance.ExcelReports; using Microsoft.Finance.GeneralLedger.Account; using Microsoft.Finance.GeneralLedger.Budget; +using Microsoft.Finance.GeneralLedger.Journal; using Microsoft.Finance.GeneralLedger.Ledger; +using Microsoft.Purchases.Payables; +using Microsoft.Purchases.Vendor; +using Microsoft.Sales.Customer; +using Microsoft.Sales.Receivables; codeunit 139544 "Trial Balance Excel Reports" { @@ -21,8 +26,12 @@ codeunit 139544 "Trial Balance Excel Reports" var LibraryERM: Codeunit "Library - ERM"; + LibraryPurchase: Codeunit "Library - Purchase"; + LibraryRandom: Codeunit "Library - Random"; LibraryReportDataset: Codeunit "Library - Report Dataset"; + LibrarySales: Codeunit "Library - Sales"; Assert: Codeunit Assert; + DocumentTypeShouldBeInvoiceErr: Label 'Document Type should be Invoice'; [Test] [HandlerFunctions('EXRTrialBalanceExcelHandler')] @@ -659,6 +668,72 @@ codeunit 139544 "Trial Balance Excel Reports" Assert.AreEqual(0, TrialBalanceData."Starting Balance", 'Starting Balance should be zero after closing entries') end; + [Test] + [HandlerFunctions('EXRAgedAccPayableExcelHandler')] + procedure AgedAccountsPayableExportsInvoiceDocumentType() + var + Vendor: Record Vendor; + VendorLedgerEntry: Record "Vendor Ledger Entry"; + Variant: Variant; + RequestPageXml: Text; + ReportDocumentType: Text; + begin + // [FEATURE] [AI test] + // [SCENARIO 622247] Aged Accounts Payable Excel report exports Document Type field correctly for Invoice entries + InitializeAgingData(); + + // [GIVEN] Vendor "V" with an open vendor ledger entry of type Invoice + LibraryPurchase.CreateVendor(Vendor); + CreateVendorLedgerEntry(VendorLedgerEntry, Vendor."No.", "Gen. Journal Document Type"::Invoice); + Commit(); + + // [WHEN] Running the Aged Accounts Payable Excel report + Vendor.SetRange("No.", Vendor."No."); + RequestPageXml := Report.RunRequestPage(Report::"EXR Aged Acc Payable Excel", RequestPageXml); + LibraryReportDataset.RunReportAndLoad(Report::"EXR Aged Acc Payable Excel", Variant, RequestPageXml); + + // [THEN] The exported data contains the Document Type "Invoice" + LibraryReportDataset.SetXmlNodeList('DataItem[@name="AgingData"]'); + Assert.AreEqual(1, LibraryReportDataset.RowCount(), 'One aging entry should be exported'); + LibraryReportDataset.GetNextRow(); + LibraryReportDataset.FindCurrentRowValue('DocumentType', Variant); + ReportDocumentType := Variant; + Assert.AreEqual(Format("Gen. Journal Document Type"::Invoice), ReportDocumentType, DocumentTypeShouldBeInvoiceErr); + end; + + [Test] + [HandlerFunctions('EXRAgedAccountsRecExcelHandler')] + procedure AgedAccountsRecExportsInvoiceDocumentType() + var + Customer: Record Customer; + CustLedgerEntry: Record "Cust. Ledger Entry"; + Variant: Variant; + RequestPageXml: Text; + ReportDocumentType: Text; + begin + // [FEATURE] [AI test] + // [SCENARIO 622247] Aged Accounts Receivable Excel report exports Document Type field correctly for Invoice entries + InitializeAgingData(); + + // [GIVEN] Customer "C" with an open customer ledger entry of type Invoice + LibrarySales.CreateCustomer(Customer); + CreateCustLedgerEntry(CustLedgerEntry, Customer."No.", "Gen. Journal Document Type"::Invoice); + Commit(); + + // [WHEN] Running the Aged Accounts Receivable Excel report + Customer.SetRange("No.", Customer."No."); + RequestPageXml := Report.RunRequestPage(Report::"EXR Aged Accounts Rec Excel", RequestPageXml); + LibraryReportDataset.RunReportAndLoad(Report::"EXR Aged Accounts Rec Excel", Variant, RequestPageXml); + + // [THEN] The exported data contains the Document Type "Invoice" + LibraryReportDataset.SetXmlNodeList('DataItem[@name="AgingData"]'); + Assert.AreEqual(1, LibraryReportDataset.RowCount(), 'One aging entry should be exported'); + LibraryReportDataset.GetNextRow(); + LibraryReportDataset.FindCurrentRowValue('DocumentType', Variant); + ReportDocumentType := Variant; + Assert.AreEqual(Format("Gen. Journal Document Type"::Invoice), ReportDocumentType, DocumentTypeShouldBeInvoiceErr); + end; + local procedure CreateSampleBusinessUnits(HowMany: Integer) var BusinessUnit: Record "Business Unit"; @@ -779,6 +854,93 @@ codeunit 139544 "Trial Balance Excel Reports" GLEntry.Insert(); 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 CreateVendorLedgerEntry(var VendorLedgerEntry: Record "Vendor Ledger Entry"; VendorNo: Code[20]; DocumentType: Enum "Gen. Journal Document Type") + 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.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") + 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.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 EXRTrialBalanceExcelHandler(var EXRTrialBalanceExcel: TestRequestPage "EXR Trial Balance Excel") begin @@ -800,6 +962,20 @@ codeunit 139544 "Trial Balance Excel Reports" EXRConsolidatedTrialBalance.OK().Invoke(); 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; + #if not CLEAN27 #pragma warning disable AL0432 [EventSubscriber(ObjectType::Codeunit, Codeunit::"Trial Balance", OnIsPerformantTrialBalanceFeatureActive, '', false, false)]