From f13092548fe5d8f3959b6eeafccd11222092f0c8 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 26 Nov 2012 13:44:35 -0500 Subject: [PATCH] IDEMPIERE-246 Integrate Manufacturing Light / Fixes: - bug on cost difference calculation - make the creation of production lines according with iDempiere architecture (configurable via sysconfig) - must not require accounting consequences to create production lines --- .../compiere/process/ProductionCreate.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/org.adempiere.base.process/src/org/compiere/process/ProductionCreate.java b/org.adempiere.base.process/src/org/compiere/process/ProductionCreate.java index f1b23b0ea5..2ff78d2986 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ProductionCreate.java +++ b/org.adempiere.base.process/src/org/compiere/process/ProductionCreate.java @@ -4,8 +4,10 @@ import java.math.BigDecimal; import java.util.logging.Level; import org.compiere.model.MProduction; +import org.compiere.model.MSysConfig; import org.compiere.util.AdempiereUserError; import org.compiere.util.DB; +import org.compiere.util.Env; /** @@ -62,6 +64,7 @@ public class ProductionCreate extends SvrProcess { String sql = "SELECT ABS(((cc.currentcostprice-(SELECT SUM(c.currentcostprice*bom.bomqty)" + " FROM m_cost c" + " INNER JOIN m_product_bom bom ON (c.m_product_id=bom.m_productbom_id)" + + " INNER JOIN m_costelement ce ON (c.m_costelement_id = ce.m_costelement_id AND ce.costingmethod = 'S')" + " WHERE bom.m_product_id = pp.m_product_id)" + " )/cc.currentcostprice))" + " FROM m_product pp" @@ -74,7 +77,13 @@ public class ProductionCreate extends SvrProcess { if (costPercentageDiff == null) { - throw new AdempiereUserError("Could not retrieve costs"); + costPercentageDiff = Env.ZERO; + String msg = "Could not retrieve costs"; + if (MSysConfig.getBooleanValue("MFG_ValidateCostsOnCreate", false, getAD_Client_ID())) { + throw new AdempiereUserError(msg); + } else { + log.warning(msg); + } } if ( (costPercentageDiff.compareTo(new BigDecimal("0.005")))< 0 ) @@ -88,10 +97,16 @@ public class ProductionCreate extends SvrProcess { int created = 0; isBom(m_production.getM_Product_ID()); - if (!costsOK(m_production.getM_Product_ID())) + if (!costsOK(m_production.getM_Product_ID())) { + String msg = "Excessive difference in standard costs"; + if (MSysConfig.getBooleanValue("MFG_ValidateCostsDifferenceOnCreate", false, getAD_Client_ID())) { throw new AdempiereUserError("Excessive difference in standard costs"); + } else { + log.warning(msg); + } + } - if (!recreate && "true".equalsIgnoreCase(m_production.get_ValueAsString("IsCreated"))) + if (!recreate && "Y".equalsIgnoreCase(m_production.getIsCreated())) throw new AdempiereUserError("Production already created."); if (newQty != null )