[ 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,9 +97,11 @@ public class LiberoValidator implements ModelValidator
|
||||||
{
|
{
|
||||||
MOrderLine ol = (MOrderLine)po;
|
MOrderLine ol = (MOrderLine)po;
|
||||||
MOrder order = ol.getParent();
|
MOrder order = ol.getParent();
|
||||||
if(order.getDocStatus().equals(MOrder.DOCSTATUS_InProgress) || order.getDocStatus().equals(MOrder.DOCSTATUS_Completed))
|
if(!order.isSOTrx())
|
||||||
|
{
|
||||||
MPPMRP.C_OrderLine(ol, false);
|
MPPMRP.C_OrderLine(ol, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (po.get_TableName().equals(MOrderLine.Table_Name) && type == TYPE_BEFORE_DELETE)
|
if (po.get_TableName().equals(MOrderLine.Table_Name) && type == TYPE_BEFORE_DELETE)
|
||||||
{
|
{
|
||||||
MOrderLine ol = (MOrderLine)po;
|
MOrderLine ol = (MOrderLine)po;
|
||||||
|
|
|
@ -175,6 +175,19 @@ public class MPPMRP extends X_PP_MRP
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MDocType dt = MDocType.get(o.getCtx(), o.getC_DocType_ID());
|
||||||
|
String DocSubTypeSO = dt.getDocSubTypeSO();
|
||||||
|
|
||||||
|
if(MDocType.DOCSUBTYPESO_StandardOrder.equals(DocSubTypeSO) || !o.isSOTrx())
|
||||||
|
{
|
||||||
|
if((o.getDocStatus().equals(MOrder.DOCSTATUS_InProgress) || o.getDocStatus().equals(MOrder.DOCSTATUS_Completed)) || !o.isSOTrx())
|
||||||
|
{
|
||||||
|
for(MOrderLine line : o.getLines())
|
||||||
|
{
|
||||||
|
C_OrderLine(line , false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (o.is_ValueChanged(MOrder.COLUMNNAME_DocStatus)
|
if (o.is_ValueChanged(MOrder.COLUMNNAME_DocStatus)
|
||||||
|| o.is_ValueChanged(MOrder.COLUMNNAME_C_BPartner_ID)
|
|| o.is_ValueChanged(MOrder.COLUMNNAME_C_BPartner_ID)
|
||||||
)
|
)
|
||||||
|
@ -189,6 +202,7 @@ public class MPPMRP extends X_PP_MRP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create MRP record based in Order Line
|
* Create MRP record based in Order Line
|
||||||
|
@ -236,17 +250,26 @@ public class MPPMRP extends X_PP_MRP
|
||||||
mrp.setM_Warehouse_ID(ol.getM_Warehouse_ID());
|
mrp.setM_Warehouse_ID(ol.getM_Warehouse_ID());
|
||||||
mrp.saveEx();
|
mrp.saveEx();
|
||||||
|
|
||||||
|
MOrder o = ol.getParent();
|
||||||
|
MDocType dt = MDocType.get(o.getCtx(), o.getC_DocTypeTarget_ID());
|
||||||
|
String DocSubTypeSO = dt.getDocSubTypeSO();
|
||||||
|
if(MDocType.DOCSUBTYPESO_StandardOrder.equals(DocSubTypeSO))
|
||||||
|
{
|
||||||
MPPOrder order = new Query(ctx, MPPOrder.Table_Name, whereClause, trxName)
|
MPPOrder order = new Query(ctx, MPPOrder.Table_Name, whereClause, trxName)
|
||||||
.setParameters(params)
|
.setParameters(params)
|
||||||
.first();
|
.first();
|
||||||
if (order == null)
|
if (order == null)
|
||||||
{
|
{
|
||||||
MProduct product = MProduct.get(ctx,ol.getM_Product_ID());
|
String where = MPPProductBOM.COLUMNNAME_BOMType + "='" +
|
||||||
MPPProductBOM bom = MPPProductBOM.getDefault(product, trxName);
|
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)
|
if (bom != null)
|
||||||
{
|
{
|
||||||
if (bom.getBOMType().equals(MPPProductBOM.BOMTYPE_Make_To_Order))
|
MProduct product = MProduct.get(ctx,ol.getM_Product_ID());
|
||||||
{
|
|
||||||
String WhereClause = "ManufacturingResourceType = 'PT' AND IsManufacturingResource = 'Y' AND AD_Client_ID = ? AND M_Warehouse_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);
|
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));
|
MWorkflow m_workflow = MWorkflow.get(ctx, MWorkflow.getWorkflowSearchKey(ctx, product));
|
||||||
|
@ -263,7 +286,7 @@ public class MPPMRP extends X_PP_MRP
|
||||||
order.setM_AttributeSetInstance_ID(ol.getM_AttributeSetInstance_ID());
|
order.setM_AttributeSetInstance_ID(ol.getM_AttributeSetInstance_ID());
|
||||||
order.setPP_Product_BOM_ID(bom.get_ID());
|
order.setPP_Product_BOM_ID(bom.get_ID());
|
||||||
order.setAD_Workflow_ID(m_workflow.get_ID());
|
order.setAD_Workflow_ID(m_workflow.get_ID());
|
||||||
//order.setPlanner_ID(SupplyPlanner_ID);
|
order.setPlanner_ID(ol.getParent().getSalesRep_ID());
|
||||||
order.setLine(10);
|
order.setLine(10);
|
||||||
order.setQtyDelivered(Env.ZERO);
|
order.setQtyDelivered(Env.ZERO);
|
||||||
order.setQtyReject(Env.ZERO);
|
order.setQtyReject(Env.ZERO);
|
||||||
|
@ -272,9 +295,8 @@ public class MPPMRP extends X_PP_MRP
|
||||||
order.setDatePromised(ol.getDatePromised());
|
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.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.setDateFinishSchedule(ol.getDatePromised());
|
||||||
order.setQtyEntered(ol.getQtyEntered());
|
|
||||||
order.setQtyOrdered(ol.getQtyOrdered());
|
|
||||||
order.setC_UOM_ID(ol.getC_UOM_ID());
|
order.setC_UOM_ID(ol.getC_UOM_ID());
|
||||||
|
order.setQty(ol.getQtyEntered());
|
||||||
order.setPosted(false);
|
order.setPosted(false);
|
||||||
order.setProcessed(false);
|
order.setProcessed(false);
|
||||||
order.setC_DocTypeTarget_ID(C_DocType_ID);
|
order.setC_DocTypeTarget_ID(C_DocType_ID);
|
||||||
|
@ -284,7 +306,7 @@ public class MPPMRP extends X_PP_MRP
|
||||||
order.prepareIt();
|
order.prepareIt();
|
||||||
order.setDocAction(MPPOrder.DOCSTATUS_Completed);
|
order.setDocAction(MPPOrder.DOCSTATUS_Completed);
|
||||||
order.saveEx();
|
order.saveEx();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,11 +314,19 @@ public class MPPMRP extends X_PP_MRP
|
||||||
{
|
{
|
||||||
if (!order.isProcessed())
|
if (!order.isProcessed())
|
||||||
{
|
{
|
||||||
order.setQtyEntered(ol.getQtyEntered());
|
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.setDatePromised(ol.getDatePromised());
|
||||||
order.saveEx();
|
order.saveEx();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.compiere.model.MProject;
|
||||||
import org.compiere.model.MResource;
|
import org.compiere.model.MResource;
|
||||||
import org.compiere.model.MStorage;
|
import org.compiere.model.MStorage;
|
||||||
import org.compiere.model.MTable;
|
import org.compiere.model.MTable;
|
||||||
|
import org.compiere.model.MUOM;
|
||||||
import org.compiere.model.MWarehouse;
|
import org.compiere.model.MWarehouse;
|
||||||
import org.compiere.model.ModelValidationEngine;
|
import org.compiere.model.ModelValidationEngine;
|
||||||
import org.compiere.model.ModelValidator;
|
import org.compiere.model.ModelValidator;
|
||||||
|
@ -63,6 +64,8 @@ import org.compiere.wf.MWorkflow;
|
||||||
public class MPPOrder extends X_PP_Order implements DocAction
|
public class MPPOrder extends X_PP_Order implements DocAction
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
/** Product */
|
||||||
|
private MProduct m_product = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new Order by copying
|
* Create new Order by copying
|
||||||
|
@ -293,90 +296,46 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
||||||
{
|
{
|
||||||
return false;
|
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)
|
if (!newRecord)
|
||||||
{
|
{
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create BOM Head
|
explotion();
|
||||||
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
|
|
||||||
return true;
|
return true;
|
||||||
} // beforeSave
|
} // 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()
|
public String toString()
|
||||||
{
|
{
|
||||||
StringBuffer sb = new StringBuffer("MPPOrder[").append(get_ID())
|
StringBuffer sb = new StringBuffer("MPPOrder[").append(get_ID())
|
||||||
|
|
|
@ -98,4 +98,4 @@ public class MPPOrderBOM extends X_PP_Order_BOM
|
||||||
.append ("]");
|
.append ("]");
|
||||||
return sb.toString ();
|
return sb.toString ();
|
||||||
} // toString
|
} // toString
|
||||||
} // MOrder
|
} // MPPOrderBOM
|
||||||
|
|
|
@ -58,14 +58,6 @@ public class MPPOrderWorkflow extends X_PP_Order_Workflow
|
||||||
return retValue;
|
return retValue;
|
||||||
} // get
|
} // 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 */
|
/** 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>("PP_Order_Workflow", 20);
|
||||||
|
|
||||||
|
|
|
@ -106,8 +106,7 @@ public class CRP extends SvrProcess {
|
||||||
{
|
{
|
||||||
log.fine("PP_Order DocumentNo:" + order.getDocumentNo());
|
log.fine("PP_Order DocumentNo:" + order.getDocumentNo());
|
||||||
BigDecimal qtyOpen = order.getQtyOpen();
|
BigDecimal qtyOpen = order.getQtyOpen();
|
||||||
|
MPPOrderWorkflow owf = order.getMPPOrderWorkflow();
|
||||||
MPPOrderWorkflow owf = MPPOrderWorkflow.forPP_Order_ID(order.getCtx(), order.getPP_Order_ID(), order.get_TrxName());
|
|
||||||
log.fine("PP_Order Workflow:" + owf.getName());
|
log.fine("PP_Order Workflow:" + owf.getName());
|
||||||
|
|
||||||
// Schedule Fordward
|
// Schedule Fordward
|
||||||
|
|
|
@ -872,9 +872,7 @@ public class MRP extends SvrProcess
|
||||||
else
|
else
|
||||||
order.setDateStartSchedule(TimeUtil.addDays(DemandDateStartSchedule, (m_product_planning.getDeliveryTime_Promised().add(m_product_planning.getTransfertTime())).negate().intValue()));
|
order.setDateStartSchedule(TimeUtil.addDays(DemandDateStartSchedule, (m_product_planning.getDeliveryTime_Promised().add(m_product_planning.getTransfertTime())).negate().intValue()));
|
||||||
order.setDateFinishSchedule(DemandDateStartSchedule);
|
order.setDateFinishSchedule(DemandDateStartSchedule);
|
||||||
|
order.setQty(QtyPlanned);
|
||||||
order.setQtyEntered(QtyPlanned);
|
|
||||||
order.setQtyOrdered(QtyPlanned);
|
|
||||||
order.setQtyBatchs(Env.ONE);
|
order.setQtyBatchs(Env.ONE);
|
||||||
order.setQtyBatchSize(QtyPlanned);
|
order.setQtyBatchSize(QtyPlanned);
|
||||||
order.setC_UOM_ID(product.getC_UOM_ID());
|
order.setC_UOM_ID(product.getC_UOM_ID());
|
||||||
|
|
Loading…
Reference in New Issue