Example the Calculate Roll-Up for Patio Set

http://sourceforge.net/tracker/?func=detail&atid=879335&aid=2494851&group_id=176962

Fix issue with the Roll-Up Workflow
This commit is contained in:
vpj-cd 2009-01-09 01:42:15 +00:00
parent 5aa1925f22
commit c9994ef0b8
3 changed files with 331 additions and 18 deletions

View File

@ -154,12 +154,14 @@ public class RollupWorkflow extends SvrProcess
node.setCost(Env.ZERO);
}
BigDecimal m_cost = Env.ZERO;
BigDecimal labor = Env.ZERO;
BigDecimal burden = Env.ZERO;
MCost[] costs = MCost.getCosts(getCtx(), getAD_Client_ID(), p_AD_Org_ID, product.getM_Product_ID(), p_M_CostType_ID, p_C_AcctSchema_ID , get_TrxName());
for (MCost cost : costs)
{
MCostElement element = cost.getCostElement();
if(element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_Resource) || element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_BurdenMOverhead))
if(element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_Resource)
|| element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_BurdenMOverhead))
{
for (MWFNode node : nodes)
@ -169,12 +171,12 @@ public class RollupWorkflow extends SvrProcess
if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_Resource))
{
nodeCost = node.getCostForCostElementType(MCostElement.COSTELEMENTTYPE_Resource ,p_C_AcctSchema_ID, p_M_CostType_ID, p_AD_Org_ID, node.getSetupTime(), node.getDuration());
m_cost = m_cost.add(nodeCost);
labor = labor.add(nodeCost);
}
else if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_BurdenMOverhead))
{
nodeCost = node.getCostForCostElementType(MCostElement.COSTELEMENTTYPE_BurdenMOverhead ,p_C_AcctSchema_ID, p_M_CostType_ID, p_AD_Org_ID, node.getSetupTime(), node.getDuration());
m_cost = m_cost.add(nodeCost);
burden = burden.add(nodeCost);
}
if(nodeCost.signum() != 0)
{
@ -182,22 +184,23 @@ public class RollupWorkflow extends SvrProcess
node.saveEx();
}
}
// check if element cost is of type Labor
if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_Resource))
{
log.info("Product:"+product.getName()+" Labor: " + m_cost);
cost.setCurrentCostPrice(m_cost);
cost.saveEx();
}
else if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_BurdenMOverhead))
{
log.info("Product:"+product.getName()+" Burden: " + m_cost);
cost.setCurrentCostPrice(m_cost);
cost.saveEx();
}
// check if element cost is of type Labor
if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_Resource))
{
log.info("Product:"+product.getName()+" Labor: " + labor);
cost.setCurrentCostPrice(labor);
cost.saveEx();
}
else if (element.getCostElementType().equals(MCostElement.COSTELEMENTTYPE_BurdenMOverhead))
{
log.info("Product:"+product.getName()+" Burden: " + burden);
cost.setCurrentCostPrice(burden);
cost.saveEx();
}
}
}
workflow.setCost(workflow.getCost().add(m_cost));
workflow.setCost(labor.add(burden));
workflow.saveEx(get_TrxName());
}
return "@OK@";

View File

@ -0,0 +1,155 @@
-- Jan 8, 2009 7:23:10 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=731, SeqNo=0, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=732
;
-- Jan 8, 2009 7:23:10 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=731, SeqNo=1, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=733
;
-- Jan 8, 2009 7:23:10 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=50008, SeqNo=0, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=50007
;
-- Jan 8, 2009 7:23:10 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=50008, SeqNo=1, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=50009
;
-- Jan 8, 2009 7:23:10 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=50008, SeqNo=2, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=50014
;
-- Jan 8, 2009 7:23:23 PM ECT
-- Standard Cost for Manufacturing
UPDATE C_ElementValue SET Value='83300',Updated=TO_DATE('2009-01-08 19:23:23','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_ElementValue_ID=50014
;
-- Jan 8, 2009 7:23:23 PM ECT
-- Standard Cost for Manufacturing
UPDATE C_ValidCombination SET Combination='HQ-83300-_-_-_-_', Description='HQ-Overhead (Applied)-_-_-_-_',Updated=TO_DATE('2009-01-08 19:23:23','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_ValidCombination_ID=50011
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=0, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=430
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=1, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=50010
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=2, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=50016
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=3, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=50011
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=4, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=431
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=5, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=781
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=6, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=780
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=7, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=778
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=8, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=432
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=9, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=433
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=10, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=434
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=11, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=435
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=12, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=438
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=13, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=634
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=14, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=443
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=15, Updated=SysDate WHERE AD_Tree_ID=101 AND Node_ID=446
;
-- Jan 8, 2009 8:21:42 PM ECT
-- Manufacturing Cost
UPDATE PP_Product_BOMLine SET QtyBOM=1.000000000000,Updated=TO_DATE('2009-01-08 20:21:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE PP_Product_BOMLine_ID=50002
;
-- Jan 8, 2009 8:21:45 PM ECT
-- Manufacturing Cost
UPDATE PP_Product_BOMLine SET QtyBOM=1.000000000000,Updated=TO_DATE('2009-01-08 20:21:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE PP_Product_BOMLine_ID=50003
;
-- Jan 8, 2009 8:22:37 PM ECT
-- Manufacturing Cost
UPDATE M_Cost SET CurrentCostPriceLL=13.39000000000000000000,Updated=TO_DATE('2009-01-08 20:22:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Org_ID=0 AND C_AcctSchema_ID=101 AND M_AttributeSetInstance_ID=0 AND M_CostElement_ID=100 AND M_CostType_ID=100 AND M_Product_ID=133
;
-- Jan 8, 2009 8:22:38 PM ECT
-- Manufacturing Cost
UPDATE M_Cost SET CurrentCostPriceLL=53.560000000000000000000000,Updated=TO_DATE('2009-01-08 20:22:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Org_ID=0 AND C_AcctSchema_ID=101 AND M_AttributeSetInstance_ID=0 AND M_CostElement_ID=100 AND M_CostType_ID=100 AND M_Product_ID=145
;
-- Jan 8, 2009 8:26:03 PM ECT
-- Manufacturing Cost
UPDATE M_Cost SET CurrentCostPrice=54.000000000000,Updated=TO_DATE('2009-01-08 20:26:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Org_ID=0 AND C_AcctSchema_ID=101 AND M_AttributeSetInstance_ID=0 AND M_CostElement_ID=100 AND M_CostType_ID=100 AND M_Product_ID=134
;
-- Jan 8, 2009 8:26:19 PM ECT
-- Manufacturing Cost
UPDATE M_ProductPrice SET PriceList=60.000000000000,Updated=TO_DATE('2009-01-08 20:26:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE M_PriceList_Version_ID=103 AND M_Product_ID=134
;
-- Jan 8, 2009 8:28:06 PM ECT
-- Manufacturing Cost
UPDATE M_Cost SET CurrentCostPrice=18.000000000000,Updated=TO_DATE('2009-01-08 20:28:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Org_ID=0 AND C_AcctSchema_ID=101 AND M_AttributeSetInstance_ID=0 AND M_CostElement_ID=100 AND M_CostType_ID=100 AND M_Product_ID=135
;
-- Jan 8, 2009 8:30:12 PM ECT
-- Manufacturing Cost
UPDATE M_Cost SET CurrentCostPriceLL=125.560000000000000000000000,Updated=TO_DATE('2009-01-08 20:30:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Org_ID=0 AND C_AcctSchema_ID=101 AND M_AttributeSetInstance_ID=0 AND M_CostElement_ID=100 AND M_CostType_ID=100 AND M_Product_ID=145
;

View File

@ -0,0 +1,155 @@
-- Jan 8, 2009 7:23:10 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=731, SeqNo=0, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=732
;
-- Jan 8, 2009 7:23:10 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=731, SeqNo=1, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=733
;
-- Jan 8, 2009 7:23:10 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=50008, SeqNo=0, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=50007
;
-- Jan 8, 2009 7:23:10 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=50008, SeqNo=1, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=50009
;
-- Jan 8, 2009 7:23:10 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=50008, SeqNo=2, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=50014
;
-- Jan 8, 2009 7:23:23 PM ECT
-- Standard Cost for Manufacturing
UPDATE C_ElementValue SET Value='83300',Updated=TO_TIMESTAMP('2009-01-08 19:23:23','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_ElementValue_ID=50014
;
-- Jan 8, 2009 7:23:23 PM ECT
-- Standard Cost for Manufacturing
UPDATE C_ValidCombination SET Combination='HQ-83300-_-_-_-_', Description='HQ-Overhead (Applied)-_-_-_-_',Updated=TO_TIMESTAMP('2009-01-08 19:23:23','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_ValidCombination_ID=50011
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=0, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=430
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=1, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=50010
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=2, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=50016
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=3, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=50011
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=4, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=431
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=5, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=781
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=6, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=780
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=7, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=778
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=8, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=432
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=9, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=433
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=10, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=434
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=11, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=435
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=12, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=438
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=13, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=634
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=14, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=443
;
-- Jan 8, 2009 7:23:33 PM ECT
-- Standard Cost for Manufacturing
UPDATE AD_TreeNode SET Parent_ID=429, SeqNo=15, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=101 AND Node_ID=446
;
-- Jan 8, 2009 8:21:42 PM ECT
-- Manufacturing Cost
UPDATE PP_Product_BOMLine SET QtyBOM=1.000000000000,Updated=TO_TIMESTAMP('2009-01-08 20:21:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE PP_Product_BOMLine_ID=50002
;
-- Jan 8, 2009 8:21:45 PM ECT
-- Manufacturing Cost
UPDATE PP_Product_BOMLine SET QtyBOM=1.000000000000,Updated=TO_TIMESTAMP('2009-01-08 20:21:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE PP_Product_BOMLine_ID=50003
;
-- Jan 8, 2009 8:22:37 PM ECT
-- Manufacturing Cost
UPDATE M_Cost SET CurrentCostPriceLL=13.39000000000000000000,Updated=TO_TIMESTAMP('2009-01-08 20:22:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Org_ID=0 AND C_AcctSchema_ID=101 AND M_AttributeSetInstance_ID=0 AND M_CostElement_ID=100 AND M_CostType_ID=100 AND M_Product_ID=133
;
-- Jan 8, 2009 8:22:38 PM ECT
-- Manufacturing Cost
UPDATE M_Cost SET CurrentCostPriceLL=53.560000000000000000000000,Updated=TO_TIMESTAMP('2009-01-08 20:22:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Org_ID=0 AND C_AcctSchema_ID=101 AND M_AttributeSetInstance_ID=0 AND M_CostElement_ID=100 AND M_CostType_ID=100 AND M_Product_ID=145
;
-- Jan 8, 2009 8:26:03 PM ECT
-- Manufacturing Cost
UPDATE M_Cost SET CurrentCostPrice=54.000000000000,Updated=TO_TIMESTAMP('2009-01-08 20:26:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Org_ID=0 AND C_AcctSchema_ID=101 AND M_AttributeSetInstance_ID=0 AND M_CostElement_ID=100 AND M_CostType_ID=100 AND M_Product_ID=134
;
-- Jan 8, 2009 8:26:19 PM ECT
-- Manufacturing Cost
UPDATE M_ProductPrice SET PriceList=60.000000000000,Updated=TO_TIMESTAMP('2009-01-08 20:26:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE M_PriceList_Version_ID=103 AND M_Product_ID=134
;
-- Jan 8, 2009 8:28:06 PM ECT
-- Manufacturing Cost
UPDATE M_Cost SET CurrentCostPrice=18.000000000000,Updated=TO_TIMESTAMP('2009-01-08 20:28:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Org_ID=0 AND C_AcctSchema_ID=101 AND M_AttributeSetInstance_ID=0 AND M_CostElement_ID=100 AND M_CostType_ID=100 AND M_Product_ID=135
;
-- Jan 8, 2009 8:30:12 PM ECT
-- Manufacturing Cost
UPDATE M_Cost SET CurrentCostPriceLL=125.560000000000000000000000,Updated=TO_TIMESTAMP('2009-01-08 20:30:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Org_ID=0 AND C_AcctSchema_ID=101 AND M_AttributeSetInstance_ID=0 AND M_CostElement_ID=100 AND M_CostType_ID=100 AND M_Product_ID=145
;