Skip to content

[Master]-ACY amount on Value Entries is recalculated from LCY when the document currency equals the Additional Reporting Currency, causing a mismatch with G/L Entries - #10231

Open
neeleshsinghal wants to merge 2 commits into
mainfrom
bugs/Bug-646085-ACY-amount-on-Value-Entries-is-intact-from-LCY
Open

[Master]-ACY amount on Value Entries is recalculated from LCY when the document currency equals the Additional Reporting Currency, causing a mismatch with G/L Entries#10231
neeleshsinghal wants to merge 2 commits into
mainfrom
bugs/Bug-646085-ACY-amount-on-Value-Entries-is-intact-from-LCY

Conversation

@neeleshsinghal

@neeleshsinghal neeleshsinghal commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

@neeleshsinghal
neeleshsinghal requested a review from a team August 13, 2026 12:10
@github-actions github-actions Bot added the SCM GitHub request for SCM area label Aug 13, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Aug 13, 2026
DirCostACY := Round(DirCost * ItemJnlLine."Vendor Exchange Rate (ACY)");
OvhdCostACY := Round(OvhdCost * ItemJnlLine."Vendor Exchange Rate (ACY)");
ItemJnlLine."Unit Cost (ACY)" := Round(ItemJnlLine."Unit Cost" * ItemJnlLine."Vendor Exchange Rate (ACY)");
end else begin

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\ —\ Error\ Handling}$

In the APAC layer only, the new ShouldUseDocumentAmountForACY() branch sets PurchVarACY := 0, but the final PurchVarACY assignment (near line 3722, PurchVarACY := ItemJnlLine."Unit Cost (ACY)" * ItemJnlLine."Invoiced Quantity" - DirCostACY - OvhdCostACY;) sits outside that conditional and always executes afterward regardless of which branch was taken. This silently overwrites the zeroed PurchVarACY, defeating the document-amount path and producing an incorrect ACY purchase variance for costing-method-driven ACY postings. Although agent findings are capped at minor severity, the underlying impact is major/blocker-level (wrong posted amounts) and should be fixed before merge. Note that the sibling layers (W1, CH, ES, IT, RU) do not have this bug: their equivalent code correctly nests the PurchVarACY calculation inside the else-branch of ShouldUseDocumentAmountForACY(), so only APAC needs the fix. The recommended fix moves the final PurchVarACY assignment inside the non-document-amount else branch (mirroring the other layers' structure) so it only recomputes PurchVarACY for the CalcACYAmt/CurrExchRate fallback path.

Suggested fix (apply manually — could not be anchored as a one-click suggestion):

            end else begin
                if ShouldUseDocumentAmountForACY() then begin
                    if Expected then
                        DirCostACY := ItemJnlLine."Unit Cost (ACY)" * ItemJnlLine.Quantity + RoundingResidualAmountACY
                    else
                        DirCostACY := ItemJnlLine."Unit Cost (ACY)" * ItemJnlLine."Invoiced Quantity";
                    OvhdCostACY := 0;
                    PurchVarACY := 0;
                end else begin
                    DirCostACY := ACYMgt.CalcACYAmt(DirCost, ItemJnlLine."Posting Date", false);
                    OvhdCostACY := ACYMgt.CalcACYAmt(OvhdCost, ItemJnlLine."Posting Date", false);
                    ItemJnlLine."Unit Cost (ACY)" :=
                      Round(
                        CurrExchRate.ExchangeAmtLCYToFCY(
                          ItemJnlLine."Posting Date", GLSetup."Additional Reporting Currency", ItemJnlLine."Unit Cost",
                          CurrExchRate.ExchangeRate(
                            ItemJnlLine."Posting Date", GLSetup."Additional Reporting Currency")),
                        Currency."Unit-Amount Rounding Precision");
                    PurchVarACY := ItemJnlLine."Unit Cost (ACY)" * ItemJnlLine."Invoiced Quantity" - DirCostACY - OvhdCostACY;
                end;
            end else begin
                DirCostACY := ACYMgt.CalcACYAmt(DirCost, ItemJnlLine."Posting Date", false);
                OvhdCostACY := ACYMgt.CalcACYAmt(OvhdCost, ItemJnlLine."Posting Date", false);
                ItemJnlLine."Unit Cost (ACY)" :=
                  Round(
                    CurrExchRate.ExchangeAmtLCYToFCY(
                      ItemJnlLine."Posting Date", GLSetup."Additional Reporting Currency", ItemJnlLine."Unit Cost",
                      CurrExchRate.ExchangeRate(
                        ItemJnlLine."Posting Date", GLSetup."Additional Reporting Currency")),
                    Currency."Unit-Amount Rounding Precision");
                PurchVarACY := ItemJnlLine."Unit Cost (ACY)" * ItemJnlLine."Invoiced Quantity" - DirCostACY - OvhdCostACY;
            end;

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.32.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

SCM GitHub request for SCM area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant