Skip to content

[Master]-Purchase invoice in USD with deferral shows 0 "Amount LCY" in Deferral Schedule View"#9457

Open
neeleshsinghal wants to merge 5 commits into
mainfrom
bugs/Bug-641062-Purchase-deferral-Amount-LCY
Open

[Master]-Purchase invoice in USD with deferral shows 0 "Amount LCY" in Deferral Schedule View"#9457
neeleshsinghal wants to merge 5 commits into
mainfrom
bugs/Bug-641062-Purchase-deferral-Amount-LCY

Conversation

@neeleshsinghal

@neeleshsinghal neeleshsinghal commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Fixes AB#641062

@neeleshsinghal
neeleshsinghal requested a review from a team July 15, 2026 05:46
@github-actions github-actions Bot added this to the Version 29.0 milestone Jul 15, 2026
AmtToDefer: Decimal;
AmtToDeferLCY: Decimal;
begin
case DeferralHeader."Deferral Doc. Type" of

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Agent} \quad \color{gray}{\texttt{\small Iteration\ 1}}$

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

Comment thread src/Layers/W1/Tests/ERM/REDTestUnitforPurchDoc.Codeunit.al Outdated
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Copilot PR Review

Iteration 6 · Outcome: completed

Knowledge source: https://github.com/microsoft/BCQuality@186d8a131465475c79244d994acb872cd5c0d4bf

Findings by domain

Findings split into Knowledge-backed (cite a BCQuality article) and Agent (the agent's own judgement, no matching BCQuality rule).

Domain Findings Knowledge-backed Agent Inline Fallback
Agent 1 0 1 0 0

Totals: 0 knowledge-backed · 1 agent findings.

Orchestrator pre-filter (2 file(s) excluded)

  • layer-disabled (knowledge) : 2 file(s)

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.
Comment thread src/Layers/W1/Tests/ERM/REDTestUnitforPurchDoc.Codeunit.al
AmtToDefer: Decimal;
AmtToDeferLCY: Decimal;
begin
case DeferralHeader."Deferral Doc. Type" of

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Interfaces} \quad \color{gray}{\texttt{\small Iteration\ 5}}$

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/Layers/W1/Tests/ERM/REDTestUnitforPurchDoc.Codeunit.al
Comment thread src/Layers/NA/Tests/ERM/REDTestUnitforPurchDoc.Codeunit.al
Comment thread src/Layers/IT/Tests/ERM/REDTestUnitforPurchDoc.Codeunit.al
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Finance GitHub request for Finance area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants