From a6bbb96983c8f0d972487e37ddd46abbced78a86 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Fri, 7 Feb 2014 16:48:44 +0800 Subject: [PATCH] 1003754 Landed cost issue -- related to IDEMPIERE-1285. Fixed the transfer of invoice price variance to product cost for average invoice and average po costing. --- .../src/org/compiere/acct/Doc_MatchInv.java | 10 ++++++++++ .../src/org/compiere/model/MInvoice.java | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java b/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java index da6f38add4..632b18bccf 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java @@ -403,6 +403,16 @@ public class Doc_MatchInv extends Doc as.getC_Currency_ID(), ipv.negate()); updateFactLine(line); + line = fact.createLine(null, account, as.getC_Currency_ID(), ipv); + updateFactLine(line); + } else if (X_M_Cost.COSTINGMETHOD_AverageInvoice.equals(costingMethod) && !zeroQty) { + MAccount account = m_pc.getAccount(ProductCost.ACCTTYPE_P_Asset, as); + + FactLine line = fact.createLine(null, + m_pc.getAccount(ProductCost.ACCTTYPE_P_IPV, as), + as.getC_Currency_ID(), ipv.negate()); + updateFactLine(line); + line = fact.createLine(null, account, as.getC_Currency_ID(), ipv); updateFactLine(line); } diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index 5ac7f638ed..069c02478d 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -1828,6 +1828,18 @@ public class MInvoice extends X_C_Invoice implements DocAction matchPO++; if (!po.isPosted() && po.getM_InOutLine_ID() > 0) // match po don't post if receipt is not assigned, and it doesn't create avg po record addDocsPostProcess(po); + + MMatchInv[] matchInvoices = MMatchInv.getInvoiceLine(getCtx(), line.getC_InvoiceLine_ID(), get_TrxName()); + if (matchInvoices != null && matchInvoices.length > 0) + { + for(MMatchInv matchInvoice : matchInvoices) + { + if (!matchInvoice.isPosted()) + { + addDocsPostProcess(matchInvoice); + } + } + } } } }