BF [ 2530090 ] It doesn't get the right UOM into the Manufacturing Order
https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2530090&group_id=176962 RollupBillOfMaterial.java : fixed a possible issue when different products have different costing levels RULE: never modify a process parameter variable because it's too error prone (like p_AD_Org_ID in this case)
This commit is contained in:
parent
34c5d24147
commit
147a545e89
|
|
@ -93,14 +93,15 @@ public class RollupBillOfMaterial extends SvrProcess
|
||||||
{
|
{
|
||||||
for (MProduct product : getProducts(lowLevel))
|
for (MProduct product : getProducts(lowLevel))
|
||||||
{
|
{
|
||||||
|
int AD_Org_ID = p_AD_Org_ID;
|
||||||
// Validate the CostingLevel
|
// Validate the CostingLevel
|
||||||
MAcctSchema as = MAcctSchema.get(getCtx(), p_C_AcctSchema_ID);
|
MAcctSchema as = MAcctSchema.get(getCtx(), p_C_AcctSchema_ID);
|
||||||
if(MAcctSchema.COSTINGLEVEL_Client.equals(product.getCostingLevel(as)))
|
if(MAcctSchema.COSTINGLEVEL_Client.equals(product.getCostingLevel(as)))
|
||||||
{
|
{
|
||||||
p_AD_Org_ID = 0;
|
AD_Org_ID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MCost cost : getCosts(product.get_ID()))
|
for (MCost cost : getCosts(product.get_ID(), AD_Org_ID))
|
||||||
{
|
{
|
||||||
log.info("Calculate Lower Cost for :"+ product.getName());
|
log.info("Calculate Lower Cost for :"+ product.getName());
|
||||||
MCostElement element = cost.getCostElement();
|
MCostElement element = cost.getCostElement();
|
||||||
|
|
@ -109,42 +110,42 @@ public class RollupBillOfMaterial extends SvrProcess
|
||||||
// check if element cost is of Material Type
|
// check if element cost is of Material Type
|
||||||
if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_Material))
|
if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_Material))
|
||||||
{
|
{
|
||||||
BigDecimal Material = getCurrentCostPriceLL(MCostElement.COSTELEMENTTYPE_Material, product);
|
BigDecimal Material = getCurrentCostPriceLL(MCostElement.COSTELEMENTTYPE_Material, product, AD_Org_ID);
|
||||||
log.info("Material Cost Low Level:" + Material);
|
log.info("Material Cost Low Level:" + Material);
|
||||||
cost.setCurrentCostPriceLL(Material);
|
cost.setCurrentCostPriceLL(Material);
|
||||||
cost.saveEx();
|
cost.saveEx();
|
||||||
}
|
}
|
||||||
else if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_Resource))
|
else if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_Resource))
|
||||||
{
|
{
|
||||||
BigDecimal Labor = getCurrentCostPriceLL(MCostElement.COSTELEMENTTYPE_Resource, product);
|
BigDecimal Labor = getCurrentCostPriceLL(MCostElement.COSTELEMENTTYPE_Resource, product, AD_Org_ID);
|
||||||
log.info("Labor Cost Low Level:" + Labor);
|
log.info("Labor Cost Low Level:" + Labor);
|
||||||
cost.setCurrentCostPriceLL(Labor);
|
cost.setCurrentCostPriceLL(Labor);
|
||||||
cost.saveEx();
|
cost.saveEx();
|
||||||
}
|
}
|
||||||
else if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_BurdenMOverhead))
|
else if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_BurdenMOverhead))
|
||||||
{
|
{
|
||||||
BigDecimal Burder = getCurrentCostPriceLL(MCostElement.COSTELEMENTTYPE_BurdenMOverhead, product);
|
BigDecimal Burder = getCurrentCostPriceLL(MCostElement.COSTELEMENTTYPE_BurdenMOverhead, product, AD_Org_ID);
|
||||||
log.info("Burden Cost Low Level:" + Burder);
|
log.info("Burden Cost Low Level:" + Burder);
|
||||||
cost.setCurrentCostPriceLL(Burder);
|
cost.setCurrentCostPriceLL(Burder);
|
||||||
cost.saveEx();
|
cost.saveEx();
|
||||||
}
|
}
|
||||||
else if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_Overhead))
|
else if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_Overhead))
|
||||||
{
|
{
|
||||||
BigDecimal Overhead = getCurrentCostPriceLL(MCostElement.COSTELEMENTTYPE_Overhead, product);
|
BigDecimal Overhead = getCurrentCostPriceLL(MCostElement.COSTELEMENTTYPE_Overhead, product, AD_Org_ID);
|
||||||
log.info("Overhead Cost Low Level:" + Overhead);
|
log.info("Overhead Cost Low Level:" + Overhead);
|
||||||
cost.setCurrentCostPriceLL(Overhead);
|
cost.setCurrentCostPriceLL(Overhead);
|
||||||
cost.saveEx();
|
cost.saveEx();
|
||||||
}
|
}
|
||||||
else if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_OutsideProcessing))
|
else if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_OutsideProcessing))
|
||||||
{
|
{
|
||||||
BigDecimal Subcontract = getCurrentCostPriceLL(MCostElement.COSTELEMENTTYPE_OutsideProcessing, product);
|
BigDecimal Subcontract = getCurrentCostPriceLL(MCostElement.COSTELEMENTTYPE_OutsideProcessing, product, AD_Org_ID);
|
||||||
log.info("Subcontract Cost Low Level:" + Subcontract);
|
log.info("Subcontract Cost Low Level:" + Subcontract);
|
||||||
cost.setCurrentCostPriceLL(Subcontract);
|
cost.setCurrentCostPriceLL(Subcontract);
|
||||||
cost.saveEx();
|
cost.saveEx();
|
||||||
}
|
}
|
||||||
else if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_Overhead))
|
else if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_Overhead))
|
||||||
{
|
{
|
||||||
BigDecimal Subcontract = getCurrentCostPriceLL(MCostElement.COSTELEMENTTYPE_Overhead, product);
|
BigDecimal Subcontract = getCurrentCostPriceLL(MCostElement.COSTELEMENTTYPE_Overhead, product, AD_Org_ID);
|
||||||
log.info("Overhead Cost Low Level:" + Subcontract);
|
log.info("Overhead Cost Low Level:" + Subcontract);
|
||||||
cost.setCurrentCostPriceLL(Subcontract);
|
cost.setCurrentCostPriceLL(Subcontract);
|
||||||
cost.saveEx();
|
cost.saveEx();
|
||||||
|
|
@ -153,7 +154,7 @@ public class RollupBillOfMaterial extends SvrProcess
|
||||||
else if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_Distribution))
|
else if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_Distribution))
|
||||||
{
|
{
|
||||||
|
|
||||||
BigDecimal Distribution = getCurrentCostPriceLL(MCostElement.COSTELEMENTTYPE_Distribution, M_Product_ID);
|
BigDecimal Distribution = getCurrentCostPriceLL(MCostElement.COSTELEMENTTYPE_Distribution, M_Product_ID, AD_Org_ID);
|
||||||
cost.setCurrentCostPriceLL(Distribution);
|
cost.setCurrentCostPriceLL(Distribution);
|
||||||
cost.saveEx();
|
cost.saveEx();
|
||||||
}
|
}
|
||||||
|
|
@ -174,11 +175,11 @@ public class RollupBillOfMaterial extends SvrProcess
|
||||||
* @param C_AcctSchema_ID Account Schema
|
* @param C_AcctSchema_ID Account Schema
|
||||||
* @return CurrentCostPriceLL Sum Current Cost Price Level Low for this Cost Element Type
|
* @return CurrentCostPriceLL Sum Current Cost Price Level Low for this Cost Element Type
|
||||||
*/
|
*/
|
||||||
private BigDecimal getCurrentCostPriceLL(String CostElementType, MProduct product)
|
private BigDecimal getCurrentCostPriceLL(String CostElementType, MProduct product, int AD_Org_ID)
|
||||||
{
|
{
|
||||||
log.info("ElementType: "+CostElementType);
|
log.info("ElementType: "+CostElementType);
|
||||||
BigDecimal costPriceLL = Env.ZERO;
|
BigDecimal costPriceLL = Env.ZERO;
|
||||||
MPPProductPlanning pp = MPPProductPlanning.find(getCtx(), p_AD_Org_ID,
|
MPPProductPlanning pp = MPPProductPlanning.find(getCtx(), AD_Org_ID,
|
||||||
0, // M_Warehouse_ID
|
0, // M_Warehouse_ID
|
||||||
0, // S_Resource_ID
|
0, // S_Resource_ID
|
||||||
product.getM_Product_ID(),
|
product.getM_Product_ID(),
|
||||||
|
|
@ -202,7 +203,7 @@ public class RollupBillOfMaterial extends SvrProcess
|
||||||
for (MPPProductBOMLine bomline : bom.getLines())
|
for (MPPProductBOMLine bomline : bom.getLines())
|
||||||
{
|
{
|
||||||
// get the rate for this resource
|
// get the rate for this resource
|
||||||
for (MCost cost : getCosts(bomline.getM_Product_ID()))
|
for (MCost cost : getCosts(bomline.getM_Product_ID(), AD_Org_ID))
|
||||||
{
|
{
|
||||||
MCostElement element = cost.getCostElement();
|
MCostElement element = cost.getCostElement();
|
||||||
// check if current cost element type is specified cost element type
|
// check if current cost element type is specified cost element type
|
||||||
|
|
@ -244,7 +245,7 @@ public class RollupBillOfMaterial extends SvrProcess
|
||||||
return costPriceLL;
|
return costPriceLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MCost[] getCosts(int product_id)
|
private MCost[] getCosts(int product_id, int AD_Org_ID)
|
||||||
{
|
{
|
||||||
return MCost.getCosts(getCtx(), getAD_Client_ID(), p_AD_Org_ID, product_id,
|
return MCost.getCosts(getCtx(), getAD_Client_ID(), p_AD_Org_ID, product_id,
|
||||||
p_M_CostType_ID, p_C_AcctSchema_ID , get_TrxName());
|
p_M_CostType_ID, p_C_AcctSchema_ID , get_TrxName());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue