diff --git a/src/Layers/APAC/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al b/src/Layers/APAC/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al index 2bc2186e763..9550698760d 100644 --- a/src/Layers/APAC/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al +++ b/src/Layers/APAC/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al @@ -3689,16 +3689,24 @@ codeunit 22 "Item Jnl.-Post Line" 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 + 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"); + 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"); end; end else begin DirCostACY := ACYMgt.CalcACYAmt(DirCost, ItemJnlLine."Posting Date", false); @@ -3711,8 +3719,8 @@ codeunit 22 "Item Jnl.-Post Line" ItemJnlLine."Posting Date", GLSetup."Additional Reporting Currency")), Currency."Unit-Amount Rounding Precision"); end; - PurchVarACY := ItemJnlLine."Unit Cost (ACY)" * ItemJnlLine."Invoiced Quantity" - DirCostACY - OvhdCostACY; - end; + PurchVarACY := ItemJnlLine."Unit Cost (ACY)" * ItemJnlLine."Invoiced Quantity" - DirCostACY - OvhdCostACY; + end; CalcUnitCost := (DirCost <> 0) and (ItemJnlLine."Unit Cost" = 0); OnAfterCalcPosShares(ItemJnlLine, DirCost, OvhdCost, PurchVar, DirCostACY, OvhdCostACY, PurchVarACY, CalcUnitCost, CalcPurchVar, Expected, GlobalItemLedgEntry); @@ -6076,6 +6084,16 @@ codeunit 22 "Item Jnl.-Post Line" exit(false); end; + local procedure ShouldUseDocumentAmountForACY(): Boolean + begin + exit( + (ItemJnlLine."Source Currency Code" = GLSetup."Additional Reporting Currency") and + (Item."Costing Method" <> Item."Costing Method"::Standard) and + (ItemJnlLine."Discount Amount" = 0) and + (ItemJnlLine."Indirect Cost %" = 0) and + (ItemJnlLine."Overhead Rate" = 0)); + end; + [IntegrationEvent(false, false)] local procedure OnBeforeAllowProdApplication(OldItemLedgerEntry: Record "Item Ledger Entry"; ItemLedgerEntry: Record "Item Ledger Entry"; var AllowApplication: Boolean) begin diff --git a/src/Layers/CH/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al b/src/Layers/CH/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al index 134044c2f9d..7f81396eb53 100644 --- a/src/Layers/CH/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al +++ b/src/Layers/CH/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al @@ -3673,18 +3673,26 @@ codeunit 22 "Item Jnl.-Post Line" end; end; - if GLSetup."Additional Reporting Currency" <> '' then 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; + if GLSetup."Additional Reporting Currency" <> '' then + 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; CalcUnitCost := (DirCost <> 0) and (ItemJnlLine."Unit Cost" = 0); OnAfterCalcPosShares(ItemJnlLine, DirCost, OvhdCost, PurchVar, DirCostACY, OvhdCostACY, PurchVarACY, CalcUnitCost, CalcPurchVar, Expected, GlobalItemLedgEntry); @@ -6047,6 +6055,16 @@ codeunit 22 "Item Jnl.-Post Line" exit(false); end; + local procedure ShouldUseDocumentAmountForACY(): Boolean + begin + exit( + (ItemJnlLine."Source Currency Code" = GLSetup."Additional Reporting Currency") and + (Item."Costing Method" <> Item."Costing Method"::Standard) and + (ItemJnlLine."Discount Amount" = 0) and + (ItemJnlLine."Indirect Cost %" = 0) and + (ItemJnlLine."Overhead Rate" = 0)); + end; + [IntegrationEvent(false, false)] local procedure OnBeforeAllowProdApplication(OldItemLedgerEntry: Record "Item Ledger Entry"; ItemLedgerEntry: Record "Item Ledger Entry"; var AllowApplication: Boolean) begin diff --git a/src/Layers/ES/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al b/src/Layers/ES/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al index f23c1ae14f4..cd3ea599674 100644 --- a/src/Layers/ES/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al +++ b/src/Layers/ES/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al @@ -3682,18 +3682,26 @@ codeunit 22 "Item Jnl.-Post Line" end; end; - if GLSetup."Additional Reporting Currency" <> '' then 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; + if GLSetup."Additional Reporting Currency" <> '' then + 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; CalcUnitCost := (DirCost <> 0) and (ItemJnlLine."Unit Cost" = 0); OnAfterCalcPosShares(ItemJnlLine, DirCost, OvhdCost, PurchVar, DirCostACY, OvhdCostACY, PurchVarACY, CalcUnitCost, CalcPurchVar, Expected, GlobalItemLedgEntry); @@ -6057,6 +6065,16 @@ codeunit 22 "Item Jnl.-Post Line" exit(false); end; + local procedure ShouldUseDocumentAmountForACY(): Boolean + begin + exit( + (ItemJnlLine."Source Currency Code" = GLSetup."Additional Reporting Currency") and + (Item."Costing Method" <> Item."Costing Method"::Standard) and + (ItemJnlLine."Discount Amount" = 0) and + (ItemJnlLine."Indirect Cost %" = 0) and + (ItemJnlLine."Overhead Rate" = 0)); + end; + [IntegrationEvent(false, false)] local procedure OnBeforeAllowProdApplication(OldItemLedgerEntry: Record "Item Ledger Entry"; ItemLedgerEntry: Record "Item Ledger Entry"; var AllowApplication: Boolean) begin diff --git a/src/Layers/IT/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al b/src/Layers/IT/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al index 0292e2402cd..02703bfdc37 100644 --- a/src/Layers/IT/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al +++ b/src/Layers/IT/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al @@ -3700,18 +3700,26 @@ codeunit 22 "Item Jnl.-Post Line" end; end; - if GLSetup."Additional Reporting Currency" <> '' then 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; + if GLSetup."Additional Reporting Currency" <> '' then + 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; CalcUnitCost := (DirCost <> 0) and (ItemJnlLine."Unit Cost" = 0); OnAfterCalcPosShares(ItemJnlLine, DirCost, OvhdCost, PurchVar, DirCostACY, OvhdCostACY, PurchVarACY, CalcUnitCost, CalcPurchVar, Expected, GlobalItemLedgEntry); @@ -6074,6 +6082,16 @@ codeunit 22 "Item Jnl.-Post Line" exit(false); end; + local procedure ShouldUseDocumentAmountForACY(): Boolean + begin + exit( + (ItemJnlLine."Source Currency Code" = GLSetup."Additional Reporting Currency") and + (Item."Costing Method" <> Item."Costing Method"::Standard) and + (ItemJnlLine."Discount Amount" = 0) and + (ItemJnlLine."Indirect Cost %" = 0) and + (ItemJnlLine."Overhead Rate" = 0)); + end; + [IntegrationEvent(false, false)] local procedure OnBeforeAllowProdApplication(OldItemLedgerEntry: Record "Item Ledger Entry"; ItemLedgerEntry: Record "Item Ledger Entry"; var AllowApplication: Boolean) begin diff --git a/src/Layers/RU/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al b/src/Layers/RU/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al index 930e79a0d6d..31ccec23007 100644 --- a/src/Layers/RU/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al +++ b/src/Layers/RU/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al @@ -3712,18 +3712,26 @@ codeunit 22 "Item Jnl.-Post Line" end; end; - if GLSetup."Additional Reporting Currency" <> '' then 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; + if GLSetup."Additional Reporting Currency" <> '' then + 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; CalcUnitCost := (DirCost <> 0) and (ItemJnlLine."Unit Cost" = 0); OnAfterCalcPosShares(ItemJnlLine, DirCost, OvhdCost, PurchVar, DirCostACY, OvhdCostACY, PurchVarACY, CalcUnitCost, CalcPurchVar, Expected, GlobalItemLedgEntry); @@ -6392,6 +6400,16 @@ codeunit 22 "Item Jnl.-Post Line" exit(false); end; + local procedure ShouldUseDocumentAmountForACY(): Boolean + begin + exit( + (ItemJnlLine."Source Currency Code" = GLSetup."Additional Reporting Currency") and + (Item."Costing Method" <> Item."Costing Method"::Standard) and + (ItemJnlLine."Discount Amount" = 0) and + (ItemJnlLine."Indirect Cost %" = 0) and + (ItemJnlLine."Overhead Rate" = 0)); + end; + [IntegrationEvent(false, false)] local procedure OnBeforeAllowProdApplication(OldItemLedgerEntry: Record "Item Ledger Entry"; ItemLedgerEntry: Record "Item Ledger Entry"; var AllowApplication: Boolean) begin diff --git a/src/Layers/W1/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al b/src/Layers/W1/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al index 755acf686b4..db63aa99a10 100644 --- a/src/Layers/W1/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al +++ b/src/Layers/W1/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al @@ -3669,18 +3669,26 @@ codeunit 22 "Item Jnl.-Post Line" end; end; - if GLSetup."Additional Reporting Currency" <> '' then 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; + if GLSetup."Additional Reporting Currency" <> '' then + 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; CalcUnitCost := (DirCost <> 0) and (ItemJnlLine."Unit Cost" = 0); OnAfterCalcPosShares(ItemJnlLine, DirCost, OvhdCost, PurchVar, DirCostACY, OvhdCostACY, PurchVarACY, CalcUnitCost, CalcPurchVar, Expected, GlobalItemLedgEntry); @@ -6043,6 +6051,16 @@ codeunit 22 "Item Jnl.-Post Line" exit(false); end; + local procedure ShouldUseDocumentAmountForACY(): Boolean + begin + exit( + (ItemJnlLine."Source Currency Code" = GLSetup."Additional Reporting Currency") and + (Item."Costing Method" <> Item."Costing Method"::Standard) and + (ItemJnlLine."Discount Amount" = 0) and + (ItemJnlLine."Indirect Cost %" = 0) and + (ItemJnlLine."Overhead Rate" = 0)); + end; + [IntegrationEvent(false, false)] local procedure OnBeforeAllowProdApplication(OldItemLedgerEntry: Record "Item Ledger Entry"; ItemLedgerEntry: Record "Item Ledger Entry"; var AllowApplication: Boolean) begin