-
Notifications
You must be signed in to change notification settings - Fork 459
[master] Report 400 (Remittance Advice) Does Not Include Applied Vendor Refund Entries Resulting in Incorrect Total Calculation #10796
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
Changes from all commits
9bc0943
8f39624
a5fe27d
fbe291e
ecb177b
7e43a1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -267,19 +267,25 @@ codeunit 37207 "Remit. Advice Buffer Mgt." | |
| DetailedVendLedgEntry.Reset(); | ||
| DetailedVendLedgEntry.SetRange("Vendor Ledger Entry No.", AppliedVendLedgEntry."Entry No."); | ||
| DetailedVendLedgEntry.SetRange("Entry Type", DetailedVendLedgEntry."Entry Type"::Application); | ||
| DetailedVendLedgEntry.SetRange("Document Type", DetailedVendLedgEntry."Document Type"::Payment); | ||
| DetailedVendLedgEntry.SetRange("Document No.", PaymentVendLedgEntry."Document No."); | ||
| if AppliedVendLedgEntry."Document Type" = AppliedVendLedgEntry."Document Type"::Refund then begin | ||
| DetailedVendLedgEntry.SetRange("Document Type", DetailedVendLedgEntry."Document Type"::Refund); | ||
| DetailedVendLedgEntry.SetRange("Document No.", AppliedVendLedgEntry."Document No."); | ||
| end else begin | ||
| DetailedVendLedgEntry.SetRange("Document Type", DetailedVendLedgEntry."Document Type"::Payment); | ||
| DetailedVendLedgEntry.SetRange("Document No.", PaymentVendLedgEntry."Document No."); | ||
| end; | ||
| DetailedVendLedgEntry.SetRange(Unapplied, false); | ||
| if not DetailedVendLedgEntry.IsEmpty() then begin | ||
| DetailedVendLedgEntry.CalcSums(Amount, "Remaining Pmt. Disc. Possible"); | ||
| LineAmount := DetailedVendLedgEntry.Amount; | ||
|
|
||
| LineDiscount := 0; | ||
| if AppliedVendLedgEntry."Currency Code" <> '' then begin | ||
| if IsDiscountAppliedToPayment(AppliedVendLedgEntry."Entry No.", PaymentVendLedgEntry."Document No.") then | ||
| LineDiscount := DetailedVendLedgEntry."Remaining Pmt. Disc. Possible"; | ||
| end else | ||
| LineDiscount := CurrExchRate.ExchangeAmtFCYToFCY(AppliedVendLedgEntry."Posting Date", '', AppliedVendLedgEntry."Currency Code", AppliedVendLedgEntry."Pmt. Disc. Rcd.(LCY)"); | ||
| if AppliedVendLedgEntry."Document Type" <> AppliedVendLedgEntry."Document Type"::Refund then | ||
| if AppliedVendLedgEntry."Currency Code" <> '' then begin | ||
| if IsDiscountAppliedToPayment(AppliedVendLedgEntry."Entry No.", PaymentVendLedgEntry."Document No.") then | ||
| LineDiscount := DetailedVendLedgEntry."Remaining Pmt. Disc. Possible"; | ||
| end else | ||
| LineDiscount := CurrExchRate.ExchangeAmtFCYToFCY(AppliedVendLedgEntry."Posting Date", '', AppliedVendLedgEntry."Currency Code", AppliedVendLedgEntry."Pmt. Disc. Rcd.(LCY)"); | ||
|
|
||
| LineNo += 1; | ||
| TempBuffer.Init(); | ||
|
|
@@ -297,7 +303,11 @@ codeunit 37207 "Remit. Advice Buffer Mgt." | |
| TempBuffer."Vendor Ledger Entry No." := AppliedVendLedgEntry."Entry No."; | ||
| TempBuffer.Insert(); | ||
|
|
||
| TotalPaid += TempBuffer."Paid Amount"; | ||
| // A refund reduces the payment total, mirroring report 400's "Amount -= LineAmount" | ||
| if AppliedVendLedgEntry."Document Type" = AppliedVendLedgEntry."Document Type"::Refund then | ||
| TotalPaid -= TempBuffer."Paid Amount" | ||
| else | ||
| TotalPaid += TempBuffer."Paid Amount"; | ||
| TotalDiscount += TempBuffer."Pmt. Discount Amount"; | ||
|
|
||
| // Applied credit-memo cross-applications (report 400 lines 231-249) | ||
|
|
@@ -357,6 +367,7 @@ codeunit 37207 "Remit. Advice Buffer Mgt." | |
| var | ||
| DetailedVendLedgEntry1: Record "Detailed Vendor Ledg. Entry"; | ||
| DetailedVendLedgEntry2: Record "Detailed Vendor Ledg. Entry"; | ||
| RefundVendLedgEntry: Record "Vendor Ledger Entry"; | ||
| EntryNo: Integer; | ||
| begin | ||
| AppliedVendLedgEntry.Reset(); | ||
|
|
@@ -407,6 +418,16 @@ codeunit 37207 "Remit. Advice Buffer Mgt." | |
| end; | ||
| until DetailedVendLedgEntry1.Next() = 0; | ||
|
|
||
| RefundVendLedgEntry.SetRange("Vendor No.", PaymentVendLedgEntry."Vendor No."); | ||
|
neeleshsinghal marked this conversation as resolved.
|
||
| RefundVendLedgEntry.SetRange("Document No.", PaymentVendLedgEntry."Document No."); | ||
| RefundVendLedgEntry.SetRange("Document Type", RefundVendLedgEntry."Document Type"::Refund); | ||
| if RefundVendLedgEntry.FindSet() then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new refund-matching loop in FindAppliedEntries narrows Knowledge: 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4 |
||
| repeat | ||
| AppliedVendLedgEntry.SetRange("Entry No.", RefundVendLedgEntry."Entry No."); | ||
| if AppliedVendLedgEntry.FindFirst() then | ||
| AppliedVendLedgEntry.Mark(true); | ||
| until RefundVendLedgEntry.Next() = 0; | ||
|
|
||
| AppliedVendLedgEntry.SetCurrentKey("Entry No."); | ||
| AppliedVendLedgEntry.SetRange("Entry No."); | ||
| AppliedVendLedgEntry.SetRange("Closed by Entry No."); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -256,26 +256,37 @@ report 400 "Remittance Advice - Entries" | |
| CalcFields(Amount, "Remaining Amount"); | ||
| DtldVendLedgEntry.SetRange("Vendor Ledger Entry No.", "Entry No."); | ||
| DtldVendLedgEntry.SetRange("Entry Type", DtldVendLedgEntry."Entry Type"::Application); | ||
| DtldVendLedgEntry.SetRange("Document Type", DtldVendLedgEntry."Document Type"::Payment); | ||
| DtldVendLedgEntry.SetRange("Document No.", "Vendor Ledger Entry"."Document No."); | ||
| if "Document Type" = "Document Type"::Refund then begin | ||
| DtldVendLedgEntry.SetRange("Document Type", DtldVendLedgEntry."Document Type"::Refund); | ||
| DtldVendLedgEntry.SetRange("Document No.", "Document No."); | ||
| end else begin | ||
| DtldVendLedgEntry.SetRange("Document Type", DtldVendLedgEntry."Document Type"::Payment); | ||
| DtldVendLedgEntry.SetRange("Document No.", "Vendor Ledger Entry"."Document No."); | ||
| end; | ||
| DtldVendLedgEntry.SetRange(Unapplied, false); | ||
| if DtldVendLedgEntry.IsEmpty() then | ||
| CurrReport.Skip(); | ||
| DtldVendLedgEntry.CalcSums(Amount, "Remaining Pmt. Disc. Possible"); | ||
| LineAmount := DtldVendLedgEntry.Amount; | ||
|
|
||
| if "Currency Code" <> '' then begin | ||
| if IsDiscountAppliedToPayment("Vendor Ledger Entry"."Entry No.", "Vendor Ledger Entry"."Document No.") then | ||
| LineDiscount := DtldVendLedgEntry."Remaining Pmt. Disc. Possible" | ||
| end else | ||
| LineDiscount := CurrExchRate.ExchangeAmtFCYToFCY("Posting Date", '', "Currency Code", "Pmt. Disc. Rcd.(LCY)"); | ||
| Clear(LineDiscount); | ||
| if "Document Type" <> "Document Type"::Refund then | ||
| if "Currency Code" <> '' then begin | ||
| if IsDiscountAppliedToPayment("Vendor Ledger Entry"."Entry No.", "Vendor Ledger Entry"."Document No.") then | ||
| LineDiscount := DtldVendLedgEntry."Remaining Pmt. Disc. Possible" | ||
| end else | ||
| LineDiscount := CurrExchRate.ExchangeAmtFCYToFCY("Posting Date", '', "Currency Code", "Pmt. Disc. Rcd.(LCY)"); | ||
|
|
||
| "Vendor Ledger Entry".Amount += LineDiscount; | ||
| if "Document Type" = "Document Type"::Refund then | ||
| "Vendor Ledger Entry".Amount -= LineAmount; | ||
|
|
||
| LAmountWDiscCur := -LineAmount - LineDiscount; | ||
| end; | ||
|
|
||
| trigger OnPreDataItem() | ||
| var | ||
| RefundVendLedgEntry: Record "Vendor Ledger Entry"; | ||
| begin | ||
| CreateVendLedgEntry := "Vendor Ledger Entry"; | ||
| FindApplnEntriesDtldtLedgEntry(); | ||
|
|
@@ -294,6 +305,15 @@ report 400 "Remittance Advice - Entries" | |
| Mark(true); | ||
| until Next() = 0; | ||
|
|
||
| RefundVendLedgEntry.SetRange("Vendor No.", CreateVendLedgEntry."Vendor No."); | ||
| RefundVendLedgEntry.SetRange("Document No.", CreateVendLedgEntry."Document No."); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The report's equivalent refund-marking loop in the Knowledge: 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4 |
||
| RefundVendLedgEntry.SetRange("Document Type", RefundVendLedgEntry."Document Type"::Refund); | ||
| if RefundVendLedgEntry.FindSet() then | ||
| repeat | ||
| "Entry No." := RefundVendLedgEntry."Entry No."; | ||
| Mark(true); | ||
| until RefundVendLedgEntry.Next() = 0; | ||
|
neeleshsinghal marked this conversation as resolved.
|
||
|
|
||
| SetCurrentKey("Entry No."); | ||
| SetRange("Closed by Entry No."); | ||
| MarkedOnly(true); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new refund branch in Export Remit. Advice PEPPOL30 (treating Applied Doc. Type = Refund as a credit line) has no dedicated test coverage in this diff. The new report test (RefundSharingPaymentDocShownOnRemittanceAdviceEntries) exercises report 400 only; it does not validate the PEPPOL XML serializer output for refund-ledger entries, so this branch can regress silently. Add a focused AL test that builds a refund-applied remittance buffer and asserts the exported XML uses CreditLineAmount (and the correct BillingReference element) for a Refund applied-doc-type line.
Agent judgement — not directly backed by a BCQuality knowledge article.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4