Implementing Subcontract Activity Control

http://sourceforge.net/tracker2/?func=detail&aid=2431672&group_id=176962&atid=879335

Fix issue to complete the receipt for sub contract
This commit is contained in:
vpj-cd 2009-01-14 18:02:31 +00:00
parent 7ca5ab994f
commit 25e60159ed
6 changed files with 53 additions and 23 deletions

View File

@ -221,10 +221,7 @@ public class LiberoValidator implements ModelValidator
cc.setDocStatus(docStatus); cc.setDocStatus(docStatus);
cc.setDocAction(MPPCostCollector.DOCACTION_Close); cc.setDocAction(MPPCostCollector.DOCACTION_Close);
cc.saveEx(); cc.saveEx();
return Msg.translate(po.getCtx(), "PP_Order_ID") return null;
+":"+cc.getPP_Order().getDocumentNo()
+Msg.translate(po.getCtx(),"PP_Order_Node_ID")
+":"+cc.getPP_Order_Node().getValue();
} }
} }
} }

View File

@ -204,17 +204,22 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
if (activity.isSubcontracting()) if (activity.isSubcontracting())
{ {
if(activity.getDocStatus().equals(MPPOrderNode.DOCSTATUS_InProgress) if(MPPOrderNode.DOCSTATUS_InProgress.equals(activity.getDocStatus())
&& getDocStatus().equals(MPPCostCollector.DOCSTATUS_InProgress)) && MPPCostCollector.DOCSTATUS_InProgress.equals(getDocStatus()))
{ {
return MPPOrderNode.DOCSTATUS_InProgress; return MPPOrderNode.DOCSTATUS_InProgress;
} }
else if(activity.getDocStatus().equals(MPPOrderNode.DOCSTATUS_InProgress) else if(MPPOrderNode.DOCSTATUS_InProgress.equals(activity.getDocStatus())
&& getDocStatus().equals(MPPCostCollector.DOCSTATUS_Drafted)) && MPPCostCollector.DOCSTATUS_Drafted.equals(getDocStatus()))
{ {
throw new ActivityProcessedException(activity); 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); activity.setDocStatus(DOCSTATUS_InProgress);
@ -436,7 +441,7 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
msg.append(oline.getParent().getDocumentNo()).append(","); msg.append(oline.getParent().getDocumentNo()).append(",");
} }
if(DocStatus.equals(MPPOrderNode.DOCSTATUS_InProgress)) if(MPPOrderNode.DOCSTATUS_InProgress.equals(DocStatus))
{ {
m_processMsg = msg.toString(); m_processMsg = msg.toString();
return DocStatus; return DocStatus;
@ -446,10 +451,11 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
setDocStatus(DOCSTATUS_Completed); setDocStatus(DOCSTATUS_Completed);
activity.setDocStatus(DOCSTATUS_Completed); activity.setDocStatus(DOCSTATUS_Completed);
activity.saveEx(); activity.saveEx();
m_processMsg = Msg.translate(getCtx(), "PP_Order_ID")
setDocAction(DOCACTION_Complete); +":"+ getPP_Order().getDocumentNo()
setDocStatus(DOCSTATUS_InProgress); +Msg.translate(getCtx(),"PP_Order_Node_ID")
return DOCSTATUS_InProgress; +":"+getPP_Order_Node().getValue();
return DocStatus;
} }
else else
{ {
@ -839,8 +845,9 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
* Create Purchase Order (in case of Subcontracting) * Create Purchase Order (in case of Subcontracting)
* @param activity * @param activity
*/ */
private void createPOrder(MPPOrderNode activity) private String createPO(MPPOrderNode activity)
{ {
String msg = "";
HashMap<Integer,MOrder> orders = new HashMap<Integer,MOrder>(); HashMap<Integer,MOrder> orders = new HashMap<Integer,MOrder>();
// //
String whereClause = MPPOrderNodeProduct.COLUMNNAME_PP_Order_Node_ID+"=?" 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()); order = new MOrder(getCtx(), 0, get_TrxName());
MBPartner vendor = MBPartner.get(getCtx(), C_BPartner_ID); MBPartner vendor = MBPartner.get(getCtx(), C_BPartner_ID);
order.setAD_Org_ID(getAD_Org_ID());
order.setBPartner(vendor); order.setBPartner(vendor);
order.setIsSOTrx(false); order.setIsSOTrx(false);
order.setC_DocTypeTarget_ID(); order.setC_DocTypeTarget_ID();
@ -903,10 +911,15 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
order.saveEx(); order.saveEx();
addDescription(Msg.translate(getCtx(), "C_Order_ID")+": "+order.getDocumentNo()); addDescription(Msg.translate(getCtx(), "C_Order_ID")+": "+order.getDocumentNo());
orders.put(C_BPartner_ID, order); 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: // Create Order Line:
BigDecimal QtyOrdered = subcontract.getQty(); BigDecimal QtyOrdered = getMovementQty().multiply(subcontract.getQty());
// Check Order Min // Check Order Min
if(product_po.getOrder_Min().signum() > 0) 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? // TODO: Mark this as processed?
setProcessed(true); setProcessed(true);
} // each subcontracting line } // each subcontracting line
return msg;
} }
@Override @Override

View File

@ -622,7 +622,6 @@ public class MPPOrder extends X_PP_Order implements DocAction
ArrayList[][] issue = new ArrayList[m_lines.length][1]; ArrayList[][] issue = new ArrayList[m_lines.length][1];
Timestamp today = new Timestamp(System.currentTimeMillis()); Timestamp today = new Timestamp(System.currentTimeMillis());
int row = 0;
for (int i = 0; i < getLines().length ; i++) for (int i = 0; i < getLines().length ; i++)
{ {
MPPOrderBOMLine line = m_lines[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++ ) 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"); boolean isSelected = key.getName().equals("Y");
if (key == null || !isSelected) if (key == null || !isSelected)
{ {

View File

@ -144,8 +144,8 @@ public class MPPOrderNode extends X_PP_Order_Node
setAD_WF_Node_ID(wfNode.getAD_WF_Node_ID()); setAD_WF_Node_ID(wfNode.getAD_WF_Node_ID());
setAD_WF_Responsible_ID(wfNode.getAD_WF_Responsible_ID()); setAD_WF_Responsible_ID(wfNode.getAD_WF_Responsible_ID());
setAD_Workflow_ID(wfNode.getAD_Workflow_ID()); setAD_Workflow_ID(wfNode.getAD_Workflow_ID());
this.setIsSubcontracting(wfNode.isSubcontracting()); setIsSubcontracting(wfNode.isSubcontracting());
this.setC_BPartner_ID(wfNode.getC_BPartner_ID()); setC_BPartner_ID(wfNode.getC_BPartner_ID());
setCost(wfNode.getCost()); setCost(wfNode.getCost());
setDuration(wfNode.getDuration()); setDuration(wfNode.getDuration());
setEntityType(wfNode.getEntityType()); setEntityType(wfNode.getEntityType());

View File

@ -19,6 +19,10 @@ package org.eevolution.model;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Properties; import java.util.Properties;
import org.adempiere.exceptions.AdempiereException;
import org.compiere.util.DB;
import org.compiere.util.Env;
/** /**
* Order Node Product Model * 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_Workflow_ID(PP_Order_Node.getPP_Order_Workflow_ID());
setPP_Order_Node_ID(PP_Order_Node.get_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;
}
} }

View File

@ -23,6 +23,7 @@ import java.util.Properties;
import org.compiere.model.Query; import org.compiere.model.Query;
import org.compiere.util.CCache; import org.compiere.util.CCache;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env;
/** /**
* Workflow Node Product Model * 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()); int seqNo = DB.getSQLValueEx(get_TrxName(), sql, getAD_WF_Node_ID(), get_ID());
setSeqNo(seqNo); setSeqNo(seqNo);
} }
if(getQty().equals(Env.ZERO) && isSubcontracting())
{
setQty(Env.ONE);
}
// //
return true; return true;
} }
} // MPPWFNodeProduct } // MPPWFNodeProduct