From 93a64eeea620f2c5e96530a8644e97fe3904dda1 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 27 Jun 2008 17:47:33 +0000 Subject: [PATCH] Fix [ 1965015 ] Posting not balanced when is producing more than 1 product --- base/src/org/compiere/acct/Doc_Production.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/base/src/org/compiere/acct/Doc_Production.java b/base/src/org/compiere/acct/Doc_Production.java index 1f36e254f3..dd09b77f73 100644 --- a/base/src/org/compiere/acct/Doc_Production.java +++ b/base/src/org/compiere/acct/Doc_Production.java @@ -189,6 +189,15 @@ public class Doc_Production extends Doc bomCost = bomCost.add(line0.getProductCosts(as, line.getAD_Org_ID(), false)); } costs = bomCost.negate(); + // [ 1965015 ] Posting not balanced when is producing more than 1 product - Globalqss 2008/06/26 + X_M_ProductionPlan mpp = new X_M_ProductionPlan(getCtx(), line.getM_ProductionPlan_ID(), getTrxName()); + if (line.getQty() != mpp.getProductionQty()) { + // if the line doesn't correspond with the whole qty produced then apply prorate + // costs = costs * line_qty / production_qty + costs = costs.multiply(line.getQty(), + new MathContext(as.getCostingPrecision(), RoundingMode.valueOf(BigDecimal.ROUND_HALF_UP))); + costs = costs.divide(mpp.getProductionQty(), as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP); + } } else costs = line.getProductCosts(as, line.getAD_Org_ID(), false);