From 5fdb307116d7128844f9bbe1903c0ffe322e246f Mon Sep 17 00:00:00 2001 From: vpj-cd Date: Tue, 27 Jan 2009 17:29:03 +0000 Subject: [PATCH] It is not rolling up correctly the lower level costs https://sourceforge.net/tracker2/?func=detail&aid=2530003&group_id=176962&atid=879332 Fix Validate CostingLevel --- base/src/org/compiere/model/MResource.java | 9 +-------- base/src/org/compiere/wf/MWFNode.java | 10 ++++++++++ .../org/eevolution/process/RollupBillOfMaterial.java | 9 ++++++++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/base/src/org/compiere/model/MResource.java b/base/src/org/compiere/model/MResource.java index 0723326614..3558b2efc9 100644 --- a/base/src/org/compiere/model/MResource.java +++ b/base/src/org/compiere/model/MResource.java @@ -172,14 +172,7 @@ public class MResource extends X_S_Resource */ public double getResouceRate(int C_AcctSchema_ID,int M_CostType_ID, String CostElementType , int AD_Org_ID) { - - MAcctSchema as = MAcctSchema.get(getCtx(), C_AcctSchema_ID); - MProduct product = getProduct(); - if(MAcctSchema.COSTINGLEVEL_Client.equals(product.getCostingLevel(as))) - { - AD_Org_ID = 0; - } - + final String sql = "SELECT SUM(c."+MCost.COLUMNNAME_CurrentCostPrice+")" +" FROM M_Cost c, M_CostElement ce, M_Product p" +" WHERE c.AD_Client_ID=? AND c.AD_Org_ID=?" diff --git a/base/src/org/compiere/wf/MWFNode.java b/base/src/org/compiere/wf/MWFNode.java index f4ac577a0a..a038e57b7c 100644 --- a/base/src/org/compiere/wf/MWFNode.java +++ b/base/src/org/compiere/wf/MWFNode.java @@ -27,7 +27,9 @@ import java.util.Properties; import java.util.logging.Level; import org.adempiere.exceptions.AdempiereException; +import org.compiere.model.MAcctSchema; import org.compiere.model.MColumn; +import org.compiere.model.MProduct; import org.compiere.model.MResource; import org.compiere.model.MUOM; import org.compiere.model.X_AD_WF_Node; @@ -677,6 +679,14 @@ public class MWFNode extends X_AD_WF_Node MResource resource = (MResource) getS_Resource(); //get the rate and convert in second for this cost type element (Resource, Burden) MWorkflow workflow = getWorkflow(); + // Validate the CostingLevel + MAcctSchema as = MAcctSchema.get(getCtx(), C_AcctSchema_ID); + MProduct product = resource.getProduct(); + if(MAcctSchema.COSTINGLEVEL_Client.equals(product.getCostingLevel(as))) + { + AD_Org_ID = 0; + } + double rate = resource.getResouceRate(C_AcctSchema_ID, M_CostType_ID,CostElementType, AD_Org_ID); BigDecimal cost = Env.ZERO; if (rate == 0) diff --git a/base/src/org/eevolution/process/RollupBillOfMaterial.java b/base/src/org/eevolution/process/RollupBillOfMaterial.java index b4cac38b10..f771fbc135 100644 --- a/base/src/org/eevolution/process/RollupBillOfMaterial.java +++ b/base/src/org/eevolution/process/RollupBillOfMaterial.java @@ -92,7 +92,14 @@ public class RollupBillOfMaterial extends SvrProcess for (int lowLevel = maxLowLevel; lowLevel >= 0; lowLevel--) { for (MProduct product : getProducts(lowLevel)) - { + { + // Validate the CostingLevel + MAcctSchema as = MAcctSchema.get(getCtx(), p_C_AcctSchema_ID); + if(MAcctSchema.COSTINGLEVEL_Client.equals(product.getCostingLevel(as))) + { + p_AD_Org_ID = 0; + } + for (MCost cost : getCosts(product.get_ID())) { log.info("Calculate Lower Cost for :"+ product.getName());