diff --git a/base/src/org/eevolution/model/LiberoValidator.java b/base/src/org/eevolution/model/LiberoValidator.java index 63d6d92655..93aa0aa9ad 100644 --- a/base/src/org/eevolution/model/LiberoValidator.java +++ b/base/src/org/eevolution/model/LiberoValidator.java @@ -221,10 +221,7 @@ public class LiberoValidator implements ModelValidator cc.setDocStatus(docStatus); cc.setDocAction(MPPCostCollector.DOCACTION_Close); cc.saveEx(); - return Msg.translate(po.getCtx(), "PP_Order_ID") - +":"+cc.getPP_Order().getDocumentNo() - +Msg.translate(po.getCtx(),"PP_Order_Node_ID") - +":"+cc.getPP_Order_Node().getValue(); + return null; } } } diff --git a/base/src/org/eevolution/model/MPPCostCollector.java b/base/src/org/eevolution/model/MPPCostCollector.java index d4f8af775e..5cd29c27ca 100644 --- a/base/src/org/eevolution/model/MPPCostCollector.java +++ b/base/src/org/eevolution/model/MPPCostCollector.java @@ -204,17 +204,22 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction if (activity.isSubcontracting()) { - if(activity.getDocStatus().equals(MPPOrderNode.DOCSTATUS_InProgress) - && getDocStatus().equals(MPPCostCollector.DOCSTATUS_InProgress)) + if(MPPOrderNode.DOCSTATUS_InProgress.equals(activity.getDocStatus()) + && MPPCostCollector.DOCSTATUS_InProgress.equals(getDocStatus())) { return MPPOrderNode.DOCSTATUS_InProgress; } - else if(activity.getDocStatus().equals(MPPOrderNode.DOCSTATUS_InProgress) - && getDocStatus().equals(MPPCostCollector.DOCSTATUS_Drafted)) + else if(MPPOrderNode.DOCSTATUS_InProgress.equals(activity.getDocStatus()) + && MPPCostCollector.DOCSTATUS_Drafted.equals(getDocStatus())) { throw new ActivityProcessedException(activity); } - createPOrder(activity); + m_processMsg = createPO(activity); + m_justPrepared = false; + setDocAction(DOCACTION_Complete); + activity.setDocStatus(DOCSTATUS_InProgress); + activity.saveEx(); + return DOCSTATUS_InProgress; } activity.setDocStatus(DOCSTATUS_InProgress); @@ -436,7 +441,7 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction msg.append(oline.getParent().getDocumentNo()).append(","); } - if(DocStatus.equals(MPPOrderNode.DOCSTATUS_InProgress)) + if(MPPOrderNode.DOCSTATUS_InProgress.equals(DocStatus)) { m_processMsg = msg.toString(); return DocStatus; @@ -446,10 +451,11 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction setDocStatus(DOCSTATUS_Completed); activity.setDocStatus(DOCSTATUS_Completed); activity.saveEx(); - - setDocAction(DOCACTION_Complete); - setDocStatus(DOCSTATUS_InProgress); - return DOCSTATUS_InProgress; + m_processMsg = Msg.translate(getCtx(), "PP_Order_ID") + +":"+ getPP_Order().getDocumentNo() + +Msg.translate(getCtx(),"PP_Order_Node_ID") + +":"+getPP_Order_Node().getValue(); + return DocStatus; } else { @@ -839,8 +845,9 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction * Create Purchase Order (in case of Subcontracting) * @param activity */ - private void createPOrder(MPPOrderNode activity) + private String createPO(MPPOrderNode activity) { + String msg = ""; HashMap orders = new HashMap(); // String whereClause = MPPOrderNodeProduct.COLUMNNAME_PP_Order_Node_ID+"=?" @@ -891,6 +898,7 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction { order = new MOrder(getCtx(), 0, get_TrxName()); MBPartner vendor = MBPartner.get(getCtx(), C_BPartner_ID); + order.setAD_Org_ID(getAD_Org_ID()); order.setBPartner(vendor); order.setIsSOTrx(false); order.setC_DocTypeTarget_ID(); @@ -903,10 +911,15 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction order.saveEx(); addDescription(Msg.translate(getCtx(), "C_Order_ID")+": "+order.getDocumentNo()); orders.put(C_BPartner_ID, order); + msg = msg + Msg.translate(getCtx(), "C_Order_ID") + +" : "+ order.getDocumentNo() + +" - " + +Msg.translate(getCtx(),"C_BPartner_ID") + +" : "+vendor.getName()+" , "; } // // Create Order Line: - BigDecimal QtyOrdered = subcontract.getQty(); + BigDecimal QtyOrdered = getMovementQty().multiply(subcontract.getQty()); // Check Order Min if(product_po.getOrder_Min().signum() > 0) { @@ -930,6 +943,7 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction // TODO: Mark this as processed? setProcessed(true); } // each subcontracting line + return msg; } @Override diff --git a/base/src/org/eevolution/model/MPPOrder.java b/base/src/org/eevolution/model/MPPOrder.java index fbeae95324..d509395b4e 100644 --- a/base/src/org/eevolution/model/MPPOrder.java +++ b/base/src/org/eevolution/model/MPPOrder.java @@ -622,7 +622,6 @@ public class MPPOrder extends X_PP_Order implements DocAction ArrayList[][] issue = new ArrayList[m_lines.length][1]; Timestamp today = new Timestamp(System.currentTimeMillis()); - int row = 0; for (int i = 0; i < getLines().length ; i++) { MPPOrderBOMLine line = m_lines[i]; @@ -1250,7 +1249,7 @@ public class MPPOrder extends X_PP_Order implements DocAction for(int i = 0; i < issue.length; i++ ) { - KeyNamePair key = (KeyNamePair) issue[i][0].get(1); + KeyNamePair key = (KeyNamePair) issue[i][0].get(0); boolean isSelected = key.getName().equals("Y"); if (key == null || !isSelected) { diff --git a/base/src/org/eevolution/model/MPPOrderNode.java b/base/src/org/eevolution/model/MPPOrderNode.java index f09437bacb..2b32caec39 100644 --- a/base/src/org/eevolution/model/MPPOrderNode.java +++ b/base/src/org/eevolution/model/MPPOrderNode.java @@ -144,8 +144,8 @@ public class MPPOrderNode extends X_PP_Order_Node setAD_WF_Node_ID(wfNode.getAD_WF_Node_ID()); setAD_WF_Responsible_ID(wfNode.getAD_WF_Responsible_ID()); setAD_Workflow_ID(wfNode.getAD_Workflow_ID()); - this.setIsSubcontracting(wfNode.isSubcontracting()); - this.setC_BPartner_ID(wfNode.getC_BPartner_ID()); + setIsSubcontracting(wfNode.isSubcontracting()); + setC_BPartner_ID(wfNode.getC_BPartner_ID()); setCost(wfNode.getCost()); setDuration(wfNode.getDuration()); setEntityType(wfNode.getEntityType()); diff --git a/base/src/org/eevolution/model/MPPOrderNodeProduct.java b/base/src/org/eevolution/model/MPPOrderNodeProduct.java index dca2e9830a..df91d68de5 100644 --- a/base/src/org/eevolution/model/MPPOrderNodeProduct.java +++ b/base/src/org/eevolution/model/MPPOrderNodeProduct.java @@ -19,6 +19,10 @@ package org.eevolution.model; import java.sql.ResultSet; import java.util.Properties; +import org.adempiere.exceptions.AdempiereException; +import org.compiere.util.DB; +import org.compiere.util.Env; + /** * Order Node Product Model * @@ -62,4 +66,16 @@ public class MPPOrderNodeProduct extends X_PP_Order_Node_Product setPP_Order_Workflow_ID(PP_Order_Node.getPP_Order_Workflow_ID()); setPP_Order_Node_ID(PP_Order_Node.get_ID()); } + + @Override + protected boolean beforeSave(boolean newRecord) + { + if(getQty().equals(Env.ZERO) && isSubcontracting()) + { + setQty(Env.ONE); + } + + // + return true; + } } diff --git a/base/src/org/eevolution/model/MPPWFNodeProduct.java b/base/src/org/eevolution/model/MPPWFNodeProduct.java index 63294fe1e2..5f8405f493 100644 --- a/base/src/org/eevolution/model/MPPWFNodeProduct.java +++ b/base/src/org/eevolution/model/MPPWFNodeProduct.java @@ -23,6 +23,7 @@ import java.util.Properties; import org.compiere.model.Query; import org.compiere.util.CCache; import org.compiere.util.DB; +import org.compiere.util.Env; /** * Workflow Node Product Model @@ -83,9 +84,12 @@ public class MPPWFNodeProduct extends X_PP_WF_Node_Product int seqNo = DB.getSQLValueEx(get_TrxName(), sql, getAD_WF_Node_ID(), get_ID()); setSeqNo(seqNo); } + if(getQty().equals(Env.ZERO) && isSubcontracting()) + { + setQty(Env.ONE); + } + // return true; - } - - + } } // MPPWFNodeProduct