[Master]-Purchase invoice in USD with deferral shows 0 "Amount LCY" in Deferral Schedule View"#9457
[Master]-Purchase invoice in USD with deferral shows 0 "Amount LCY" in Deferral Schedule View"#9457neeleshsinghal wants to merge 5 commits into
Conversation
| AmtToDefer: Decimal; | ||
| AmtToDeferLCY: Decimal; | ||
| begin | ||
| case DeferralHeader."Deferral Doc. Type" of |
There was a problem hiding this comment.
RoundDeferralAmountFromSource (new local procedure called unconditionally from CreateDeferralSchedule) only has a case branch for DeferralHeader."Deferral Doc.
Type"::Purchase. CreateDeferralSchedule is a generic entry point also reached for Sales documents (DeferralDocType is passed through from callers such as DeferralCodeOnValidate/RemoveOrSetDeferralSchedule/OpenLineScheduleEdit with no Purchase-only guard, and "Deferral Document Type" enum has Sales=1 and G/L=2 alongside Purchase=0). The bug this change fixes -- Amount (LCY) not filled in the deferral schedule before posting for a foreign-currency document -- is therefore still present for Sales documents with a foreign currency, since the case statement has no branch for DeferralHeader."Deferral Doc. Type"::Sales and silently no-ops for it. If the true impact were confirmed it would warrant major severity and a knowledge-backed rule; recommend adding a Sales branch (reading Sales Header "Currency Factor"/"Posting Date"/"Currency Code") mirroring the Purchase branch, or explicitly justifying in a comment why Sales is out of scope for this fix.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
Copilot PR ReviewIteration 6 · Outcome: completed Knowledge source: https://github.com/microsoft/BCQuality@186d8a131465475c79244d994acb872cd5c0d4bf Findings by domainFindings split into Knowledge-backed (cite a BCQuality article) and Agent (the agent's own judgement, no matching BCQuality rule).
Totals: 0 knowledge-backed · 1 agent findings. Orchestrator pre-filter (2 file(s) excluded)
Findings produced by the AL review agent v1.7.3. Reply 👎 on any inline comment to flag false positives. |
Removed TotalAmountLCY variable from REDTestUnitforPurchDoc.
Removed TotalAmountLCY variable from the REDTestUnitforPurchDoc.Codeunit.al file.
Removed TotalAmountLCY variable from REDTestUnitforPurchDoc.
| AmtToDefer: Decimal; | ||
| AmtToDeferLCY: Decimal; | ||
| begin | ||
| case DeferralHeader."Deferral Doc. Type" of |
There was a problem hiding this comment.
RoundDeferralAmountFromSource (new local procedure in DeferralUtilities.Codeunit.al) is called unconditionally from CreateDeferralSchedule for every deferral document type (Purchase, Sales, G/L), but its case statement over "Deferral Doc.
Type" only implements the Purchase branch and has no else. Sales and G/L deferral schedules silently fall through and never get their Amount (LCY) rounded/filled at schedule-creation time the way Purchase schedules now do, leaving the same currency-rounding gap this change fixes for Purchase in place for Sales and G/L deferral schedules with foreign currency.
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
There was a problem hiding this comment.
Pull request overview
Fixes an issue where purchase invoices in foreign currency (e.g., USD) with deferrals can show 0 in “Amount (LCY)” in the Deferral Schedule view, by ensuring LCY amounts are calculated/rounded from the source purchase document context and adding coverage in ERM tests.
Changes:
- Update deferral schedule creation to round/calculate LCY amounts for purchase deferrals using the source Purchase Header (posting date/currency factor).
- Add an automated test ensuring deferral schedule lines have non-zero Amount (LCY) for an unposted foreign-currency purchase invoice (W1/NA/IT layers).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/Layers/W1/Tests/ERM/REDTestUnitforPurchDoc.Codeunit.al | Adds test coverage for non-zero deferral Amount (LCY) on unposted FCY purchase invoices. |
| src/Layers/W1/BaseApp/Finance/Deferral/DeferralUtilities.Codeunit.al | Rounds deferral schedule LCY amounts from the source Purchase Header context after schedule generation. |
| src/Layers/NA/Tests/ERM/REDTestUnitforPurchDoc.Codeunit.al | Layer copy of the new FCY deferral LCY test. |
| src/Layers/IT/Tests/ERM/REDTestUnitforPurchDoc.Codeunit.al | Layer copy of the new FCY deferral LCY test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes AB#641062