Fix issue with Make to Kit
Refactor static method to right class complete functionality for close the milestone activities or the Manufacturing Order close
This commit is contained in:
parent
56fe52c525
commit
87c1fd51bf
|
@ -182,10 +182,11 @@ public class LiberoValidator implements ModelValidator
|
|||
if(inout.isSOTrx())
|
||||
{
|
||||
final String whereClause = "C_OrderLine_ID IS NOT NULL"
|
||||
+" AND EXISTS (SELECT 1 FROM C_OrderLine ol , M_InOutLine iol"
|
||||
+" WHERE ol.C_OrderLine_ID=iol.C_OrderLine_ID AND iol.M_InOut_ID=? )";
|
||||
+" AND EXISTS (SELECT 1 FROM M_InOutLine iol"
|
||||
+" WHERE iol.M_InOut_ID=? AND PP_Order.C_OrderLine_ID = iol.C_OrderLine_ID) AND "
|
||||
+ MPPOrder.COLUMNNAME_DocStatus + " = ?";
|
||||
Collection<MPPOrder> orders = new Query(po.getCtx(), MPPOrder.Table_Name, whereClause, po.get_TrxName())
|
||||
.setParameters(new Object[]{inout.getM_InOut_ID()})
|
||||
.setParameters(new Object[]{inout.getM_InOut_ID(), MPPOrder.DOCSTATUS_InProgress})
|
||||
.list();
|
||||
for(MPPOrder order : orders)
|
||||
{
|
||||
|
@ -199,6 +200,7 @@ public class LiberoValidator implements ModelValidator
|
|||
order.setDocStatus(MPPOrder.DOCACTION_Close);
|
||||
order.setDocAction(MPPOrder.DOCACTION_None);
|
||||
order.saveEx();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,6 +70,88 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
|||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Create & Complete Cost Collector
|
||||
* @param pp_order
|
||||
* @param M_Product_ID
|
||||
* @param M_Locator_ID
|
||||
* @param M_AttributeSetInstance_ID
|
||||
* @param S_Resource_ID
|
||||
* @param PP_Order_BOMLine_ID
|
||||
* @param PP_Order_Node_ID
|
||||
* @param C_DocType_ID
|
||||
* @param CostCollectorType
|
||||
* @param movementdate
|
||||
* @param qty
|
||||
* @param scrap
|
||||
* @param reject
|
||||
* @param durationSetup
|
||||
* @param duration
|
||||
* @param trxName
|
||||
* @return completed cost collector
|
||||
*/
|
||||
public static MPPCostCollector createCollector (MPPOrder pp_order,
|
||||
int M_Product_ID,
|
||||
int M_Locator_ID,
|
||||
int M_AttributeSetInstance_ID,
|
||||
int S_Resource_ID,
|
||||
int PP_Order_BOMLine_ID,
|
||||
int PP_Order_Node_ID,
|
||||
int C_DocType_ID,
|
||||
String CostCollectorType,
|
||||
Timestamp movementdate,
|
||||
BigDecimal qty,
|
||||
BigDecimal scrap,
|
||||
BigDecimal reject,
|
||||
int durationSetup,
|
||||
int duration,
|
||||
String trxName
|
||||
)
|
||||
{
|
||||
MPPCostCollector cc = new MPPCostCollector(pp_order.getCtx(), 0, trxName);
|
||||
cc.setPP_Order_ID(pp_order.getPP_Order_ID());
|
||||
cc.setPP_Order_BOMLine_ID(PP_Order_BOMLine_ID);
|
||||
cc.setPP_Order_Workflow_ID(pp_order.getMPPOrderWorkflow().getPP_Order_Workflow_ID());
|
||||
cc.setPP_Order_Node_ID(PP_Order_Node_ID);
|
||||
cc.setAD_OrgTrx_ID(pp_order.getAD_OrgTrx_ID());
|
||||
cc.setC_Activity_ID(pp_order.getC_Activity_ID());
|
||||
cc.setC_Campaign_ID(pp_order.getC_Campaign_ID());
|
||||
cc.setC_DocType_ID(C_DocType_ID);
|
||||
cc.setC_DocTypeTarget_ID(C_DocType_ID);
|
||||
cc.setCostCollectorType(CostCollectorType);
|
||||
cc.setC_Project_ID(pp_order.getC_Project_ID());
|
||||
cc.setDescription(pp_order.getDescription());
|
||||
cc.setDocAction(MPPCostCollector.ACTION_Complete);
|
||||
cc.setDocStatus(MPPCostCollector.DOCSTATUS_Drafted);
|
||||
cc.setIsActive(true);
|
||||
cc.setM_Warehouse_ID(pp_order.getM_Warehouse_ID());
|
||||
cc.setM_Locator_ID(M_Locator_ID);
|
||||
cc.setM_AttributeSetInstance_ID(M_AttributeSetInstance_ID);
|
||||
cc.setS_Resource_ID(S_Resource_ID);
|
||||
cc.setMovementDate(movementdate);
|
||||
cc.setDateAcct(movementdate);
|
||||
cc.setMovementQty(qty);
|
||||
cc.setScrappedQty(scrap);
|
||||
cc.setQtyReject(reject);
|
||||
cc.setSetupTimeReal(new BigDecimal(durationSetup));
|
||||
cc.setDurationReal(new BigDecimal(duration));
|
||||
cc.setPosted(false);
|
||||
cc.setProcessed(false);
|
||||
cc.setProcessing(false);
|
||||
cc.setUser1_ID(pp_order.getUser1_ID());
|
||||
cc.setUser2_ID(pp_order.getUser2_ID());
|
||||
cc.setM_Product_ID(M_Product_ID);
|
||||
cc.saveEx();
|
||||
if (!cc.processIt(MPPCostCollector.DOCACTION_Complete))
|
||||
{
|
||||
throw new AdempiereException(cc.getProcessMsg());
|
||||
}
|
||||
cc.saveEx();
|
||||
return cc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Standard Constructor
|
||||
* @param ctx context
|
||||
|
@ -230,20 +312,11 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
|||
activity.setSetupTimeReal(activity.getSetupTimeReal()+getSetupTimeReal().intValue());
|
||||
activity.saveEx();
|
||||
|
||||
if (MPPOrderNode.isLastNode(getCtx(), getPP_Order_Node_ID(), get_TrxName()))
|
||||
// report all activity previews to milestone activity
|
||||
if(activity.isMilestone())
|
||||
{
|
||||
final String whereClause ="PP_Order_ID=? AND PP_Order_Node_ID<>?"
|
||||
+" AND NOT EXISTS (SELECT 1 FROM PP_Cost_Collector cc "
|
||||
+" WHERE cc.PP_Order_ID=PP_Order_Node.PP_Order_ID"
|
||||
+" AND cc.PP_Order_Node_ID=PP_Order_Node.PP_Order_Node_ID)";
|
||||
List<MPPOrderNode> nodes = new Query(getCtx(), MPPOrderNode.Table_Name, whereClause, get_TrxName())
|
||||
.setParameters(new Object[]{getPP_Order_ID(),getPP_Order_Node_ID()})
|
||||
.setOnlyActiveRecords(true)
|
||||
.list();
|
||||
for (MPPOrderNode node : nodes)
|
||||
{
|
||||
createNewNode(node);
|
||||
}
|
||||
MPPOrderWorkflow order_workflow = activity.getMPPOrderWorkflow();
|
||||
order_workflow.closeActivities(activity, getMovementDate(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -447,9 +520,10 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
|||
return DocStatus;
|
||||
}
|
||||
setProcessed(true);
|
||||
setDocAction(DOCACTION_Close);
|
||||
setDocStatus(DOCSTATUS_Completed);
|
||||
activity.setDocStatus(DOCSTATUS_Completed);
|
||||
setDocAction(MPPOrderNode.DOCACTION_Close);
|
||||
setDocStatus(MPPOrderNode.DOCSTATUS_Completed);
|
||||
activity.setDocStatus(MPPOrderNode.DOCSTATUS_Completed);
|
||||
activity.setAction(MPPOrderNode.DOCACTION_None);
|
||||
activity.saveEx();
|
||||
m_processMsg = Msg.translate(getCtx(), "PP_Order_ID")
|
||||
+":"+ getPP_Order().getDocumentNo()
|
||||
|
@ -461,7 +535,8 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
|||
{
|
||||
if(activity.getQtyDelivered().compareTo(activity.getQtyRequiered()) >= 0)
|
||||
{
|
||||
activity.setDocStatus(DOCSTATUS_Completed);
|
||||
activity.setDocStatus(MPPOrderNode.DOCSTATUS_Completed);
|
||||
activity.setAction(MPPOrderNode.DOCACTION_None);
|
||||
activity.saveEx();
|
||||
}
|
||||
}
|
||||
|
@ -484,45 +559,6 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
|||
public boolean closeIt()
|
||||
{
|
||||
log.info("closeIt - " + toString());
|
||||
|
||||
// Close Not delivered Qty
|
||||
// fjviejo e-evolution operation activity
|
||||
// last node translates to => I complete node
|
||||
if(!MPPOrderNode.isLastNode(getCtx(), getPP_Order_Node_ID(), get_TrxName()))
|
||||
{
|
||||
MPPOrderNode onodeact = new MPPOrderNode(Env.getCtx(),getPP_Order_Node_ID(),get_TrxName());
|
||||
onodeact.setDocStatus(DOCSTATUS_Closed);
|
||||
// onodeact.setAction(DOCACTION_None);
|
||||
onodeact.saveEx();
|
||||
|
||||
final String whereClause = COLUMNNAME_PP_Order_ID+"=? AND "+COLUMNNAME_PP_Order_Node_ID+"=?";
|
||||
List<MPPCostCollector> list = new Query(getCtx(), Table_Name, whereClause, get_TrxName())
|
||||
.setOnlyActiveRecords(true)
|
||||
.setParameters(new Object[]{getPP_Order_ID(), getPP_Order_Node_ID()})
|
||||
.list();
|
||||
for (MPPCostCollector cc : list)
|
||||
{
|
||||
cc.setDocStatus(DOCSTATUS_Closed);
|
||||
cc.setDocAction(DOCACTION_None);
|
||||
cc.saveEx();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final String whereClause = MPPOrderNode.COLUMNNAME_PP_Order_ID+"=?"
|
||||
+" AND ("+MPPOrderNode.COLUMNNAME_DocStatus+" IS NULL OR "+MPPOrderNode.COLUMNNAME_DocStatus+"<>?)";
|
||||
List<MPPOrderNode> list = new Query(getCtx(), MPPOrderNode.Table_Name, whereClause, get_TrxName())
|
||||
.setOnlyActiveRecords(true)
|
||||
.setParameters(new Object[]{getPP_Order_ID(), MPPOrderNode.DOCSTATUS_Closed})
|
||||
.list();
|
||||
for (MPPOrderNode onode : list)
|
||||
{
|
||||
onode.setDocStatus(DOCSTATUS_Closed);
|
||||
onode.saveEx();
|
||||
}
|
||||
closeNew(getPP_Order_ID(), getPP_Order_Node_ID());
|
||||
}
|
||||
// fjviejo e-evolution operation activity end
|
||||
setDocAction(DOCACTION_None);
|
||||
return true;
|
||||
} // closeIt
|
||||
|
@ -612,43 +648,6 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
|||
return dt.getName() + " " + getDocumentNo();
|
||||
} // getDocumentInfo
|
||||
|
||||
private void createNewNode(MPPOrderNode node)
|
||||
{
|
||||
String whereClause = COLUMNNAME_PP_Order_ID+"=? AND "+COLUMNNAME_PP_Order_Node_ID+"=?";
|
||||
boolean exists = new Query(getCtx(), Table_Name, whereClause, get_TrxName())
|
||||
.setOnlyActiveRecords(true)
|
||||
.setParameters(new Object[]{getPP_Order_ID(), node.getPP_Order_Node_ID()})
|
||||
.match();
|
||||
if (!exists)
|
||||
{
|
||||
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());
|
||||
costnew.setS_Resource_ID(getS_Resource_ID());
|
||||
costnew.setM_Warehouse_ID(getM_Warehouse_ID());
|
||||
costnew.setM_Locator_ID(getM_Locator_ID());
|
||||
costnew.setM_Product_ID(getM_Product_ID());
|
||||
costnew.setM_AttributeSetInstance_ID(getM_AttributeSetInstance_ID());
|
||||
costnew.setPP_Order_Workflow_ID(getPP_Order_Workflow_ID());
|
||||
costnew.setAD_User_ID(getAD_User_ID());
|
||||
costnew.setMovementDate(getMovementDate());
|
||||
costnew.setDateAcct(getDateAcct());
|
||||
costnew.setMovementQty(getMovementQty());
|
||||
//costnew.setDurationUnit(getDurationUnit());
|
||||
costnew.setCostCollectorType(getCostCollectorType());
|
||||
costnew.setPP_Order_Node_ID(node.getPP_Order_Node_ID());
|
||||
costnew.setDurationReal(new BigDecimal(node.getDuration()));
|
||||
costnew.saveEx();
|
||||
// costnew.completeIt();
|
||||
}
|
||||
else
|
||||
{
|
||||
log.warning("***** NODE already exists");
|
||||
}
|
||||
//completenew(getPP_Order_ID(),node);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean beforeSave(boolean newRecord)
|
||||
{
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.math.RoundingMode;
|
|||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
|
@ -50,7 +51,6 @@ import org.compiere.process.DocumentEngine;
|
|||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.wf.MWFNode;
|
||||
import org.compiere.wf.MWFNodeNext;
|
||||
import org.compiere.wf.MWorkflow;
|
||||
|
@ -659,12 +659,13 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
|||
MPPOrder.createReceipt(
|
||||
this,
|
||||
today ,
|
||||
this.getQtyDelivered(),
|
||||
this.getQtyOpen(),
|
||||
this.getQtyScrap(),
|
||||
this.getQtyReject(),
|
||||
this.getM_Locator_ID(),
|
||||
this.getM_AttributeSetInstance_ID(), false, get_TrxName());
|
||||
getQtyDelivered(),
|
||||
getQtyOpen(),
|
||||
getQtyScrap(),
|
||||
getQtyReject(),
|
||||
getM_Locator_ID(),
|
||||
getM_AttributeSetInstance_ID(), false, get_TrxName());
|
||||
setQtyDelivered(getQtyOpen());
|
||||
return DOCSTATUS_Closed;
|
||||
}
|
||||
|
||||
|
@ -713,19 +714,28 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
|||
public boolean closeIt()
|
||||
{
|
||||
log.info(toString());
|
||||
// Before Close
|
||||
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_CLOSE);
|
||||
if (m_processMsg != null)
|
||||
return false;
|
||||
|
||||
if(MPPOrder.DOCSTATUS_Closed.equals(getDocStatus()))
|
||||
return true;
|
||||
|
||||
if(!MPPOrder.DOCSTATUS_Completed.equals(this.getDocStatus()))
|
||||
if(!MPPOrder.DOCSTATUS_Completed.equals(getDocStatus()))
|
||||
{
|
||||
String DocStatus = completeIt();
|
||||
setDocStatus(DocStatus);
|
||||
setDocAction(MPPOrder.ACTION_None);
|
||||
}
|
||||
// Before Close
|
||||
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_CLOSE);
|
||||
if (m_processMsg != null)
|
||||
return false;
|
||||
|
||||
BigDecimal qtyReported = getQtyDelivered().add(getQtyReject().add(getQtyScrap()));
|
||||
if(qtyReported.signum() > 0)
|
||||
{
|
||||
//Close all the activity do not reported
|
||||
MPPOrderWorkflow m_order_wf = getMPPOrderWorkflow();
|
||||
m_order_wf.closeActivities(m_order_wf.getLastNode(getAD_Client_ID()), getUpdated(),false);
|
||||
}
|
||||
|
||||
orderStock(); // Clear Ordered Quantities
|
||||
reserveStock(getLines()); // Clear Reservations
|
||||
|
@ -1007,7 +1017,7 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
|||
|
||||
/**
|
||||
* Create Receipt Finish Good
|
||||
* @param pp_order
|
||||
* @param order
|
||||
* @param movementDate
|
||||
* @param qtyDelivered
|
||||
* @param qtyToDeliver
|
||||
|
@ -1018,7 +1028,7 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
|||
* @param IsCloseDocument
|
||||
* @param trxName
|
||||
*/
|
||||
static public void createReceipt(MPPOrder pp_order,
|
||||
static public void createReceipt(MPPOrder order,
|
||||
Timestamp movementDate,
|
||||
BigDecimal qtyDelivered,
|
||||
BigDecimal qtyToDeliver,
|
||||
|
@ -1032,28 +1042,33 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
|||
|
||||
if (qtyToDeliver.signum() != 0 || qtyScrap.signum() != 0 || qtyReject.signum() != 0)
|
||||
{
|
||||
createCollector(pp_order, pp_order.getM_Product_ID(),
|
||||
M_Locator_ID,
|
||||
M_AttributeSetInstance_ID,
|
||||
movementDate,
|
||||
qtyToDeliver, qtyScrap, qtyReject,
|
||||
MDocType.getDocType(MDocType.DOCBASETYPE_ManufacturingOrder),
|
||||
0, // PP_Order_BOMLine_ID
|
||||
MPPCostCollector.COSTCOLLECTORTYPE_MaterialReceipt,
|
||||
MPPCostCollector.createCollector(
|
||||
order, //MPPOrder
|
||||
order.getM_Product_ID(), //M_Product_ID
|
||||
M_Locator_ID, //M_Locator_ID
|
||||
M_AttributeSetInstance_ID, //M_AttributeSetInstance_ID
|
||||
order.getS_Resource_ID(), //S_Resource_ID
|
||||
0, //PP_Order_BOMLine_ID
|
||||
0, //PP_Order_Node_ID
|
||||
MDocType.getDocType(MDocType.DOCBASETYPE_ManufacturingOrder), //C_DocType_ID
|
||||
MPPCostCollector.COSTCOLLECTORTYPE_MaterialReceipt, //Production "+"
|
||||
movementDate, //MovementDate
|
||||
qtyToDeliver, qtyScrap, qtyReject, //qty,scrap,reject
|
||||
0,0,
|
||||
trxName);
|
||||
}
|
||||
|
||||
if (IsCloseDocument)
|
||||
{
|
||||
pp_order.setDateFinish(movementDate);
|
||||
pp_order.closeIt();
|
||||
pp_order.saveEx();
|
||||
order.setDateFinish(movementDate);
|
||||
order.closeIt();
|
||||
order.saveEx();
|
||||
}
|
||||
|
||||
pp_order.setDateDelivered(movementDate);
|
||||
if (pp_order.getDateStart() == null)
|
||||
order.setDateDelivered(movementDate);
|
||||
if (order.getDateStart() == null)
|
||||
{
|
||||
pp_order.setDateStart(movementDate);
|
||||
order.setDateStart(movementDate);
|
||||
}
|
||||
|
||||
BigDecimal DQ = qtyDelivered;
|
||||
|
@ -1061,10 +1076,10 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
|||
BigDecimal OQ = qtyToDeliver;
|
||||
if (DQ.add(SQ).compareTo(OQ) >= 0)
|
||||
{
|
||||
pp_order.setDateFinish(movementDate);
|
||||
order.setDateFinish(movementDate);
|
||||
}
|
||||
|
||||
pp_order.saveEx(trxName);
|
||||
order.saveEx(trxName);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1077,7 +1092,7 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
|||
* @param qtyReject
|
||||
* @param storages
|
||||
*/
|
||||
public static void createIssue(MPPOrder pp_order, int PP_OrderBOMLine_ID,
|
||||
public static void createIssue(MPPOrder order, int PP_OrderBOMLine_ID,
|
||||
Timestamp movementdate,
|
||||
BigDecimal qty, BigDecimal qtyScrap, BigDecimal qtyReject,
|
||||
MStorage[] storages,
|
||||
|
@ -1096,7 +1111,7 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
|||
|
||||
BigDecimal qtyIssue = toIssue.min(storage.getQtyOnHand());
|
||||
//log.fine("ToIssue: " + issue);
|
||||
MPPOrderBOMLine PP_orderbomLine = new MPPOrderBOMLine(pp_order.getCtx(), PP_OrderBOMLine_ID, trxName);
|
||||
MPPOrderBOMLine PP_orderbomLine = new MPPOrderBOMLine(order.getCtx(), PP_OrderBOMLine_ID, trxName);
|
||||
//create record for negative and positive transaction
|
||||
if (qtyIssue.signum() != 0 || qtyScrap.signum() != 0 || qtyReject.signum() != 0)
|
||||
{
|
||||
|
@ -1108,16 +1123,20 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
|||
CostCollectorType = MPPCostCollector.COSTCOLLECTORTYPE_MethodChangeVariance;
|
||||
}
|
||||
//
|
||||
createCollector (pp_order,
|
||||
PP_orderbomLine.getM_Product_ID(),
|
||||
storage.getM_Locator_ID(),
|
||||
storage.getM_AttributeSetInstance_ID(),
|
||||
movementdate,
|
||||
qtyIssue, qtyScrap, qtyReject,
|
||||
MDocType.getDocType(MDocType.DOCBASETYPE_ManufacturingOrder),
|
||||
PP_OrderBOMLine_ID,
|
||||
CostCollectorType, // Production "-"
|
||||
trxName
|
||||
MPPCostCollector.createCollector (
|
||||
order, //MPPOrder
|
||||
PP_orderbomLine.getM_Product_ID(), //M_Product_ID
|
||||
storage.getM_Locator_ID(), //M_Locator_ID
|
||||
storage.getM_AttributeSetInstance_ID(), //M_AttributeSetInstance_ID
|
||||
order.getS_Resource_ID(), //S_Resource_ID
|
||||
PP_OrderBOMLine_ID, //PP_Order_BOMLine_ID
|
||||
0, //PP_Order_Node_ID
|
||||
MDocType.getDocType(MDocType.DOCBASETYPE_ManufacturingOrder), //C_DocType_ID,
|
||||
CostCollectorType, //Production "-"
|
||||
movementdate, //MovementDate
|
||||
qtyIssue, qtyScrap, qtyReject, //qty,scrap,reject
|
||||
0,0, //durationSetup,duration
|
||||
trxName //trxName
|
||||
);
|
||||
|
||||
}
|
||||
|
@ -1134,74 +1153,6 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create & Complete Cost Collector
|
||||
* @param pp_order
|
||||
* @param M_Product_ID
|
||||
* @param M_Locator_ID
|
||||
* @param M_AttributeSetInstance_ID
|
||||
* @param movementdate
|
||||
* @param qty
|
||||
* @param scrap
|
||||
* @param reject
|
||||
* @param C_DocType_ID
|
||||
* @param PP_Order_BOMLine_ID
|
||||
* @param CostCollectorType
|
||||
* @param trxName
|
||||
* @return completed cost collector
|
||||
*/
|
||||
private static MPPCostCollector createCollector (MPPOrder pp_order,
|
||||
int M_Product_ID,
|
||||
int M_Locator_ID,
|
||||
int M_AttributeSetInstance_ID,
|
||||
Timestamp movementdate,
|
||||
BigDecimal qty,
|
||||
BigDecimal scrap,
|
||||
BigDecimal reject,
|
||||
int C_DocType_ID,
|
||||
int PP_Order_BOMLine_ID,
|
||||
String CostCollectorType,
|
||||
String trxName
|
||||
)
|
||||
{
|
||||
MPPCostCollector cc = new MPPCostCollector(pp_order.getCtx(), 0, trxName);
|
||||
cc.setPP_Order_ID(pp_order.getPP_Order_ID());
|
||||
cc.setPP_Order_BOMLine_ID(PP_Order_BOMLine_ID);
|
||||
cc.setAD_OrgTrx_ID(pp_order.getAD_OrgTrx_ID());
|
||||
cc.setC_Activity_ID(pp_order.getC_Activity_ID());
|
||||
cc.setC_Campaign_ID(pp_order.getC_Campaign_ID());
|
||||
cc.setC_DocType_ID(C_DocType_ID);
|
||||
cc.setC_DocTypeTarget_ID(C_DocType_ID);
|
||||
cc.setCostCollectorType(CostCollectorType);
|
||||
cc.setC_Project_ID(pp_order.getC_Project_ID());
|
||||
cc.setDescription(pp_order.getDescription());
|
||||
cc.setDocAction(MPPCostCollector.ACTION_Complete);
|
||||
cc.setDocStatus(MPPCostCollector.DOCSTATUS_Drafted);
|
||||
cc.setIsActive(true);
|
||||
cc.setM_Warehouse_ID(pp_order.getM_Warehouse_ID());
|
||||
cc.setM_Locator_ID(M_Locator_ID);
|
||||
cc.setM_AttributeSetInstance_ID(M_AttributeSetInstance_ID);
|
||||
cc.setS_Resource_ID(pp_order.getS_Resource_ID());
|
||||
cc.setMovementDate(movementdate);
|
||||
cc.setDateAcct(movementdate);
|
||||
cc.setMovementQty(qty);
|
||||
cc.setScrappedQty(scrap);
|
||||
cc.setQtyReject(reject);
|
||||
cc.setPosted(false);
|
||||
cc.setProcessed(false);
|
||||
cc.setProcessing(false);
|
||||
cc.setUser1_ID(pp_order.getUser1_ID());
|
||||
cc.setUser2_ID(pp_order.getUser2_ID());
|
||||
cc.setM_Product_ID(M_Product_ID);
|
||||
cc.saveEx();
|
||||
if (!cc.processIt(MPPCostCollector.DOCACTION_Complete))
|
||||
{
|
||||
throw new AdempiereException(cc.getProcessMsg());
|
||||
}
|
||||
cc.saveEx();
|
||||
return cc;
|
||||
}
|
||||
|
||||
public static boolean isAvailableQty(MPPOrder order, I_PP_Order_BOMLine line)
|
||||
{
|
||||
MProduct product = MProduct.get(order.getCtx(), line.getM_Product_ID());
|
||||
|
@ -1333,7 +1284,7 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
|||
/**
|
||||
* @return Default Locator for current Warehouse
|
||||
*/
|
||||
private int getM_Locator_ID()
|
||||
public int getM_Locator_ID()
|
||||
{
|
||||
MWarehouse wh = MWarehouse.get(getCtx(), getM_Warehouse_ID());
|
||||
return wh.getDefaultLocator().getM_Locator_ID();
|
||||
|
|
|
@ -74,7 +74,8 @@ public class MPPOrderNode extends X_PP_Order_Node
|
|||
|
||||
/** Cache */
|
||||
private static CCache<Integer,MPPOrderNode> s_cache = new CCache<Integer,MPPOrderNode> (Table_Name, 50);
|
||||
|
||||
/** MPPOrderWorkflow */
|
||||
MPPOrderWorkflow m_order_wf = null;
|
||||
|
||||
/**************************************************************************
|
||||
* Standard Constructor - save to cache
|
||||
|
@ -203,6 +204,8 @@ public class MPPOrderNode extends X_PP_Order_Node
|
|||
private List<MPPOrderNodeNext> m_next = new ArrayList<MPPOrderNodeNext>();
|
||||
/** Duration Base MS */
|
||||
private long m_durationBaseMS = -1;
|
||||
/** Workflow Order */
|
||||
private MPPOrder m_workflow = null;
|
||||
|
||||
/**
|
||||
* Load Next
|
||||
|
@ -271,7 +274,7 @@ public class MPPOrderNode extends X_PP_Order_Node
|
|||
if (duration == 0)
|
||||
return 0;
|
||||
if (m_durationBaseMS == -1)
|
||||
m_durationBaseMS = getPPOrderWorkflow().getDurationBaseSec() * 1000;
|
||||
m_durationBaseMS = getMPPOrderWorkflow().getDurationBaseSec() * 1000;
|
||||
return duration * m_durationBaseMS;
|
||||
} // getDurationMS
|
||||
|
||||
|
@ -285,7 +288,7 @@ public class MPPOrderNode extends X_PP_Order_Node
|
|||
if (limit == 0)
|
||||
return 0;
|
||||
if (m_durationBaseMS == -1)
|
||||
m_durationBaseMS = getPPOrderWorkflow().getDurationBaseSec() * 1000;
|
||||
m_durationBaseMS = getMPPOrderWorkflow().getDurationBaseSec() * 1000;
|
||||
return limit * m_durationBaseMS;
|
||||
} // getLimitMS
|
||||
|
||||
|
@ -295,18 +298,9 @@ public class MPPOrderNode extends X_PP_Order_Node
|
|||
*/
|
||||
public int getDurationCalendarField()
|
||||
{
|
||||
return getPPOrderWorkflow().getDurationCalendarField();
|
||||
return getMPPOrderWorkflow().getDurationCalendarField();
|
||||
} // getDurationCalendarField
|
||||
|
||||
/**
|
||||
* Get Workflow (NoTrx)
|
||||
* @return workflow
|
||||
*/
|
||||
public MPPOrderWorkflow getPPOrderWorkflow()
|
||||
{
|
||||
return MPPOrderWorkflow.get(getCtx(), getPP_Order_Workflow_ID());
|
||||
} // getWorkflow
|
||||
|
||||
/**
|
||||
* String Representation
|
||||
* @return info
|
||||
|
@ -335,7 +329,7 @@ public class MPPOrderNode extends X_PP_Order_Node
|
|||
{
|
||||
MResource resource = (MResource) getS_Resource();
|
||||
//get the rate for this cost type element (Rsource, Burden)
|
||||
MPPOrderWorkflow workflow = getPPOrderWorkflow();
|
||||
MPPOrderWorkflow workflow = getMPPOrderWorkflow();
|
||||
double rate = resource.getResouceRate(C_AcctSchema_ID, M_CostType_ID,CostElementType, AD_Org_ID);
|
||||
BigDecimal cost = Env.ZERO;
|
||||
if (rate == 0)
|
||||
|
@ -359,4 +353,15 @@ public class MPPOrderNode extends X_PP_Order_Node
|
|||
}
|
||||
return cost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Parent
|
||||
* @return MPPOrderWorkflow
|
||||
*/
|
||||
public MPPOrderWorkflow getMPPOrderWorkflow()
|
||||
{
|
||||
if (m_order_wf == null)
|
||||
m_order_wf = new MPPOrderWorkflow(getCtx(), getPP_Order_Workflow_ID(), get_TrxName());
|
||||
return m_order_wf;
|
||||
} // getParent
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.eevolution.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
@ -24,6 +25,8 @@ import java.util.Properties;
|
|||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MClient;
|
||||
import org.compiere.model.MDocType;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.Env;
|
||||
|
@ -149,6 +152,8 @@ public class MPPOrderWorkflow extends X_PP_Order_Workflow
|
|||
|
||||
/** WF Nodes */
|
||||
private List<MPPOrderNode> m_nodes = null;
|
||||
/** Manufacturing Order */
|
||||
private MPPOrder m_order = null;
|
||||
|
||||
/**
|
||||
* Load All Nodes
|
||||
|
@ -411,7 +416,7 @@ public class MPPOrderWorkflow extends X_PP_Order_Workflow
|
|||
* @param AD_Client_ID for client
|
||||
* @return next PP_Order_Node_ID or 0
|
||||
*/
|
||||
public int getLast (int AD_Client_ID)
|
||||
public int getNodeLastID (int AD_Client_ID)
|
||||
{
|
||||
MPPOrderNode[] nodes = getNodesInOrder(AD_Client_ID);
|
||||
if (nodes.length > 0)
|
||||
|
@ -421,6 +426,21 @@ public class MPPOrderWorkflow extends X_PP_Order_Workflow
|
|||
return 0;
|
||||
} // getLast
|
||||
|
||||
/**
|
||||
* Get very Last Node
|
||||
* @param AD_Client_ID for client
|
||||
* @return next PP_Order_Node_ID or 0
|
||||
*/
|
||||
public MPPOrderNode getLastNode (int AD_Client_ID)
|
||||
{
|
||||
MPPOrderNode[] nodes = getNodesInOrder(AD_Client_ID);
|
||||
if (nodes.length > 0)
|
||||
{
|
||||
return nodes[nodes.length-1];
|
||||
}
|
||||
return null;
|
||||
} // getLast
|
||||
|
||||
/**
|
||||
* Is this the first Node
|
||||
* @param PP_Order_Node_ID id
|
||||
|
@ -516,4 +536,58 @@ public class MPPOrderWorkflow extends X_PP_Order_Workflow
|
|||
return Calendar.YEAR;
|
||||
return Calendar.MINUTE;
|
||||
} // getDurationCalendarField
|
||||
|
||||
|
||||
/**
|
||||
* Complete Activities
|
||||
* @param activity
|
||||
* @param movementdate
|
||||
*/
|
||||
public void closeActivities(MPPOrderNode activity, Timestamp movementdate, boolean milestone)
|
||||
{
|
||||
|
||||
MPPOrderWorkflow order_workflow = activity.getMPPOrderWorkflow();
|
||||
MPPOrder order = order_workflow.getMPPOrder();
|
||||
int nodeId = activity.get_ID();
|
||||
while(nodeId != 0)
|
||||
{
|
||||
MPPOrderNode node = MPPOrderNode.get(getCtx(), nodeId);
|
||||
//break the cycle
|
||||
if(node.isMilestone() && milestone)
|
||||
return;
|
||||
if(!MPPOrderNode.DOCSTATUS_Closed.equals(node.getDocStatus()))
|
||||
{
|
||||
|
||||
MPPCostCollector.createCollector (
|
||||
order, //MPPOrder
|
||||
order.getM_Product_ID(), //M_Product_ID
|
||||
order.getM_Locator_ID(), //M_Locator_ID
|
||||
order.getM_AttributeSetInstance_ID(), //M_AttributeSetInstance_ID
|
||||
order.getS_Resource_ID(), //S_Resource_ID
|
||||
0, //PP_Order_BOMLine_ID
|
||||
node.get_ID(), //PP_Order_Node_ID
|
||||
MDocType.getDocType(MDocType.DOCBASETYPE_ManufacturingOrder), //C_DocType_ID,
|
||||
MPPCostCollector.COSTCOLLECTORTYPE_ActivityControl, //Activity Control
|
||||
movementdate, //MovementDate
|
||||
order.getQtyOrdered(), Env.ZERO, Env.ZERO, //qty,scrap,reject
|
||||
node.getSetupTimeReal(),node.getDurationReal(), //durationSetup,duration
|
||||
get_TrxName() //trxName
|
||||
);
|
||||
}
|
||||
nodeId = order_workflow.getPrevious(node.get_ID(), order_workflow.getAD_Client_ID());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Parent
|
||||
* @return MPPOrder
|
||||
*/
|
||||
public MPPOrder getMPPOrder()
|
||||
{
|
||||
if (m_order == null)
|
||||
m_order = new MPPOrder(getCtx(), getPP_Order_ID(), get_TrxName());
|
||||
return m_order;
|
||||
} // getParent
|
||||
|
||||
|
||||
} // MPPOrderWorkflow_ID
|
||||
|
|
|
@ -156,7 +156,7 @@ public class CRP extends SvrProcess {
|
|||
else if (p_ScheduleType.equals(BACKWARD_SCHEDULING))
|
||||
{
|
||||
Timestamp date = order.getDateFinishSchedule();
|
||||
int nodeId = owf.getLast(getAD_Client_ID());
|
||||
int nodeId = owf.getNodeLastID(getAD_Client_ID());
|
||||
MPPOrderNode node = null;
|
||||
|
||||
while(nodeId != 0)
|
||||
|
|
|
@ -240,7 +240,7 @@ public abstract class CRPDatasetFactory extends CRPReasoner implements CRPModel
|
|||
else if(node.getUserObject() instanceof MPPOrderNode)
|
||||
{
|
||||
MPPOrderNode on = (MPPOrderNode)node.getUserObject();
|
||||
MPPOrderWorkflow owf = on.getPPOrderWorkflow();
|
||||
MPPOrderWorkflow owf = on.getMPPOrderWorkflow();
|
||||
MResourceType rt = MResourceType.get(Env.getCtx(), r.getS_ResourceType_ID());
|
||||
|
||||
// no function
|
||||
|
|
Loading…
Reference in New Issue