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
This commit is contained in:
Carlos Ruiz 2012-11-26 13:44:35 -05:00
parent a7b786a446
commit f13092548f
1 changed files with 18 additions and 3 deletions

View File

@ -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 )