Cost Collector related : improved functionality

Victor, please review
This commit is contained in:
teo_sarca 2008-12-11 22:06:03 +00:00
parent 60a7ad7de6
commit 690ccb9fd1
4 changed files with 35 additions and 10 deletions

View File

@ -16,6 +16,7 @@
*****************************************************************************/ *****************************************************************************/
package org.eevolution.model; package org.eevolution.model;
import java.math.BigDecimal;
import java.util.Properties; import java.util.Properties;
import org.compiere.model.CalloutEngine; import org.compiere.model.CalloutEngine;
@ -37,11 +38,12 @@ public class CalloutCostCollector extends CalloutEngine
return ""; return "";
// //
MPPOrder order = new MPPOrder(ctx, PP_Order_ID, null); 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_S_Resource_ID, order.getS_Resource_ID());
mTab.setValue(MPPCostCollector.COLUMNNAME_M_Product_ID, order.getM_Product_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_AttributeSetInstance_ID, order.getM_AttributeSetInstance_ID());
mTab.setValue(MPPCostCollector.COLUMNNAME_M_Warehouse_ID, order.getM_Warehouse_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(); MPPOrderWorkflow owf = order.getMPPOrderWorkflow();
mTab.setValue(MPPCostCollector.COLUMNNAME_PP_Order_Workflow_ID, owf.getPP_Order_Workflow_ID()); mTab.setValue(MPPCostCollector.COLUMNNAME_PP_Order_Workflow_ID, owf.getPP_Order_Workflow_ID());
@ -52,14 +54,23 @@ public class CalloutCostCollector extends CalloutEngine
public String node (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) public String node (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{ {
/*
Integer PP_Order_Node_ID = (Integer)value; Integer PP_Order_Node_ID = (Integer)value;
//
if (PP_Order_Node_ID == null || PP_Order_Node_ID <= 0) if (PP_Order_Node_ID == null || PP_Order_Node_ID <= 0)
return ""; 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 ""; return "";
} }
@ -67,6 +78,17 @@ public class CalloutCostCollector extends CalloutEngine
{ {
return ""; 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;
}
} }

View File

@ -151,7 +151,9 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
return DocAction.STATUS_Invalid; 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; m_justPrepared = true;
if (!DOCACTION_Complete.equals(getDocAction())) if (!DOCACTION_Complete.equals(getDocAction()))
@ -532,7 +534,7 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
.match(); .match();
if (!exists) 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.setPP_Order_ID(getPP_Order_ID());
costnew.setC_DocTypeTarget_ID(getC_DocTypeTarget_ID()); costnew.setC_DocTypeTarget_ID(getC_DocTypeTarget_ID());
costnew.setC_DocType_ID(getC_DocType_ID()); costnew.setC_DocType_ID(getC_DocType_ID());

View File

@ -209,6 +209,7 @@ public class MPPOrderNode extends X_PP_Order_Node
public void setQtyOrdered(BigDecimal qtyOrdered) public void setQtyOrdered(BigDecimal qtyOrdered)
{ {
setQtyRequiered(qtyOrdered);
BigDecimal time = new BigDecimal(getDuration()).multiply(qtyOrdered); BigDecimal time = new BigDecimal(getDuration()).multiply(qtyOrdered);
setDurationRequiered(time.intValue()); setDurationRequiered(time.intValue());
} }

View File

@ -59,7 +59,7 @@ public class MPPOrderWorkflow extends X_PP_Order_Workflow
} // get } // get
/** Single Cache */ /** Single Cache */
private static CCache<Integer,MPPOrderWorkflow> s_cache = new CCache<Integer,MPPOrderWorkflow>("PP_Order_Workflow", 20); private static CCache<Integer,MPPOrderWorkflow> s_cache = new CCache<Integer,MPPOrderWorkflow>(Table_Name, 20);
/************************************************************************** /**************************************************************************
* Create/Load Workflow * Create/Load Workflow