From 690ccb9fd101b432947f7d00c6c1c6668436ea35 Mon Sep 17 00:00:00 2001 From: teo_sarca Date: Thu, 11 Dec 2008 22:06:03 +0000 Subject: [PATCH] Cost Collector related : improved functionality Victor, please review --- .../model/CalloutCostCollector.java | 36 +++++++++++++++---- .../eevolution/model/MPPCostCollector.java | 6 ++-- .../org/eevolution/model/MPPOrderNode.java | 1 + .../eevolution/model/MPPOrderWorkflow.java | 2 +- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/base/src/org/eevolution/model/CalloutCostCollector.java b/base/src/org/eevolution/model/CalloutCostCollector.java index 6dab11bef4..12d4f79d67 100644 --- a/base/src/org/eevolution/model/CalloutCostCollector.java +++ b/base/src/org/eevolution/model/CalloutCostCollector.java @@ -16,6 +16,7 @@ *****************************************************************************/ package org.eevolution.model; +import java.math.BigDecimal; import java.util.Properties; import org.compiere.model.CalloutEngine; @@ -37,11 +38,12 @@ public class CalloutCostCollector extends CalloutEngine return ""; // MPPOrder order = new MPPOrder(ctx, PP_Order_ID, null); + mTab.setValue(MPPCostCollector.COLUMNNAME_C_DocTypeTarget_ID, order.getC_DocType_ID()); mTab.setValue(MPPCostCollector.COLUMNNAME_S_Resource_ID, order.getS_Resource_ID()); mTab.setValue(MPPCostCollector.COLUMNNAME_M_Product_ID, order.getM_Product_ID()); mTab.setValue(MPPCostCollector.COLUMNNAME_M_AttributeSetInstance_ID, order.getM_AttributeSetInstance_ID()); mTab.setValue(MPPCostCollector.COLUMNNAME_M_Warehouse_ID, order.getM_Warehouse_ID()); - mTab.setValue(MPPCostCollector.COLUMNNAME_MovementQty, order.getQtyEntered()); + mTab.setValue(MPPCostCollector.COLUMNNAME_MovementQty, order.getQtyOrdered()); // MPPOrderWorkflow owf = order.getMPPOrderWorkflow(); mTab.setValue(MPPCostCollector.COLUMNNAME_PP_Order_Workflow_ID, owf.getPP_Order_Workflow_ID()); @@ -52,21 +54,41 @@ public class CalloutCostCollector extends CalloutEngine public String node (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) { - /* Integer PP_Order_Node_ID = (Integer)value; - // if (PP_Order_Node_ID == null || PP_Order_Node_ID <= 0) return ""; - MPPOrderNode ordernode = new MPPOrderNode(ctx, PP_Order_Node_ID, null); - mTab.setValue(MPPCostCollector.COLUMNNAME_IsSubcontracting, ordernode.isSubcontracting() ? "Y" : "N"); - */ + // + MPPOrderNode node = getPP_Order_Node(ctx, PP_Order_Node_ID); + mTab.setValue(MPPCostCollector.COLUMNNAME_S_Resource_ID, node.getS_Resource_ID()); + + BigDecimal qtyToDeliver = node.getQtyRequiered() + .subtract(node.getQtyDelivered()) + .subtract(node.getQtyScrap()) + .subtract(node.getQtyReject()); + mTab.setValue(MPPCostCollector.COLUMNNAME_MovementQty, qtyToDeliver); + // + int duration = node.getDuration(); + BigDecimal durationReal = qtyToDeliver.multiply(BigDecimal.valueOf(duration)); + mTab.setValue(MPPCostCollector.COLUMNNAME_DurationReal, durationReal); + return ""; } public String MovementType (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) { return ""; - } + } + + private MPPOrderNode m_node = null; + private MPPOrderNode getPP_Order_Node(Properties ctx, int PP_Order_Node_ID) + { + if (m_node != null && m_node.get_ID() == PP_Order_Node_ID) + { + return m_node; + } + m_node = new MPPOrderNode(ctx, PP_Order_Node_ID, null); + return m_node; + } } diff --git a/base/src/org/eevolution/model/MPPCostCollector.java b/base/src/org/eevolution/model/MPPCostCollector.java index e25e13670a..fdc8844606 100644 --- a/base/src/org/eevolution/model/MPPCostCollector.java +++ b/base/src/org/eevolution/model/MPPCostCollector.java @@ -151,7 +151,9 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction return DocAction.STATUS_Invalid; } - MPeriod.testPeriodOpen(getCtx(), getMovementDate(), getC_DocType_ID()); + MPeriod.testPeriodOpen(getCtx(), getMovementDate(), getC_DocTypeTarget_ID()); + // Convert/Check DocType + setC_DocType_ID(getC_DocTypeTarget_ID()); m_justPrepared = true; if (!DOCACTION_Complete.equals(getDocAction())) @@ -532,7 +534,7 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction .match(); if (!exists) { - MPPCostCollector costnew = new MPPCostCollector(Env.getCtx(), 0, get_TrxName()); + MPPCostCollector costnew = new MPPCostCollector(getCtx(), 0, get_TrxName()); costnew.setPP_Order_ID(getPP_Order_ID()); costnew.setC_DocTypeTarget_ID(getC_DocTypeTarget_ID()); costnew.setC_DocType_ID(getC_DocType_ID()); diff --git a/base/src/org/eevolution/model/MPPOrderNode.java b/base/src/org/eevolution/model/MPPOrderNode.java index d1e33489c1..6cd172b716 100644 --- a/base/src/org/eevolution/model/MPPOrderNode.java +++ b/base/src/org/eevolution/model/MPPOrderNode.java @@ -209,6 +209,7 @@ public class MPPOrderNode extends X_PP_Order_Node public void setQtyOrdered(BigDecimal qtyOrdered) { + setQtyRequiered(qtyOrdered); BigDecimal time = new BigDecimal(getDuration()).multiply(qtyOrdered); setDurationRequiered(time.intValue()); } diff --git a/base/src/org/eevolution/model/MPPOrderWorkflow.java b/base/src/org/eevolution/model/MPPOrderWorkflow.java index 4dda62e882..759e94176a 100644 --- a/base/src/org/eevolution/model/MPPOrderWorkflow.java +++ b/base/src/org/eevolution/model/MPPOrderWorkflow.java @@ -59,7 +59,7 @@ public class MPPOrderWorkflow extends X_PP_Order_Workflow } // get /** Single Cache */ - private static CCache s_cache = new CCache("PP_Order_Workflow", 20); + private static CCache s_cache = new CCache(Table_Name, 20); /************************************************************************** * Create/Load Workflow