[ 2151963 ] When you update the qty in sales order the MO should be update
http://sourceforge.net/tracker/?func=detail&atid=879332&aid=2151963&group_id=176962
This commit is contained in:
parent
9a904111b7
commit
e4bee4874b
|
@ -97,8 +97,10 @@ public class LiberoValidator implements ModelValidator
|
|||
{
|
||||
MOrderLine ol = (MOrderLine)po;
|
||||
MOrder order = ol.getParent();
|
||||
if(order.getDocStatus().equals(MOrder.DOCSTATUS_InProgress) || order.getDocStatus().equals(MOrder.DOCSTATUS_Completed))
|
||||
MPPMRP.C_OrderLine(ol, false);
|
||||
if(!order.isSOTrx())
|
||||
{
|
||||
MPPMRP.C_OrderLine(ol, false);
|
||||
}
|
||||
}
|
||||
if (po.get_TableName().equals(MOrderLine.Table_Name) && type == TYPE_BEFORE_DELETE)
|
||||
{
|
||||
|
|
|
@ -175,17 +175,31 @@ public class MPPMRP extends X_PP_MRP
|
|||
return;
|
||||
}
|
||||
|
||||
if (o.is_ValueChanged(MOrder.COLUMNNAME_DocStatus)
|
||||
|| o.is_ValueChanged(MOrder.COLUMNNAME_C_BPartner_ID)
|
||||
)
|
||||
MDocType dt = MDocType.get(o.getCtx(), o.getC_DocType_ID());
|
||||
String DocSubTypeSO = dt.getDocSubTypeSO();
|
||||
|
||||
if(MDocType.DOCSUBTYPESO_StandardOrder.equals(DocSubTypeSO) || !o.isSOTrx())
|
||||
{
|
||||
List<MPPMRP> list = new Query(o.getCtx(), MPPMRP.Table_Name, whereClause, trxName)
|
||||
.setParameters(params)
|
||||
.list();
|
||||
for (MPPMRP mrp : list)
|
||||
if((o.getDocStatus().equals(MOrder.DOCSTATUS_InProgress) || o.getDocStatus().equals(MOrder.DOCSTATUS_Completed)) || !o.isSOTrx())
|
||||
{
|
||||
mrp.setC_Order(o);
|
||||
mrp.saveEx();
|
||||
for(MOrderLine line : o.getLines())
|
||||
{
|
||||
C_OrderLine(line , false);
|
||||
}
|
||||
}
|
||||
|
||||
if (o.is_ValueChanged(MOrder.COLUMNNAME_DocStatus)
|
||||
|| o.is_ValueChanged(MOrder.COLUMNNAME_C_BPartner_ID)
|
||||
)
|
||||
{
|
||||
List<MPPMRP> list = new Query(o.getCtx(), MPPMRP.Table_Name, whereClause, trxName)
|
||||
.setParameters(params)
|
||||
.list();
|
||||
for (MPPMRP mrp : list)
|
||||
{
|
||||
mrp.setC_Order(o);
|
||||
mrp.saveEx();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -236,65 +250,81 @@ public class MPPMRP extends X_PP_MRP
|
|||
mrp.setM_Warehouse_ID(ol.getM_Warehouse_ID());
|
||||
mrp.saveEx();
|
||||
|
||||
MPPOrder order = new Query(ctx, MPPOrder.Table_Name, whereClause, trxName)
|
||||
.setParameters(params)
|
||||
.first();
|
||||
if (order == null)
|
||||
MOrder o = ol.getParent();
|
||||
MDocType dt = MDocType.get(o.getCtx(), o.getC_DocTypeTarget_ID());
|
||||
String DocSubTypeSO = dt.getDocSubTypeSO();
|
||||
if(MDocType.DOCSUBTYPESO_StandardOrder.equals(DocSubTypeSO))
|
||||
{
|
||||
MProduct product = MProduct.get(ctx,ol.getM_Product_ID());
|
||||
MPPProductBOM bom = MPPProductBOM.getDefault(product, trxName);
|
||||
if (bom != null)
|
||||
MPPOrder order = new Query(ctx, MPPOrder.Table_Name, whereClause, trxName)
|
||||
.setParameters(params)
|
||||
.first();
|
||||
if (order == null)
|
||||
{
|
||||
if (bom.getBOMType().equals(MPPProductBOM.BOMTYPE_Make_To_Order))
|
||||
{
|
||||
String WhereClause = "ManufacturingResourceType = 'PT' AND IsManufacturingResource = 'Y' AND AD_Client_ID = ? AND M_Warehouse_ID = ?";
|
||||
MResource m_resource = (MResource)MTable.get(ctx,MResource.Table_ID).getPO(WhereClause, new Object[]{ ol.getAD_Client_ID(),ol.getM_Warehouse_ID()}, trxName);
|
||||
MWorkflow m_workflow = MWorkflow.get(ctx, MWorkflow.getWorkflowSearchKey(ctx, product));
|
||||
if (m_resource != null && m_workflow != null)
|
||||
{
|
||||
MDocType[] doc = MDocType.getOfDocBaseType(ctx, X_C_DocType.DOCBASETYPE_ManufacturingOrder);
|
||||
int C_DocType_ID = doc[0].getC_DocType_ID();
|
||||
String where = MPPProductBOM.COLUMNNAME_BOMType + "='" +
|
||||
MPPProductBOM.BOMTYPE_Make_To_Order + "' AND "+
|
||||
MPPProductBOM.COLUMNNAME_M_Product_ID + "=?";
|
||||
MPPProductBOM bom = new Query(ctx, MPPProductBOM.Table_Name, where, trxName)
|
||||
.setParameters(new Object[]{ol.getM_Product_ID()})
|
||||
.first();
|
||||
|
||||
if (bom != null)
|
||||
{
|
||||
MProduct product = MProduct.get(ctx,ol.getM_Product_ID());
|
||||
String WhereClause = "ManufacturingResourceType = 'PT' AND IsManufacturingResource = 'Y' AND AD_Client_ID = ? AND M_Warehouse_ID = ?";
|
||||
MResource m_resource = (MResource)MTable.get(ctx,MResource.Table_ID).getPO(WhereClause, new Object[]{ ol.getAD_Client_ID(),ol.getM_Warehouse_ID()}, trxName);
|
||||
MWorkflow m_workflow = MWorkflow.get(ctx, MWorkflow.getWorkflowSearchKey(ctx, product));
|
||||
if (m_resource != null && m_workflow != null)
|
||||
{
|
||||
MDocType[] doc = MDocType.getOfDocBaseType(ctx, X_C_DocType.DOCBASETYPE_ManufacturingOrder);
|
||||
int C_DocType_ID = doc[0].getC_DocType_ID();
|
||||
|
||||
order = new MPPOrder(ctx, 0 , trxName);
|
||||
order.setC_OrderLine_ID(ol.getC_OrderLine_ID());
|
||||
order.setS_Resource_ID(m_resource.get_ID());
|
||||
order.setM_Warehouse_ID(ol.getM_Warehouse_ID());
|
||||
order.setM_Product_ID(ol.getM_Product_ID());
|
||||
order.setM_AttributeSetInstance_ID(ol.getM_AttributeSetInstance_ID());
|
||||
order.setPP_Product_BOM_ID(bom.get_ID());
|
||||
order.setAD_Workflow_ID(m_workflow.get_ID());
|
||||
order.setPlanner_ID(ol.getParent().getSalesRep_ID());
|
||||
order.setLine(10);
|
||||
order.setQtyDelivered(Env.ZERO);
|
||||
order.setQtyReject(Env.ZERO);
|
||||
order.setQtyScrap(Env.ZERO);
|
||||
order.setDateOrdered(ol.getDateOrdered());
|
||||
order.setDatePromised(ol.getDatePromised());
|
||||
order.setDateStartSchedule(TimeUtil.addDays(ol.getDatePromised(), (MPPMRP.getDays(ctx,m_resource.getS_Resource_ID(),m_workflow.getAD_Workflow_ID(), ol.getQtyOrdered(),ol.get_TrxName())).negate().intValue()));
|
||||
order.setDateFinishSchedule(ol.getDatePromised());
|
||||
order.setC_UOM_ID(ol.getC_UOM_ID());
|
||||
order.setQty(ol.getQtyEntered());
|
||||
order.setPosted(false);
|
||||
order.setProcessed(false);
|
||||
order.setC_DocTypeTarget_ID(C_DocType_ID);
|
||||
order.setC_DocType_ID(C_DocType_ID);
|
||||
order.setPriorityRule(MPPOrder.PRIORITYRULE_High);
|
||||
order.saveEx();
|
||||
order.prepareIt();
|
||||
order.setDocAction(MPPOrder.DOCSTATUS_Completed);
|
||||
order.saveEx();
|
||||
|
||||
order = new MPPOrder(ctx, 0 , trxName);
|
||||
order.setC_OrderLine_ID(ol.getC_OrderLine_ID());
|
||||
order.setS_Resource_ID(m_resource.get_ID());
|
||||
order.setM_Warehouse_ID(ol.getM_Warehouse_ID());
|
||||
order.setM_Product_ID(ol.getM_Product_ID());
|
||||
order.setM_AttributeSetInstance_ID(ol.getM_AttributeSetInstance_ID());
|
||||
order.setPP_Product_BOM_ID(bom.get_ID());
|
||||
order.setAD_Workflow_ID(m_workflow.get_ID());
|
||||
//order.setPlanner_ID(SupplyPlanner_ID);
|
||||
order.setLine(10);
|
||||
order.setQtyDelivered(Env.ZERO);
|
||||
order.setQtyReject(Env.ZERO);
|
||||
order.setQtyScrap(Env.ZERO);
|
||||
order.setDateOrdered(ol.getDateOrdered());
|
||||
order.setDatePromised(ol.getDatePromised());
|
||||
order.setDateStartSchedule(TimeUtil.addDays(ol.getDatePromised(), (MPPMRP.getDays(ctx,m_resource.getS_Resource_ID(),m_workflow.getAD_Workflow_ID(), ol.getQtyOrdered(),ol.get_TrxName())).negate().intValue()));
|
||||
order.setDateFinishSchedule(ol.getDatePromised());
|
||||
order.setQtyEntered(ol.getQtyEntered());
|
||||
order.setQtyOrdered(ol.getQtyOrdered());
|
||||
order.setC_UOM_ID(ol.getC_UOM_ID());
|
||||
order.setPosted(false);
|
||||
order.setProcessed(false);
|
||||
order.setC_DocTypeTarget_ID(C_DocType_ID);
|
||||
order.setC_DocType_ID(C_DocType_ID);
|
||||
order.setPriorityRule(MPPOrder.PRIORITYRULE_High);
|
||||
order.saveEx();
|
||||
order.prepareIt();
|
||||
order.setDocAction(MPPOrder.DOCSTATUS_Completed);
|
||||
order.saveEx();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!order.isProcessed())
|
||||
else
|
||||
{
|
||||
order.setQtyEntered(ol.getQtyEntered());
|
||||
order.setDatePromised(ol.getDatePromised());
|
||||
order.saveEx();
|
||||
if (!order.isProcessed())
|
||||
{
|
||||
if(order.getQtyEntered().compareTo(ol.getQtyEntered()) != 0)
|
||||
{
|
||||
order.setQty(ol.getQtyEntered());
|
||||
order.saveEx();
|
||||
}
|
||||
if(order.getDatePromised().compareTo(ol.getDatePromised()) != 0)
|
||||
{
|
||||
order.setDatePromised(ol.getDatePromised());
|
||||
order.saveEx();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.compiere.model.MProject;
|
|||
import org.compiere.model.MResource;
|
||||
import org.compiere.model.MStorage;
|
||||
import org.compiere.model.MTable;
|
||||
import org.compiere.model.MUOM;
|
||||
import org.compiere.model.MWarehouse;
|
||||
import org.compiere.model.ModelValidationEngine;
|
||||
import org.compiere.model.ModelValidator;
|
||||
|
@ -63,6 +64,8 @@ import org.compiere.wf.MWorkflow;
|
|||
public class MPPOrder extends X_PP_Order implements DocAction
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
/** Product */
|
||||
private MProduct m_product = null;
|
||||
|
||||
/**
|
||||
* Create new Order by copying
|
||||
|
@ -293,90 +296,46 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( is_ValueChanged(MPPOrder.COLUMNNAME_QtyEntered) &&
|
||||
getDocStatus().equals(MPPOrder.DOCSTATUS_Drafted))
|
||||
{
|
||||
for(MPPOrderBOMLine line : getLines())
|
||||
{
|
||||
line.deleteEx(true);
|
||||
}
|
||||
MPPOrderBOM bom = getMPPOrderBOM();
|
||||
if(bom != null)
|
||||
bom.deleteEx(true, get_TrxName());
|
||||
|
||||
MPPOrderWorkflow PP_Order_Workflow = getMPPOrderWorkflow();
|
||||
if (PP_Order_Workflow != null)
|
||||
{
|
||||
PP_Order_Workflow.setPP_Order_Node_ID(0);
|
||||
PP_Order_Workflow.saveEx();
|
||||
for(MPPOrderNode node : PP_Order_Workflow.getNodes(true, getAD_Client_ID()))
|
||||
{
|
||||
for(MPPOrderNodeNext next : node.getTransitions(getAD_Client_ID()))
|
||||
{
|
||||
next.deleteEx(true);
|
||||
}
|
||||
node.deleteEx(true);
|
||||
}
|
||||
PP_Order_Workflow.deleteEx(true);
|
||||
}
|
||||
explotion();
|
||||
}
|
||||
if( is_ValueChanged(MPPOrder.COLUMNNAME_QtyEntered) && !getDocStatus().equals(MPPOrder.DOCSTATUS_Drafted))
|
||||
{
|
||||
throw new AdempiereException("Cannot Change Quantity, Only is allow with Draft Status"); // TODO: Create Message for Translation
|
||||
}
|
||||
|
||||
if (!newRecord)
|
||||
{
|
||||
return success;
|
||||
}
|
||||
|
||||
// Create BOM Head
|
||||
MPPProductBOM PP_Product_BOM = MPPProductBOM.get(getCtx(), getPP_Product_BOM_ID());
|
||||
if (PP_Product_BOM.isValidFromTo(getDateStartSchedule()))
|
||||
{
|
||||
MPPOrderBOM PP_Order_BOM = new MPPOrderBOM(PP_Product_BOM, getPP_Order_ID(), get_TrxName());
|
||||
PP_Order_BOM.setAD_Org_ID(getAD_Org_ID());
|
||||
PP_Order_BOM.saveEx();
|
||||
|
||||
for (MPPProductBOMLine PP_Product_BOMline : PP_Product_BOM.getLines())
|
||||
{
|
||||
if (PP_Product_BOMline.isValidFromTo(getDateStartSchedule()))
|
||||
{
|
||||
MPPOrderBOMLine PP_Order_BOMLine = new MPPOrderBOMLine(PP_Product_BOMline,
|
||||
getPP_Order_ID(), PP_Order_BOM.get_ID(),
|
||||
getM_Warehouse_ID(),
|
||||
get_TrxName());
|
||||
PP_Order_BOMLine.setAD_Org_ID(getAD_Org_ID());
|
||||
PP_Order_BOMLine.setQtyOrdered(getQtyOrdered());
|
||||
PP_Order_BOMLine.saveEx();
|
||||
} // end if valid From / To
|
||||
} // end Create Order BOM
|
||||
|
||||
} // end if From / To parent
|
||||
|
||||
// Create Workflow (Routing & Process
|
||||
MWorkflow AD_Workflow = MWorkflow.get(getCtx(), getAD_Workflow_ID());
|
||||
if (AD_Workflow.isValidFromTo(getDateStartSchedule()))
|
||||
{
|
||||
MPPOrderWorkflow PP_Order_Workflow = new MPPOrderWorkflow(AD_Workflow, get_ID(), get_TrxName());
|
||||
PP_Order_Workflow.setAD_Org_ID(getAD_Org_ID());
|
||||
PP_Order_Workflow.saveEx();
|
||||
for (MWFNode AD_WF_Node : AD_Workflow.getNodes(false, getAD_Client_ID()))
|
||||
{
|
||||
if (AD_WF_Node.isValidFromTo(getDateStartSchedule()))
|
||||
{
|
||||
MPPOrderNode PP_Order_Node = new MPPOrderNode(AD_WF_Node, PP_Order_Workflow,
|
||||
getQtyOrdered(),
|
||||
get_TrxName());
|
||||
PP_Order_Node.setAD_Org_ID(getAD_Org_ID());
|
||||
PP_Order_Node.saveEx();
|
||||
|
||||
for (MWFNodeNext AD_WF_NodeNext : AD_WF_Node.getTransitions(getAD_Client_ID()))
|
||||
{
|
||||
MPPOrderNodeNext nodenext = new MPPOrderNodeNext(AD_WF_NodeNext, PP_Order_Node, get_TrxName());
|
||||
nodenext.setAD_Org_ID(getAD_Org_ID());
|
||||
nodenext.saveEx();
|
||||
}// for NodeNext
|
||||
}// for node
|
||||
|
||||
}
|
||||
// Update transitions nexts and set first node
|
||||
PP_Order_Workflow.loadNodes();
|
||||
for (MPPOrderNode orderNode : PP_Order_Workflow.getNodes(false, getAD_Client_ID()))
|
||||
{
|
||||
// set workflow start node
|
||||
if (PP_Order_Workflow.getAD_WF_Node_ID() == orderNode.getAD_WF_Node_ID()) {
|
||||
PP_Order_Workflow.setPP_Order_Node_ID(orderNode.getPP_Order_Node_ID());
|
||||
}
|
||||
// set node next
|
||||
for (MPPOrderNodeNext next : orderNode.getTransitions(getAD_Client_ID()))
|
||||
{
|
||||
next.setPP_Order_Next_ID();
|
||||
next.saveEx();
|
||||
}
|
||||
}
|
||||
PP_Order_Workflow.saveEx();
|
||||
|
||||
BigDecimal QtyBatchs = null;
|
||||
BigDecimal QtyBatchSize = PP_Order_Workflow.getQtyBatchSize().setScale(0, RoundingMode.UP);
|
||||
|
||||
if (QtyBatchSize.signum()==0)
|
||||
QtyBatchs = Env.ONE;
|
||||
else
|
||||
QtyBatchs = getQtyEntered().divide(QtyBatchSize , 0, BigDecimal.ROUND_UP);
|
||||
|
||||
setQtyBatchs(QtyBatchs);
|
||||
setQtyBatchSize(QtyBatchSize);
|
||||
|
||||
} // workflow valid from/to
|
||||
explotion();
|
||||
return true;
|
||||
} // beforeSave
|
||||
|
||||
|
@ -853,6 +812,156 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Qty Entered/Ordered.
|
||||
* Use this Method if the Line UOM is the Product UOM
|
||||
* @param Qty QtyOrdered/Entered
|
||||
*/
|
||||
public void setQty (BigDecimal Qty)
|
||||
{
|
||||
super.setQtyEntered (Qty);
|
||||
super.setQtyOrdered (getQtyEntered());
|
||||
} // setQty
|
||||
|
||||
/**
|
||||
* Set Qty Entered - enforce entered UOM
|
||||
* @param QtyEntered
|
||||
*/
|
||||
public void setQtyEntered (BigDecimal QtyEntered)
|
||||
{
|
||||
if (QtyEntered != null && getC_UOM_ID() != 0)
|
||||
{
|
||||
int precision = MUOM.getPrecision(getCtx(), getC_UOM_ID());
|
||||
QtyEntered = QtyEntered.setScale(precision, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
super.setQtyEntered (QtyEntered);
|
||||
} // setQtyEntered
|
||||
|
||||
/**
|
||||
* Set Qty Ordered - enforce Product UOM
|
||||
* @param QtyOrdered
|
||||
*/
|
||||
public void setQtyOrdered (BigDecimal QtyOrdered)
|
||||
{
|
||||
MProduct product = getProduct();
|
||||
if (QtyOrdered != null && product != null)
|
||||
{
|
||||
int precision = product.getUOMPrecision();
|
||||
QtyOrdered = QtyOrdered.setScale(precision, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
super.setQtyOrdered(QtyOrdered);
|
||||
} // setQtyOrdered
|
||||
|
||||
/**
|
||||
* Get Product
|
||||
* @return product or null
|
||||
*/
|
||||
public MProduct getProduct()
|
||||
{
|
||||
if (m_product == null && getM_Product_ID() != 0)
|
||||
m_product = MProduct.get (getCtx(), getM_Product_ID());
|
||||
return m_product;
|
||||
} // getProduct
|
||||
|
||||
public MPPOrderBOM getMPPOrderBOM()
|
||||
{
|
||||
final String whereClause = MPPOrderBOM.COLUMNNAME_PP_Order_ID+"=?";
|
||||
return new Query(getCtx(), MPPOrderBOM.Table_Name, whereClause, get_TrxName())
|
||||
.setParameters(new Object[]{getPP_Order_ID()})
|
||||
.first();
|
||||
}
|
||||
|
||||
public MPPOrderWorkflow getMPPOrderWorkflow()
|
||||
{
|
||||
final String whereClause = MPPOrderWorkflow.COLUMNNAME_PP_Order_ID+"=?";
|
||||
return new Query(getCtx(), MPPOrderWorkflow.Table_Name, whereClause, get_TrxName())
|
||||
.setParameters(new Object[]{getPP_Order_ID()})
|
||||
.first();
|
||||
}
|
||||
|
||||
public void explotion()
|
||||
{
|
||||
// Create BOM Head
|
||||
MPPProductBOM PP_Product_BOM = MPPProductBOM.get(getCtx(), getPP_Product_BOM_ID());
|
||||
if (PP_Product_BOM.isValidFromTo(getDateStartSchedule()))
|
||||
{
|
||||
MPPOrderBOM PP_Order_BOM = new MPPOrderBOM(PP_Product_BOM, getPP_Order_ID(), get_TrxName());
|
||||
PP_Order_BOM.setAD_Org_ID(getAD_Org_ID());
|
||||
PP_Order_BOM.saveEx();
|
||||
|
||||
for (MPPProductBOMLine PP_Product_BOMline : PP_Product_BOM.getLines())
|
||||
{
|
||||
if (PP_Product_BOMline.isValidFromTo(getDateStartSchedule()))
|
||||
{
|
||||
MPPOrderBOMLine PP_Order_BOMLine = new MPPOrderBOMLine(PP_Product_BOMline,
|
||||
getPP_Order_ID(), PP_Order_BOM.get_ID(),
|
||||
getM_Warehouse_ID(),
|
||||
get_TrxName());
|
||||
PP_Order_BOMLine.setAD_Org_ID(getAD_Org_ID());
|
||||
PP_Order_BOMLine.setQtyOrdered(getQtyOrdered());
|
||||
PP_Order_BOMLine.saveEx();
|
||||
} // end if valid From / To
|
||||
} // end Create Order BOM
|
||||
|
||||
} // end if From / To parent
|
||||
|
||||
// Create Workflow (Routing & Process
|
||||
MWorkflow AD_Workflow = MWorkflow.get(getCtx(), getAD_Workflow_ID());
|
||||
if (AD_Workflow.isValidFromTo(getDateStartSchedule()))
|
||||
{
|
||||
MPPOrderWorkflow PP_Order_Workflow = new MPPOrderWorkflow(AD_Workflow, get_ID(), get_TrxName());
|
||||
PP_Order_Workflow.setAD_Org_ID(getAD_Org_ID());
|
||||
PP_Order_Workflow.saveEx();
|
||||
for (MWFNode AD_WF_Node : AD_Workflow.getNodes(false, getAD_Client_ID()))
|
||||
{
|
||||
if (AD_WF_Node.isValidFromTo(getDateStartSchedule()))
|
||||
{
|
||||
MPPOrderNode PP_Order_Node = new MPPOrderNode(AD_WF_Node, PP_Order_Workflow,
|
||||
getQtyOrdered(),
|
||||
get_TrxName());
|
||||
PP_Order_Node.setAD_Org_ID(getAD_Org_ID());
|
||||
PP_Order_Node.saveEx();
|
||||
|
||||
for (MWFNodeNext AD_WF_NodeNext : AD_WF_Node.getTransitions(getAD_Client_ID()))
|
||||
{
|
||||
MPPOrderNodeNext nodenext = new MPPOrderNodeNext(AD_WF_NodeNext, PP_Order_Node, get_TrxName());
|
||||
nodenext.setAD_Org_ID(getAD_Org_ID());
|
||||
nodenext.saveEx();
|
||||
}// for NodeNext
|
||||
}// for node
|
||||
|
||||
}
|
||||
// Update transitions nexts and set first node
|
||||
PP_Order_Workflow.loadNodes();
|
||||
for (MPPOrderNode orderNode : PP_Order_Workflow.getNodes(false, getAD_Client_ID()))
|
||||
{
|
||||
// set workflow start node
|
||||
if (PP_Order_Workflow.getAD_WF_Node_ID() == orderNode.getAD_WF_Node_ID()) {
|
||||
PP_Order_Workflow.setPP_Order_Node_ID(orderNode.getPP_Order_Node_ID());
|
||||
}
|
||||
// set node next
|
||||
for (MPPOrderNodeNext next : orderNode.getTransitions(getAD_Client_ID()))
|
||||
{
|
||||
next.setPP_Order_Next_ID();
|
||||
next.saveEx();
|
||||
}
|
||||
}
|
||||
PP_Order_Workflow.saveEx();
|
||||
|
||||
BigDecimal QtyBatchs = null;
|
||||
BigDecimal QtyBatchSize = PP_Order_Workflow.getQtyBatchSize().setScale(0, RoundingMode.UP);
|
||||
|
||||
if (QtyBatchSize.signum()==0)
|
||||
QtyBatchs = Env.ONE;
|
||||
else
|
||||
QtyBatchs = getQtyOrdered().divide(QtyBatchSize , 0, BigDecimal.ROUND_UP);
|
||||
|
||||
setQtyBatchs(QtyBatchs);
|
||||
setQtyBatchSize(QtyBatchSize);
|
||||
|
||||
} // workflow valid from/to
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer("MPPOrder[").append(get_ID())
|
||||
|
|
|
@ -98,4 +98,4 @@ public class MPPOrderBOM extends X_PP_Order_BOM
|
|||
.append ("]");
|
||||
return sb.toString ();
|
||||
} // toString
|
||||
} // MOrder
|
||||
} // MPPOrderBOM
|
||||
|
|
|
@ -58,14 +58,6 @@ public class MPPOrderWorkflow extends X_PP_Order_Workflow
|
|||
return retValue;
|
||||
} // get
|
||||
|
||||
public static MPPOrderWorkflow forPP_Order_ID(Properties ctx, int PP_Order_ID, String trxName)
|
||||
{
|
||||
final String whereClause = MPPOrderWorkflow.COLUMNNAME_PP_Order_ID+"=?";
|
||||
return new Query(ctx, MPPOrderWorkflow.Table_Name, whereClause, trxName)
|
||||
.setParameters(new Object[]{PP_Order_ID})
|
||||
.first();
|
||||
}
|
||||
|
||||
/** Single Cache */
|
||||
private static CCache<Integer,MPPOrderWorkflow> s_cache = new CCache<Integer,MPPOrderWorkflow>("PP_Order_Workflow", 20);
|
||||
|
||||
|
|
|
@ -106,8 +106,7 @@ public class CRP extends SvrProcess {
|
|||
{
|
||||
log.fine("PP_Order DocumentNo:" + order.getDocumentNo());
|
||||
BigDecimal qtyOpen = order.getQtyOpen();
|
||||
|
||||
MPPOrderWorkflow owf = MPPOrderWorkflow.forPP_Order_ID(order.getCtx(), order.getPP_Order_ID(), order.get_TrxName());
|
||||
MPPOrderWorkflow owf = order.getMPPOrderWorkflow();
|
||||
log.fine("PP_Order Workflow:" + owf.getName());
|
||||
|
||||
// Schedule Fordward
|
||||
|
|
|
@ -872,9 +872,7 @@ public class MRP extends SvrProcess
|
|||
else
|
||||
order.setDateStartSchedule(TimeUtil.addDays(DemandDateStartSchedule, (m_product_planning.getDeliveryTime_Promised().add(m_product_planning.getTransfertTime())).negate().intValue()));
|
||||
order.setDateFinishSchedule(DemandDateStartSchedule);
|
||||
|
||||
order.setQtyEntered(QtyPlanned);
|
||||
order.setQtyOrdered(QtyPlanned);
|
||||
order.setQty(QtyPlanned);
|
||||
order.setQtyBatchs(Env.ONE);
|
||||
order.setQtyBatchSize(QtyPlanned);
|
||||
order.setC_UOM_ID(product.getC_UOM_ID());
|
||||
|
|
Loading…
Reference in New Issue