From 06ce3aae940c0da4ed801b10cbfee16d830ba283 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Mon, 5 May 2014 15:29:23 +0800 Subject: [PATCH] 1003754 Landed cost issue -- related to IDEMPIERE-1285. Fix landed cost posting. --- .../src/org/compiere/acct/Doc_Invoice.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/org.adempiere.base/src/org/compiere/acct/Doc_Invoice.java b/org.adempiere.base/src/org/compiere/acct/Doc_Invoice.java index ef2e6076ed..6dafc5fc2f 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc_Invoice.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc_Invoice.java @@ -977,6 +977,25 @@ public class Doc_Invoice extends Doc fl.setQty(line.getQty()); } else if (compare < 0) + { + drAmt = dr ? (reversal ? null : allocationAmt) : (reversal ? allocationAmt : null); + crAmt = dr ? (reversal ? allocationAmt : null) : (reversal ? null : allocationAmt); + account = pc.getAccount(ProductCost.ACCTTYPE_P_LandedCostClearing, as); + FactLine fl = fact.createLine (line, account, getC_Currency_ID(), drAmt, crAmt); + fl.setDescription(desc); + fl.setM_Product_ID(lca.getM_Product_ID()); + fl.setQty(line.getQty()); + + BigDecimal underAmt = estimatedAmt.subtract(allocationAmt); + drAmt = dr ? (reversal ? underAmt : null) : (reversal ? null : underAmt); + crAmt = dr ? (reversal ? null : underAmt) : (reversal ? underAmt : null); + account = zeroQty ? pc.getAccount(ProductCost.ACCTTYPE_P_AverageCostVariance, as) : pc.getAccount(ProductCost.ACCTTYPE_P_Asset, as); + fl = fact.createLine (line, account, getC_Currency_ID(), drAmt, crAmt); + fl.setDescription(desc); + fl.setM_Product_ID(lca.getM_Product_ID()); + fl.setQty(line.getQty()); + } + else { drAmt = dr ? (reversal ? null : allocationAmt) : (reversal ? allocationAmt : null); crAmt = dr ? (reversal ? allocationAmt : null) : (reversal ? null : allocationAmt);