[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
Conversation
| 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 |
There was a problem hiding this comment.
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
AB#646085