Libero QA assurance:
* move MForecastLine class to org.compiere.model * use getSQLValue*Ex instead of getSQLValue * code refactoring & cleanup * correct trxName usage * improved exception handling
This commit is contained in:
parent
fb473ceeea
commit
6476744416
|
@ -0,0 +1,62 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 2008 SC ARHIPAC SERVICE SRL. All Rights Reserved. *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* You should have received a copy of the GNU General Public License along *
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.adempiere.exceptions;
|
||||||
|
|
||||||
|
import org.compiere.model.MDocType;
|
||||||
|
import org.compiere.model.MRefList;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.Util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throwed when desired document type was not found
|
||||||
|
* @author Teo Sarca, www.arhipac.ro
|
||||||
|
*/
|
||||||
|
public class DocTypeNotFoundException extends AdempiereException
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** Doc Base Type */
|
||||||
|
private String m_docBaseType = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param docBaseType Document Base Type (see MDocType.DOCBASETYPE_*)
|
||||||
|
* @param additionalInfo optional if there is some additional info
|
||||||
|
*/
|
||||||
|
public DocTypeNotFoundException(String docBaseType, String additionalInfo)
|
||||||
|
{
|
||||||
|
super(additionalInfo);
|
||||||
|
m_docBaseType = docBaseType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDocBaseType()
|
||||||
|
{
|
||||||
|
return m_docBaseType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage()
|
||||||
|
{
|
||||||
|
String additionalInfo = super.getMessage();
|
||||||
|
String docBaseTypeName = MRefList.getListName(Env.getCtx(), MDocType.DOCBASETYPE_AD_Reference_ID, getDocBaseType());
|
||||||
|
StringBuffer sb = new StringBuffer("@NotFound@ @C_DocType_ID@");
|
||||||
|
sb.append(" - @DocBaseType@ : " + docBaseTypeName);
|
||||||
|
if (!Util.isEmpty(additionalInfo, true))
|
||||||
|
{
|
||||||
|
sb.append(" (").append(additionalInfo).append(")");
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* You should have received a copy of the GNU General Public License along *
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
|
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
||||||
|
* Contributor(s): Victor Perez www.e-evolution.com *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.compiere.model;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.eevolution.model.MPPMRP;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forecast Line Model
|
||||||
|
*
|
||||||
|
* @author Victor Perez www.e-evolution.com
|
||||||
|
* @version $Id: MForecastLine.java,v 1.11 2005/05/17 05:29:52 vpj-cd Exp $
|
||||||
|
*/
|
||||||
|
public class MForecastLine extends X_M_ForecastLine
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard Constructor
|
||||||
|
* @param ctx context
|
||||||
|
* @param M_ForecastLine_ID id
|
||||||
|
*/
|
||||||
|
public MForecastLine (Properties ctx, int M_ForecastLine_ID, String trxName)
|
||||||
|
{
|
||||||
|
super (ctx, M_ForecastLine_ID, trxName);
|
||||||
|
} // MForecastLine
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load Constructor
|
||||||
|
* @param ctx context
|
||||||
|
* @param rs result set
|
||||||
|
*/
|
||||||
|
public MForecastLine (Properties ctx, ResultSet rs, String trxName)
|
||||||
|
{
|
||||||
|
super(ctx, rs, trxName);
|
||||||
|
} // MRequisitionLine
|
||||||
|
|
||||||
|
/**
|
||||||
|
* After Save.
|
||||||
|
* Update Total on Header
|
||||||
|
* @param newRecord if new record
|
||||||
|
* @param success save was success
|
||||||
|
*/
|
||||||
|
protected boolean afterSave (boolean newRecord, boolean success)
|
||||||
|
{
|
||||||
|
if (!success)
|
||||||
|
return success;
|
||||||
|
//begin e-evolution vpj-cd 10/30/2004
|
||||||
|
MPPMRP.M_ForecastLine(this,false);
|
||||||
|
//end e-evolution vpj-cd 10/30/2004
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} // afterSave
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* After Delete
|
||||||
|
* @param success
|
||||||
|
* @return true/false
|
||||||
|
*/
|
||||||
|
protected boolean afterDelete (boolean success)
|
||||||
|
{
|
||||||
|
if (!success)
|
||||||
|
return success;
|
||||||
|
//begin e-evolution vpj-cd 10/30/2004
|
||||||
|
MPPMRP.M_ForecastLine(this,true);
|
||||||
|
//end e-evolution vpj-cd 10/30/2004
|
||||||
|
return true;
|
||||||
|
} // afterDelete
|
||||||
|
|
||||||
|
} // MForecastLine
|
|
@ -669,7 +669,7 @@ public class MWFNode extends X_AD_WF_Node
|
||||||
public BigDecimal getCostForCostElementType(String CostElementType, int C_AcctSchema_ID,int M_CostType_ID,int AD_Org_ID,int setuptime, int duration)
|
public BigDecimal getCostForCostElementType(String CostElementType, int C_AcctSchema_ID,int M_CostType_ID,int AD_Org_ID,int setuptime, int duration)
|
||||||
{
|
{
|
||||||
MResource resource = (MResource) getS_Resource();
|
MResource resource = (MResource) getS_Resource();
|
||||||
//get the rate and convert in second for this cost type element (Rsource, Burden)
|
//get the rate and convert in second for this cost type element (Resource, Burden)
|
||||||
MWorkflow workflow = getWorkflow();
|
MWorkflow workflow = getWorkflow();
|
||||||
double rate = resource.getResouceRate(C_AcctSchema_ID, M_CostType_ID,CostElementType, AD_Org_ID);
|
double rate = resource.getResouceRate(C_AcctSchema_ID, M_CostType_ID,CostElementType, AD_Org_ID);
|
||||||
BigDecimal cost = Env.ZERO;
|
BigDecimal cost = Env.ZERO;
|
||||||
|
@ -678,7 +678,7 @@ public class MWFNode extends X_AD_WF_Node
|
||||||
return Env.ZERO;
|
return Env.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
int C_UOM_ID = DB.getSQLValue(get_TrxName(),"SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? " , getS_Resource_ID());
|
int C_UOM_ID = DB.getSQLValueEx(get_TrxName(),"SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? " , getS_Resource_ID());
|
||||||
MUOM uom = MUOM.get(getCtx(), C_UOM_ID);
|
MUOM uom = MUOM.get(getCtx(), C_UOM_ID);
|
||||||
if (uom.isHour())
|
if (uom.isHour())
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 2008 SC ARHIPAC SERVICE SRL. All Rights Reserved. *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* You should have received a copy of the GNU General Public License along *
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.eevolution.exceptions;
|
||||||
|
|
||||||
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
|
import org.eevolution.model.MPPOrderNode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throwed when we are trying to process/complete an Order Activity that is already processed/completed
|
||||||
|
* @author Teo Sarca, www.arhipac.ro
|
||||||
|
*/
|
||||||
|
public class ActivityProcessedException extends AdempiereException
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public ActivityProcessedException(MPPOrderNode activity)
|
||||||
|
{
|
||||||
|
super("Order Activity Already Processed - "+activity); // TODO: translate
|
||||||
|
}
|
||||||
|
}
|
|
@ -138,10 +138,10 @@ public class CalloutOrder extends CalloutEngine
|
||||||
if (QtyBatchSize.equals(Env.ZERO))
|
if (QtyBatchSize.equals(Env.ZERO))
|
||||||
Qty = Env.ONE;
|
Qty = Env.ONE;
|
||||||
else
|
else
|
||||||
Qty = p_QtyEntered.divide(QtyBatchSize , 0, BigDecimal.ROUND_UP);
|
Qty = p_QtyEntered.divide(QtyBatchSize, 0, RoundingMode.UP);
|
||||||
|
|
||||||
mTab.setValue(MPPOrder.COLUMNNAME_QtyBatchs, Qty);
|
mTab.setValue(MPPOrder.COLUMNNAME_QtyBatchs, Qty);
|
||||||
mTab.setValue(MPPOrder.COLUMNNAME_QtyBatchSize, p_QtyEntered.divide(Qty , BigDecimal.ROUND_HALF_UP));
|
mTab.setValue(MPPOrder.COLUMNNAME_QtyBatchSize, QtyBatchSize);
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,12 +12,14 @@
|
||||||
* For the text or an alternative of this public license, you may reach us *
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
||||||
* Contributor(s): Victor Perez www.e-evolution.com *
|
* Contributor(s): Victor Perez www.e-evolution.com *
|
||||||
|
* Teo Sarca, www.arhipac.ro *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.eevolution.model;
|
package org.eevolution.model;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.compiere.model.MClient;
|
import org.compiere.model.MClient;
|
||||||
|
import org.compiere.model.MForecastLine;
|
||||||
import org.compiere.model.MInOut;
|
import org.compiere.model.MInOut;
|
||||||
import org.compiere.model.MInOutLine;
|
import org.compiere.model.MInOutLine;
|
||||||
import org.compiere.model.MOrder;
|
import org.compiere.model.MOrder;
|
||||||
|
@ -27,30 +29,21 @@ import org.compiere.model.ModelValidationEngine;
|
||||||
import org.compiere.model.ModelValidator;
|
import org.compiere.model.ModelValidator;
|
||||||
import org.compiere.model.PO;
|
import org.compiere.model.PO;
|
||||||
import org.compiere.model.Query;
|
import org.compiere.model.Query;
|
||||||
|
import org.compiere.process.DocAction;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LiberoValidator
|
* Libero Validator
|
||||||
*
|
*
|
||||||
* @author Victor Perez
|
* @author Victor Perez
|
||||||
* @author Trifon Trifonov
|
* @author Trifon Trifonov
|
||||||
* <li>[ 2270421 ] Can not complete Shipment (Customer)</li>
|
* <li>[ 2270421 ] Can not complete Shipment (Customer)</li>
|
||||||
*
|
* @author Teo Sarca, www.arhipac.ro
|
||||||
* @version $Id: LiberoValidator.java,v 1 vpj-cd Exp $
|
|
||||||
*/
|
*/
|
||||||
public class LiberoValidator implements ModelValidator
|
public class LiberoValidator implements ModelValidator
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
* The class is instantiated when logging in and client is selected/known
|
|
||||||
*/
|
|
||||||
public LiberoValidator ()
|
|
||||||
{
|
|
||||||
super ();
|
|
||||||
} // LiberoValidator
|
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private CLogger log = CLogger.getCLogger(getClass());
|
private CLogger log = CLogger.getCLogger(getClass());
|
||||||
/** Client */
|
/** Client */
|
||||||
|
@ -60,10 +53,13 @@ public class LiberoValidator implements ModelValidator
|
||||||
public void initialize (ModelValidationEngine engine, MClient client)
|
public void initialize (ModelValidationEngine engine, MClient client)
|
||||||
{
|
{
|
||||||
//client = null for global validator
|
//client = null for global validator
|
||||||
if (client != null) {
|
if (client != null)
|
||||||
|
{
|
||||||
m_AD_Client_ID = client.getAD_Client_ID();
|
m_AD_Client_ID = client.getAD_Client_ID();
|
||||||
log.info(client.toString());
|
log.info(client.toString());
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
log.info("Initializing global validator: "+this.toString());
|
log.info("Initializing global validator: "+this.toString());
|
||||||
}
|
}
|
||||||
// Tables to be monitored
|
// Tables to be monitored
|
||||||
|
@ -80,217 +76,130 @@ public class LiberoValidator implements ModelValidator
|
||||||
public String modelChange (PO po, int type) throws Exception
|
public String modelChange (PO po, int type) throws Exception
|
||||||
{
|
{
|
||||||
log.info(po.get_TableName() + " Type: "+type);
|
log.info(po.get_TableName() + " Type: "+type);
|
||||||
|
boolean isChange = (TYPE_AFTER_NEW == type || (TYPE_AFTER_CHANGE == type && MPPMRP.isChanged(po)));
|
||||||
if (po.get_TableName().equals(MOrder.Table_Name))
|
boolean isDelete = (TYPE_BEFORE_DELETE == type);
|
||||||
|
boolean isCompleted = false;
|
||||||
|
boolean isVoided = false;
|
||||||
|
DocAction doc = null;
|
||||||
|
if (po instanceof DocAction)
|
||||||
|
{
|
||||||
|
doc = (DocAction)po;
|
||||||
|
}
|
||||||
|
else if (po instanceof MOrderLine)
|
||||||
|
{
|
||||||
|
doc = ((MOrderLine)po).getParent();
|
||||||
|
}
|
||||||
|
if (doc != null)
|
||||||
|
{
|
||||||
|
String docStatus = doc.getDocStatus();
|
||||||
|
isCompleted = DocAction.STATUS_InProgress.equals(docStatus)
|
||||||
|
|| DocAction.STATUS_Completed.equals(docStatus);
|
||||||
|
isVoided = DocAction.STATUS_Voided.equals(docStatus);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
if (isDelete || isVoided)
|
||||||
|
{
|
||||||
|
MPPMRP.deleteMRP(po);
|
||||||
|
}
|
||||||
|
else if (po instanceof MOrder)
|
||||||
{
|
{
|
||||||
MOrder order = (MOrder)po;
|
MOrder order = (MOrder)po;
|
||||||
//Create a planning supply when isPurchase Order
|
// Create/Update a planning supply when isPurchase Order
|
||||||
if (type == TYPE_AFTER_NEW && !order.isSOTrx())
|
// or when you change DatePromised or DocStatus and is Purchase Order
|
||||||
|
if (isChange && !order.isSOTrx())
|
||||||
{
|
{
|
||||||
MPPMRP.C_Order(order, false);
|
MPPMRP.C_Order(order, false);
|
||||||
}
|
}
|
||||||
//Update MRP when you change DatePromised or DocStatus and is Purchase Order
|
// Update MRP when you change the status order to complete or in process for a sales order
|
||||||
else if (type == TYPE_AFTER_CHANGE && !order.isSOTrx())
|
// or you change DatePromised
|
||||||
|
else if (type == TYPE_AFTER_CHANGE && order.isSOTrx())
|
||||||
{
|
{
|
||||||
if ( order.is_ValueChanged(MOrder.COLUMNNAME_DatePromised)
|
if (isCompleted || MPPMRP.isChanged(order))
|
||||||
|| order.is_ValueChanged(MOrder.COLUMNNAME_DocStatus))
|
|
||||||
MPPMRP.C_Order(order, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Update MRP when you change the status order to complete or in process for a sales order or you change DatePromised
|
|
||||||
if (type == TYPE_AFTER_CHANGE && order.isSOTrx())
|
|
||||||
{
|
|
||||||
if ( order.is_ValueChanged(MOrder.COLUMNNAME_DatePromised)
|
|
||||||
|| order.is_ValueChanged(MOrder.COLUMNNAME_DocStatus)
|
|
||||||
|| order.getDocStatus().equals(MOrder.DOCSTATUS_InProgress)
|
|
||||||
|| order.getDocStatus().equals(MOrder.DOCSTATUS_Completed))
|
|
||||||
{
|
{
|
||||||
MPPMRP.C_Order(order, false);
|
MPPMRP.C_Order(order, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
if (po.get_TableName().equals(MOrderLine.Table_Name))
|
else if (po instanceof MOrderLine && isChange)
|
||||||
{
|
{
|
||||||
MOrderLine ol = (MOrderLine)po;
|
MOrderLine ol = (MOrderLine)po;
|
||||||
MOrder order = ol.getParent();
|
MOrder order = ol.getParent();
|
||||||
//Create a planning supply when isPurchase Order
|
// Create/Update a planning supply when isPurchase Order or you change relevant fields
|
||||||
if (type == TYPE_AFTER_NEW && !order.isSOTrx())
|
if (!order.isSOTrx())
|
||||||
|
{
|
||||||
|
MPPMRP.C_OrderLine(ol, false);
|
||||||
|
}
|
||||||
|
// Update MRP when Sales Order have document status in process or complete and
|
||||||
|
// you change relevant fields
|
||||||
|
else if(order.isSOTrx() && isCompleted)
|
||||||
{
|
{
|
||||||
MPPMRP.C_OrderLine(ol, false);
|
MPPMRP.C_OrderLine(ol, false);
|
||||||
//Update MRP when when isPurchase Order and you change DatePromised , Product , Qty Ordered, Qty Delivered
|
|
||||||
} else if (type == TYPE_AFTER_CHANGE && !order.isSOTrx()) {
|
|
||||||
if ( ol.is_ValueChanged(MOrderLine.COLUMNNAME_DatePromised)
|
|
||||||
|| ol.is_ValueChanged(MOrderLine.COLUMNNAME_M_Product_ID)
|
|
||||||
|| ol.is_ValueChanged(MOrderLine.COLUMNNAME_QtyOrdered)
|
|
||||||
|| ol.is_ValueChanged(MOrderLine.COLUMNNAME_QtyDelivered)
|
|
||||||
)
|
|
||||||
MPPMRP.C_OrderLine(ol, false);
|
|
||||||
//Update MRP when Sales Order have document status in process or complete
|
|
||||||
//You change DatePromised , Product , Qty Ordered, Qty Delivered
|
|
||||||
} else if(type == TYPE_AFTER_CHANGE && order.isSOTrx()) {
|
|
||||||
if ( order.getDocStatus().equals(MOrder.DOCSTATUS_InProgress)
|
|
||||||
|| order.getDocStatus().equals(MOrder.DOCSTATUS_Completed))
|
|
||||||
{
|
|
||||||
if ( ol.is_ValueChanged(MOrderLine.COLUMNNAME_DatePromised)
|
|
||||||
|| ol.is_ValueChanged(MOrderLine.COLUMNNAME_M_Product_ID)
|
|
||||||
|| ol.is_ValueChanged(MOrderLine.COLUMNNAME_QtyOrdered)
|
|
||||||
|| ol.is_ValueChanged(MOrderLine.COLUMNNAME_QtyDelivered)
|
|
||||||
)
|
|
||||||
MPPMRP.C_OrderLine(ol, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//
|
||||||
if (po.get_TableName().equals(MOrderLine.Table_Name) && type == TYPE_BEFORE_DELETE)
|
else if (po instanceof MRequisitionLine && isChange)
|
||||||
{
|
|
||||||
MOrderLine ol = (MOrderLine)po;
|
|
||||||
MPPMRP.C_OrderLine(ol, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (po.get_TableName().equals(MRequisitionLine.Table_Name) )
|
|
||||||
{
|
{
|
||||||
MRequisitionLine rl = (MRequisitionLine)po;
|
MRequisitionLine rl = (MRequisitionLine)po;
|
||||||
if (type == TYPE_AFTER_NEW)
|
MPPMRP.M_RequisitionLine(rl, false);
|
||||||
{
|
|
||||||
MPPMRP.M_RequisitionLine(rl, false);
|
|
||||||
}
|
|
||||||
if (type == TYPE_AFTER_CHANGE)
|
|
||||||
{
|
|
||||||
if ( rl.is_ValueChanged(MRequisitionLine.COLUMNNAME_M_Product_ID)
|
|
||||||
|| rl.is_ValueChanged(MRequisitionLine.COLUMNNAME_Qty))
|
|
||||||
MPPMRP.M_RequisitionLine(rl, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
//
|
||||||
if (po.get_TableName().equals(MRequisitionLine.Table_Name) && type == TYPE_BEFORE_DELETE )
|
else if (po instanceof MForecastLine && isChange)
|
||||||
{
|
|
||||||
MRequisitionLine ol = (MRequisitionLine)po;
|
|
||||||
MPPMRP.M_RequisitionLine(ol, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (po.get_TableName().equals(MForecastLine.Table_Name))
|
|
||||||
{
|
{
|
||||||
MForecastLine fl = (MForecastLine)po;
|
MForecastLine fl = (MForecastLine)po;
|
||||||
if(type == TYPE_AFTER_NEW)
|
MPPMRP.M_ForecastLine(fl, false);
|
||||||
MPPMRP.M_ForecastLine(fl, false);
|
|
||||||
if (type == TYPE_AFTER_CHANGE)
|
|
||||||
{
|
|
||||||
if ( fl.is_ValueChanged(MForecastLine.COLUMNNAME_M_Product_ID)
|
|
||||||
|| fl.is_ValueChanged(MForecastLine.COLUMNNAME_Qty)
|
|
||||||
|| fl.is_ValueChanged(MForecastLine.COLUMNNAME_DatePromised)
|
|
||||||
)
|
|
||||||
MPPMRP.M_ForecastLine(fl, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
//
|
||||||
if (po.get_TableName().equals(MForecastLine.Table_Name) && type == TYPE_BEFORE_DELETE)
|
else if (po instanceof MDDOrderLine && isChange)
|
||||||
{
|
|
||||||
MForecastLine ol = (MForecastLine)po;
|
|
||||||
MPPMRP.M_ForecastLine(ol, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (po.get_TableName().equals(MDDOrderLine.Table_Name))
|
|
||||||
{
|
{
|
||||||
MDDOrderLine ol = (MDDOrderLine)po;
|
MDDOrderLine ol = (MDDOrderLine)po;
|
||||||
if (type == TYPE_AFTER_NEW)
|
MPPMRP.DD_Order_Line(ol , false);
|
||||||
{
|
|
||||||
MPPMRP.DD_Order_Line(ol , false);
|
|
||||||
}
|
|
||||||
if (type == TYPE_AFTER_CHANGE) {
|
|
||||||
if ( ol.is_ValueChanged(MDDOrderLine.COLUMNNAME_M_Product_ID)
|
|
||||||
|| ol.is_ValueChanged(MDDOrderLine.COLUMNNAME_DatePromised)
|
|
||||||
|| ol.is_ValueChanged(MDDOrderLine.COLUMNNAME_QtyOrdered)
|
|
||||||
|| ol.is_ValueChanged(MDDOrderLine.COLUMNNAME_QtyDelivered)
|
|
||||||
|| ol.is_ValueChanged(MDDOrderLine.COLUMNNAME_ConfirmedQty)
|
|
||||||
|| ol.is_ValueChanged(MDDOrderLine.COLUMNNAME_M_Locator_ID)
|
|
||||||
|| ol.is_ValueChanged(MDDOrderLine.COLUMNNAME_M_LocatorTo_ID)
|
|
||||||
|| ol.is_ValueChanged(MDDOrderLine.COLUMNNAME_ConfirmedQty))
|
|
||||||
MPPMRP.DD_Order_Line(ol, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
//
|
||||||
if (po.get_TableName().equals(MDDOrderLine.Table_Name) && type == TYPE_BEFORE_DELETE)
|
else if (po instanceof MPPOrder && isChange)
|
||||||
{
|
|
||||||
|
|
||||||
MDDOrderLine ol = (MDDOrderLine)po;
|
|
||||||
MPPMRP.DD_Order_Line(ol, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (po.get_TableName().equals(MPPOrder.Table_Name))
|
|
||||||
{
|
{
|
||||||
MPPOrder order = (MPPOrder)po;
|
MPPOrder order = (MPPOrder)po;
|
||||||
if (type == TYPE_AFTER_NEW) {
|
MPPMRP.PP_Order(order, false);
|
||||||
MPPMRP.PP_Order(order, false);
|
|
||||||
}
|
|
||||||
if (type == TYPE_AFTER_CHANGE) {
|
|
||||||
if ( order.is_ValueChanged(MPPOrder.COLUMNNAME_M_Product_ID)
|
|
||||||
|| order.is_ValueChanged(MPPOrder.COLUMNNAME_DatePromised)
|
|
||||||
|| order.is_ValueChanged(MPPOrder.COLUMNNAME_QtyOrdered)
|
|
||||||
|| order.is_ValueChanged(MPPOrder.COLUMNNAME_QtyDelivered)
|
|
||||||
|| order.is_ValueChanged(MPPOrder.COLUMNNAME_PP_Product_BOM_ID)
|
|
||||||
|| order.is_ValueChanged(MPPOrder.COLUMNNAME_AD_Workflow_ID))
|
|
||||||
MPPMRP.PP_Order(order, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
//
|
||||||
if (po.get_TableName().equals(MPPOrder.Table_Name) && type == TYPE_BEFORE_DELETE)
|
else if (po instanceof MPPOrderBOMLine && isChange)
|
||||||
{
|
{
|
||||||
MPPOrder order = (MPPOrder)po;
|
MPPOrderBOMLine obl = (MPPOrderBOMLine)po;
|
||||||
MPPMRP.PP_Order(order, true);
|
MPPMRP.PP_Order_BOMLine(obl, false);
|
||||||
}
|
}
|
||||||
|
//
|
||||||
if (po.get_TableName().equals(MPPOrderBOMLine.Table_Name))
|
|
||||||
{
|
|
||||||
MPPOrderBOMLine ol = (MPPOrderBOMLine)po;
|
|
||||||
if (type == TYPE_AFTER_NEW) {
|
|
||||||
MPPMRP.PP_Order_BOMLine(ol, false);
|
|
||||||
}
|
|
||||||
if (type == TYPE_AFTER_CHANGE) {
|
|
||||||
if ( ol.is_ValueChanged(MPPOrderBOMLine.COLUMNNAME_M_Product_ID)
|
|
||||||
|| ol.is_ValueChanged(MPPOrderBOMLine.COLUMNNAME_M_Warehouse_ID)
|
|
||||||
|| ol.is_ValueChanged(MPPOrderBOMLine.COLUMNNAME_QtyEntered)
|
|
||||||
|| ol.is_ValueChanged(MPPOrderBOMLine.COLUMNNAME_QtyDelivered))
|
|
||||||
MPPMRP.PP_Order_BOMLine(ol, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (po.get_TableName().equals(MPPOrderBOMLine.Table_Name) && type == TYPE_BEFORE_DELETE)
|
|
||||||
{
|
|
||||||
MPPOrderBOMLine ol = (MPPOrderBOMLine)po;
|
|
||||||
MPPMRP.PP_Order_BOMLine(ol, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
} // modelChange
|
} // modelChange
|
||||||
|
|
||||||
public String docValidate (PO po, int timing)
|
public String docValidate (PO po, int timing)
|
||||||
{
|
{
|
||||||
log.info(po.get_TableName() + " Timing: "+timing);
|
log.info(po.get_TableName() + " Timing: "+timing);
|
||||||
if (po.get_TableName().equals(MInOut.Table_Name) && timing == TIMING_AFTER_COMPLETE)
|
if (po instanceof MInOut && timing == TIMING_AFTER_COMPLETE)
|
||||||
{
|
{
|
||||||
MInOut inout = (MInOut)po;
|
MInOut inout = (MInOut)po;
|
||||||
for (MInOutLine line : inout.getLines())
|
for (MInOutLine line : inout.getLines())
|
||||||
{
|
{
|
||||||
String whereClause = "C_OrderLine_ID=? AND PP_Cost_Collector_ID IS NOT NULL";
|
String whereClause = "C_OrderLine_ID=? AND PP_Cost_Collector_ID IS NOT NULL";
|
||||||
Collection<MOrderLine> olines = new Query(po.getCtx(), MOrderLine.Table_Name, whereClause, po.get_TrxName())
|
Collection<MOrderLine> olines = new Query(po.getCtx(), MOrderLine.Table_Name, whereClause, po.get_TrxName())
|
||||||
.setParameters(new Object[]{line.getC_OrderLine_ID()}).list();
|
.setParameters(new Object[]{line.getC_OrderLine_ID()})
|
||||||
|
.list();
|
||||||
for (MOrderLine oline: olines)
|
for (MOrderLine oline : olines)
|
||||||
{
|
{
|
||||||
if(oline.getQtyOrdered().compareTo(oline.getQtyDelivered()) >= 0)
|
if(oline.getQtyOrdered().compareTo(oline.getQtyDelivered()) >= 0)
|
||||||
{
|
{
|
||||||
MPPCostCollector cc = new MPPCostCollector(po.getCtx(), oline.getPP_Cost_Collector_ID(), po.get_TrxName());
|
MPPCostCollector cc = new MPPCostCollector(po.getCtx(), oline.getPP_Cost_Collector_ID(), po.get_TrxName());
|
||||||
cc.completeIt();
|
String docStatus = cc.completeIt();
|
||||||
cc.setDocStatus(MPPCostCollector.DOCSTATUS_Completed);
|
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")+":"+cc.getPPOrder().getDocumentNo()+Msg.translate(po.getCtx(),"PP_Order_Node_ID")+":"+cc.getPPOrderNode().getValue();
|
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;
|
return null;
|
||||||
|
|
|
@ -72,13 +72,14 @@ public class MHREmployee extends X_HR_Employee //--
|
||||||
whereClause.append(" AND e.IsActive=? ");
|
whereClause.append(" AND e.IsActive=? ");
|
||||||
params.add(true);
|
params.add(true);
|
||||||
|
|
||||||
|
// This payroll not content periods, NOT IS a Regular Payroll > ogi-cd 28Nov2007
|
||||||
if(p.getHR_Payroll_ID() != 0 && p.getHR_Period_ID() != 0) // this payroll not content periods, NOT IS a Regular Payroll > ogi-cd 28Nov2007
|
if(p.getHR_Payroll_ID() != 0 && p.getHR_Period_ID() != 0)
|
||||||
{
|
{
|
||||||
whereClause.append(" AND (e.HR_Payroll_ID IS NULL OR e.HR_Payroll_ID=?) " );
|
whereClause.append(" AND (e.HR_Payroll_ID IS NULL OR e.HR_Payroll_ID=?) " );
|
||||||
params.add(p.getHR_Payroll_ID());
|
params.add(p.getHR_Payroll_ID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HR Period
|
||||||
if(p.getHR_Period_ID() != 0)
|
if(p.getHR_Period_ID() != 0)
|
||||||
{
|
{
|
||||||
whereClause.append(" AND e.StartDate <=? ");
|
whereClause.append(" AND e.StartDate <=? ");
|
||||||
|
@ -90,7 +91,8 @@ public class MHREmployee extends X_HR_Employee //--
|
||||||
params.add(p.getDateAcct());
|
params.add(p.getDateAcct());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p.getHR_Department_ID() != 0) // Selected Department
|
// Selected Department
|
||||||
|
if (p.getHR_Department_ID() != 0)
|
||||||
{
|
{
|
||||||
whereClause.append(" AND e.HR_Department_ID =? ");
|
whereClause.append(" AND e.HR_Department_ID =? ");
|
||||||
params.add(p.getHR_Department_ID());
|
params.add(p.getHR_Department_ID());
|
||||||
|
@ -98,7 +100,8 @@ public class MHREmployee extends X_HR_Employee //--
|
||||||
|
|
||||||
whereClause.append(" ) "); // end select from HR_Employee
|
whereClause.append(" ) "); // end select from HR_Employee
|
||||||
|
|
||||||
if (p.getC_BPartner_ID() != 0 ) // Selected Employee
|
// Selected Employee
|
||||||
|
if (p.getC_BPartner_ID() != 0)
|
||||||
{
|
{
|
||||||
whereClause.append(" AND C_BPartner_ID =? ");
|
whereClause.append(" AND C_BPartner_ID =? ");
|
||||||
params.add(p.getC_BPartner_ID());
|
params.add(p.getC_BPartner_ID());
|
||||||
|
|
|
@ -18,24 +18,25 @@ package org.eevolution.model;
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.adempiere.exceptions.AdempiereException;
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
import org.compiere.Adempiere;
|
import org.adempiere.exceptions.DocTypeNotFoundException;
|
||||||
import org.compiere.acct.Doc;
|
import org.adempiere.exceptions.FillMandatoryException;
|
||||||
import org.compiere.model.MAcctSchema;
|
import org.adempiere.exceptions.NoVendorForProductException;
|
||||||
|
import org.compiere.model.I_C_UOM;
|
||||||
|
import org.compiere.model.I_M_Product;
|
||||||
import org.compiere.model.MAttributeSetInstance;
|
import org.compiere.model.MAttributeSetInstance;
|
||||||
import org.compiere.model.MBPartner;
|
import org.compiere.model.MBPartner;
|
||||||
import org.compiere.model.MClient;
|
import org.compiere.model.MClient;
|
||||||
import org.compiere.model.MDocType;
|
import org.compiere.model.MDocType;
|
||||||
|
import org.compiere.model.MLocator;
|
||||||
import org.compiere.model.MOrder;
|
import org.compiere.model.MOrder;
|
||||||
import org.compiere.model.MOrderLine;
|
import org.compiere.model.MOrderLine;
|
||||||
import org.compiere.model.MPeriod;
|
import org.compiere.model.MPeriod;
|
||||||
|
@ -43,19 +44,19 @@ import org.compiere.model.MProduct;
|
||||||
import org.compiere.model.MProductPO;
|
import org.compiere.model.MProductPO;
|
||||||
import org.compiere.model.MStorage;
|
import org.compiere.model.MStorage;
|
||||||
import org.compiere.model.MTransaction;
|
import org.compiere.model.MTransaction;
|
||||||
|
import org.compiere.model.MUOM;
|
||||||
|
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;
|
||||||
import org.compiere.model.Query;
|
import org.compiere.model.Query;
|
||||||
import org.compiere.print.ReportEngine;
|
import org.compiere.print.ReportEngine;
|
||||||
import org.compiere.process.DocAction;
|
import org.compiere.process.DocAction;
|
||||||
import org.compiere.process.DocumentEngine;
|
import org.compiere.process.DocumentEngine;
|
||||||
import org.compiere.util.CCache;
|
|
||||||
import org.compiere.util.CLogMgt;
|
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Ini;
|
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
import org.compiere.util.TimeUtil;
|
import org.compiere.util.TimeUtil;
|
||||||
|
import org.eevolution.exceptions.ActivityProcessedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PP Cost Collector Model
|
* PP Cost Collector Model
|
||||||
|
@ -79,10 +80,13 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
super (ctx, PP_Cost_Collector_ID,trxName);
|
super (ctx, PP_Cost_Collector_ID,trxName);
|
||||||
if (PP_Cost_Collector_ID == 0)
|
if (PP_Cost_Collector_ID == 0)
|
||||||
{
|
{
|
||||||
setDocAction (DOCACTION_Complete); // CO
|
setC_DocType_ID(0);
|
||||||
setDocStatus (DOCSTATUS_Drafted); // DR
|
setDocStatus (DOCSTATUS_Drafted); // DR
|
||||||
|
setDocAction (DOCACTION_Complete); // CO
|
||||||
setMovementDate (new Timestamp(System.currentTimeMillis())); // @#Date@
|
setMovementDate (new Timestamp(System.currentTimeMillis())); // @#Date@
|
||||||
|
setIsActive(true);
|
||||||
setPosted (false);
|
setPosted (false);
|
||||||
|
setProcessing (false);
|
||||||
setProcessed (false);
|
setProcessed (false);
|
||||||
}
|
}
|
||||||
} // MPPCostCollector
|
} // MPPCostCollector
|
||||||
|
@ -111,6 +115,20 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
setDescription(desc + " | " + description);
|
setDescription(desc + " | " + description);
|
||||||
} // addDescription
|
} // addDescription
|
||||||
|
|
||||||
|
|
||||||
|
public void setC_DocTypeTarget_ID(String docBaseType)
|
||||||
|
{
|
||||||
|
MDocType[] doc = MDocType.getOfDocBaseType(getCtx(), docBaseType);
|
||||||
|
if(doc == null)
|
||||||
|
{
|
||||||
|
throw new DocTypeNotFoundException(docBaseType, "");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setC_DocTypeTarget_ID(doc[0].get_ID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
public void setProcessed (boolean processed)
|
public void setProcessed (boolean processed)
|
||||||
{
|
{
|
||||||
|
@ -178,23 +196,23 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
// Operation Activity
|
// Operation Activity
|
||||||
if(isCostCollectorType(COSTCOLLECTORTYPE_ActivityControl))
|
if(isCostCollectorType(COSTCOLLECTORTYPE_ActivityControl))
|
||||||
{
|
{
|
||||||
MPPOrderNode activity = getPPOrderNode();
|
MPPOrderNode activity = getPP_Order_Node();
|
||||||
if(activity.getDocStatus().equals(MPPOrderNode.DOCACTION_Complete))
|
if(MPPOrderNode.DOCACTION_Complete.equals(activity.getDocStatus()))
|
||||||
{
|
{
|
||||||
m_processMsg = "Activity was completed before";
|
throw new ActivityProcessedException(activity);
|
||||||
return DocAction.STATUS_Invalid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activity.isSubcontracting())
|
if (activity.isSubcontracting())
|
||||||
{
|
{
|
||||||
if(activity.getDocStatus().equals(MPPOrderNode.DOCSTATUS_InProgress) && getDocStatus().equals(MPPCostCollector.DOCSTATUS_InProgress))
|
if(activity.getDocStatus().equals(MPPOrderNode.DOCSTATUS_InProgress)
|
||||||
|
&& getDocStatus().equals(MPPCostCollector.DOCSTATUS_InProgress))
|
||||||
{
|
{
|
||||||
return MPPOrderNode.DOCSTATUS_InProgress;
|
return MPPOrderNode.DOCSTATUS_InProgress;
|
||||||
}
|
}
|
||||||
else if(activity.getDocStatus().equals(MPPOrderNode.DOCSTATUS_InProgress) && getDocStatus().equals(MPPCostCollector.DOCSTATUS_Drafted))
|
else if(activity.getDocStatus().equals(MPPOrderNode.DOCSTATUS_InProgress)
|
||||||
|
&& getDocStatus().equals(MPPCostCollector.DOCSTATUS_Drafted))
|
||||||
{
|
{
|
||||||
m_processMsg = "Activity was processed before";
|
throw new ActivityProcessedException(activity);
|
||||||
return DocAction.STATUS_Invalid;
|
|
||||||
}
|
}
|
||||||
createPOrder(activity);
|
createPOrder(activity);
|
||||||
}
|
}
|
||||||
|
@ -209,11 +227,11 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
|
|
||||||
if (MPPOrderNode.isLastNode(getCtx(), getPP_Order_Node_ID(), get_TrxName()))
|
if (MPPOrderNode.isLastNode(getCtx(), getPP_Order_Node_ID(), get_TrxName()))
|
||||||
{
|
{
|
||||||
String whereClause ="AND PP_Order_ID=? AND PP_Order_Node_ID<>?"
|
final String whereClause ="PP_Order_ID=? AND PP_Order_Node_ID<>?"
|
||||||
+" AND NOT EXISTS (SELECT 1 FROM PP_Cost_Collector cc "
|
+" 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)";
|
+" 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, this.get_TrxName())
|
List<MPPOrderNode> nodes = new Query(getCtx(), MPPOrderNode.Table_Name, whereClause, get_TrxName())
|
||||||
.setParameters(new Object[]{getPP_Order_ID(),getPP_Order_Node_ID()})
|
.setParameters(new Object[]{getPP_Order_ID(),getPP_Order_Node_ID()})
|
||||||
.setOnlyActiveRecords(true)
|
.setOnlyActiveRecords(true)
|
||||||
.list();
|
.list();
|
||||||
|
@ -226,10 +244,7 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
|
|
||||||
|
|
||||||
m_justPrepared = true;
|
m_justPrepared = true;
|
||||||
if (!DOCACTION_Complete.equals(getDocAction()))
|
setDocAction(DOCACTION_Complete);
|
||||||
{
|
|
||||||
setDocAction(DOCACTION_Complete);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE);
|
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE);
|
||||||
if (m_processMsg != null)
|
if (m_processMsg != null)
|
||||||
|
@ -296,7 +311,7 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
// Only for Production Issue records
|
// Only for Production Issue records
|
||||||
if (isIssue())
|
if (isIssue())
|
||||||
{
|
{
|
||||||
checkMaterialPolicy(getPPOrderBOMLine(), getMovementQty());
|
checkMaterialPolicy(getPP_Order_BOMLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
log.fine("Material Transaction");
|
log.fine("Material Transaction");
|
||||||
|
@ -324,8 +339,7 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
ma.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
|
ma.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
|
||||||
QtyMA, QtyIssue, QtyReceipt, get_TrxName()))
|
QtyMA, QtyIssue, QtyReceipt, get_TrxName()))
|
||||||
{
|
{
|
||||||
m_processMsg = "Cannot correct Inventory (MA)";
|
throw new AdempiereException(); //Cannot correct Inventory (MA)
|
||||||
return DocAction.STATUS_Invalid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create Transaction
|
// Create Transaction
|
||||||
|
@ -348,8 +362,7 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
|
getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
|
||||||
Qty, QtyIssue, QtyReceipt, get_TrxName()))
|
Qty, QtyIssue, QtyReceipt, get_TrxName()))
|
||||||
{
|
{
|
||||||
m_processMsg = "Cannot correct Inventory";
|
throw new AdempiereException(); // Cannot correct Inventory;
|
||||||
return DocAction.STATUS_Invalid;
|
|
||||||
}
|
}
|
||||||
// FallBack: Create Transaction
|
// FallBack: Create Transaction
|
||||||
|
|
||||||
|
@ -367,56 +380,61 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
if (isIssue())
|
if (isIssue())
|
||||||
{
|
{
|
||||||
// Update PP Order Line
|
// Update PP Order Line
|
||||||
MPPOrderBOMLine obomline = getPPOrderBOMLine();
|
MPPOrderBOMLine obomline = getPP_Order_BOMLine();
|
||||||
if (obomline != null)
|
obomline.setQtyDelivered(obomline.getQtyDelivered().add(getMovementQty()));
|
||||||
{
|
obomline.setQtyScrap(obomline.getQtyScrap().add(getScrappedQty()));
|
||||||
obomline.setQtyDelivered(obomline.getQtyDelivered().add(getMovementQty()));
|
obomline.setQtyReject(obomline.getQtyReject().add(getQtyReject()));
|
||||||
obomline.setQtyScrap(obomline.getQtyScrap().add(getScrappedQty()));
|
obomline.setDateDelivered(getMovementDate()); // overwrite=last
|
||||||
obomline.setQtyReject(obomline.getQtyReject().add(getQtyReject()));
|
obomline.setM_AttributeSetInstance_ID(getM_AttributeSetInstance_ID());
|
||||||
obomline.setDateDelivered(getMovementDate()); // overwrite=last
|
log.fine("OrderLine - Reserved=" + obomline.getQtyReserved() + ", Delivered=" + obomline.getQtyDelivered());
|
||||||
obomline.setM_AttributeSetInstance_ID(getM_AttributeSetInstance_ID());
|
obomline.setQtyReserved(obomline.getQtyReserved().subtract(getMovementQty()));
|
||||||
log.fine("OrderLine - Reserved=" + obomline.getQtyReserved() + ", Delivered=" + obomline.getQtyDelivered());
|
obomline.saveEx();
|
||||||
obomline.setQtyReserved(obomline.getQtyReserved().subtract(getMovementQty()));
|
log.fine("OrderLine -> Reserved="+obomline.getQtyReserved()+", Delivered="+obomline.getQtyDelivered());
|
||||||
obomline.saveEx();
|
|
||||||
log.fine("OrderLine -> Reserved="+obomline.getQtyReserved()+", Delivered="+obomline.getQtyDelivered());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (isReceipt())
|
if (isReceipt())
|
||||||
{
|
{
|
||||||
// Update PP Order
|
// Update PP Order Qtys
|
||||||
MPPOrder order = getPPOrder();
|
MPPOrder order = getPP_Order();
|
||||||
order.setQtyDelivered(order.getQtyDelivered().add(getMovementQty()));
|
order.setQtyDelivered(order.getQtyDelivered().add(getMovementQty()));
|
||||||
order.setQtyScrap(order.getQtyScrap().add(getScrappedQty()));
|
order.setQtyScrap(order.getQtyScrap().add(getScrappedQty()));
|
||||||
order.setQtyReject(order.getQtyReject().add(getQtyReject()));
|
order.setQtyReject(order.getQtyReject().add(getQtyReject()));
|
||||||
order.setDateDelivered(getMovementDate()); // overwrite=last
|
|
||||||
log.fine("OrderLine - Reserved=" + order.getQtyReserved() + ", Delivered=" + order.getQtyDelivered());
|
|
||||||
order.setQtyReserved(order.getQtyReserved().subtract(getMovementQty()));
|
order.setQtyReserved(order.getQtyReserved().subtract(getMovementQty()));
|
||||||
|
//
|
||||||
|
// Update PP Order Dates
|
||||||
|
order.setDateDelivered(getMovementDate()); // overwrite=last
|
||||||
|
if (order.getDateStart() == null)
|
||||||
|
{
|
||||||
|
order.setDateStart(getMovementDate());
|
||||||
|
}
|
||||||
|
if (order.getQtyOpen().signum() <= 0)
|
||||||
|
{
|
||||||
|
order.setDateFinish(getMovementDate());
|
||||||
|
}
|
||||||
order.saveEx();
|
order.saveEx();
|
||||||
log.fine("Order -> Delivered=" + order.getQtyDelivered());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(isCostCollectorType(COSTCOLLECTORTYPE_ActivityControl))
|
else if(isCostCollectorType(COSTCOLLECTORTYPE_ActivityControl))
|
||||||
{
|
{
|
||||||
MPPOrderNode activity = getPPOrderNode();
|
MPPOrderNode activity = getPP_Order_Node();
|
||||||
if(activity.getDocStatus().equals(MPPOrderNode.DOCSTATUS_Completed))
|
if(activity.getDocStatus().equals(MPPOrderNode.DOCSTATUS_Completed))
|
||||||
{
|
{
|
||||||
m_processMsg = "Activity was completed before";
|
throw new ActivityProcessedException(activity);
|
||||||
return DocAction.STATUS_Invalid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(isSubcontracting())
|
if(isSubcontracting())
|
||||||
{
|
{
|
||||||
String whereClause = "PP_Cost_Collector_ID =?";
|
String whereClause = MOrderLine.COLUMNNAME_PP_Cost_Collector_ID+"=?";
|
||||||
Collection<MOrderLine> olines = new Query(getCtx(), MOrderLine.Table_Name, whereClause, get_TrxName())
|
Collection<MOrderLine> olines = new Query(getCtx(), MOrderLine.Table_Name, whereClause, get_TrxName())
|
||||||
.setParameters(new Object[]{this.getPP_Cost_Collector_ID()}).list();
|
.setParameters(new Object[]{get_ID()})
|
||||||
|
.list();
|
||||||
String DocStatus = MPPOrderNode.DOCSTATUS_Completed;
|
String DocStatus = MPPOrderNode.DOCSTATUS_Completed;
|
||||||
StringBuffer msg = new StringBuffer("The quantity do not is complete for next Purchase Order :");
|
StringBuffer msg = new StringBuffer("The quantity do not is complete for next Purchase Order :");
|
||||||
for (MOrderLine oline: olines)
|
for (MOrderLine oline : olines)
|
||||||
{
|
{
|
||||||
if(oline.getQtyDelivered().compareTo(oline.getQtyOrdered()) < 0)
|
if(oline.getQtyDelivered().compareTo(oline.getQtyOrdered()) < 0)
|
||||||
|
{
|
||||||
DocStatus = MPPOrderNode.DOCSTATUS_InProgress;
|
DocStatus = MPPOrderNode.DOCSTATUS_InProgress;
|
||||||
|
}
|
||||||
msg.append(oline.getParent().getDocumentNo()).append(",");
|
msg.append(oline.getParent().getDocumentNo()).append(",");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,9 +461,8 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
activity.saveEx();
|
activity.saveEx();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} // end Activity Control
|
||||||
}
|
//
|
||||||
// for all lines
|
|
||||||
setProcessed(true);
|
setProcessed(true);
|
||||||
setDocAction(DOCACTION_Close);
|
setDocAction(DOCACTION_Close);
|
||||||
setDocStatus(DOCSTATUS_Completed);
|
setDocStatus(DOCSTATUS_Completed);
|
||||||
|
@ -488,7 +505,7 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String whereClause = MPPOrderNode.COLUMNNAME_PP_Order_ID+"=?"
|
final String whereClause = MPPOrderNode.COLUMNNAME_PP_Order_ID+"=?"
|
||||||
+" AND ("+MPPOrderNode.COLUMNNAME_DocStatus+" IS NULL OR "+MPPOrderNode.COLUMNNAME_DocStatus+"<>?)";
|
+" AND ("+MPPOrderNode.COLUMNNAME_DocStatus+" IS NULL OR "+MPPOrderNode.COLUMNNAME_DocStatus+"<>?)";
|
||||||
List<MPPOrderNode> list = new Query(getCtx(), MPPOrderNode.Table_Name, whereClause, get_TrxName())
|
List<MPPOrderNode> list = new Query(getCtx(), MPPOrderNode.Table_Name, whereClause, get_TrxName())
|
||||||
.setOnlyActiveRecords(true)
|
.setOnlyActiveRecords(true)
|
||||||
|
@ -631,10 +648,27 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
@Override
|
@Override
|
||||||
protected boolean beforeSave(boolean newRecord)
|
protected boolean beforeSave(boolean newRecord)
|
||||||
{
|
{
|
||||||
/*if (newRecord)
|
// Set default locator, if not set and we have the warehouse:
|
||||||
|
if (getM_Locator_ID() <= 0 && getM_Warehouse_ID() > 0)
|
||||||
{
|
{
|
||||||
setDocStatus(DOCSTATUS_InProgress);
|
MWarehouse wh = MWarehouse.get(getCtx(), getM_Warehouse_ID());
|
||||||
}*/
|
MLocator loc = wh.getDefaultLocator();
|
||||||
|
if (loc != null)
|
||||||
|
{
|
||||||
|
setM_Locator_ID(loc.get_ID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (isCostCollectorType(COSTCOLLECTORTYPE_ActivityControl) && getPP_Order_Node_ID() <= 0)
|
||||||
|
{
|
||||||
|
throw new FillMandatoryException(COLUMNNAME_PP_Order_Node_ID);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (isIssue() && getPP_Order_BOMLine_ID() <= 0)
|
||||||
|
{
|
||||||
|
throw new FillMandatoryException(COLUMNNAME_PP_Order_BOMLine_ID);
|
||||||
|
}
|
||||||
|
//
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -656,7 +690,8 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void completeNew(int PP_Order_ID)
|
@Deprecated
|
||||||
|
private void completeNew(int PP_Order_ID)
|
||||||
{
|
{
|
||||||
if(isCostCollectorType(COSTCOLLECTORTYPE_ActivityControl))
|
if(isCostCollectorType(COSTCOLLECTORTYPE_ActivityControl))
|
||||||
{
|
{
|
||||||
|
@ -676,10 +711,10 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check Material Policy.
|
* Check Material Policy.
|
||||||
* Sets line ASI
|
* Sets line ASI
|
||||||
*/
|
*/
|
||||||
private void checkMaterialPolicy(MPPOrderBOMLine line , BigDecimal qty)
|
private void checkMaterialPolicy(MPPOrderBOMLine line)
|
||||||
{
|
{
|
||||||
MPPOrderBOMLineMA.deleteOrderBOMLineMA(line.get_ID(), get_TrxName());
|
MPPOrderBOMLineMA.deleteOrderBOMLineMA(line.get_ID(), get_TrxName());
|
||||||
|
|
||||||
|
@ -689,6 +724,7 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BigDecimal qty = getMovementQty();
|
||||||
BigDecimal qtyASI = Env.ZERO ;
|
BigDecimal qtyASI = Env.ZERO ;
|
||||||
|
|
||||||
// Check Line
|
// Check Line
|
||||||
|
@ -749,7 +785,8 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
} // outgoing Trx
|
} // outgoing Trx
|
||||||
} // checkMaterialPolicy
|
} // checkMaterialPolicy
|
||||||
|
|
||||||
public MPPOrderNode getPPOrderNode()
|
@Override
|
||||||
|
public MPPOrderNode getPP_Order_Node()
|
||||||
{
|
{
|
||||||
int node_id = getPP_Order_Node_ID();
|
int node_id = getPP_Order_Node_ID();
|
||||||
if (node_id <= 0)
|
if (node_id <= 0)
|
||||||
|
@ -765,9 +802,8 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
return m_orderNode;
|
return m_orderNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MPPOrderBOMLine getPP_Order_BOMLine()
|
||||||
public MPPOrderBOMLine getPPOrderBOMLine()
|
|
||||||
{
|
{
|
||||||
int id = getPP_Order_BOMLine_ID();
|
int id = getPP_Order_BOMLine_ID();
|
||||||
if (id <= 0)
|
if (id <= 0)
|
||||||
|
@ -783,8 +819,8 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
return m_bomLine;
|
return m_bomLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MPPOrder getPPOrder()
|
public MPPOrder getPP_Order()
|
||||||
{
|
{
|
||||||
int id = getPP_Order_ID();
|
int id = getPP_Order_ID();
|
||||||
if (id <= 0)
|
if (id <= 0)
|
||||||
|
@ -801,104 +837,114 @@ 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
|
||||||
*/
|
*/
|
||||||
private void createPOrder(MPPOrderNode activity)
|
private void createPOrder(MPPOrderNode activity)
|
||||||
{
|
{
|
||||||
// create purchase order on complete
|
HashMap<Integer,MOrder> orders = new HashMap<Integer,MOrder>();
|
||||||
String whereClause = "PP_Order_ID=? AND PP_Order_Node_ID=? AND IsSubcontracting=?";
|
//
|
||||||
Collection<MPPOrderNodeProduct> subctracts = new Query(getCtx(),MPPOrderNodeProduct.Table_Name,whereClause, get_TrxName())
|
String whereClause = MPPOrderNodeProduct.COLUMNNAME_PP_Order_Node_ID+"=?"
|
||||||
.setParameters(new Object[]{getPP_Order_ID(), activity.getPP_Order_Node_ID(),"Y"})
|
+" AND "+MPPOrderNodeProduct.COLUMNNAME_IsSubcontracting+"=?";
|
||||||
.setOnlyActiveRecords(true)
|
Collection<MPPOrderNodeProduct> subcontracts = new Query(getCtx(), MPPOrderNodeProduct.Table_Name, whereClause, get_TrxName())
|
||||||
.list();
|
.setParameters(new Object[]{activity.get_ID(), true})
|
||||||
|
.setOnlyActiveRecords(true)
|
||||||
int C_BPartner_ID = -1 ;
|
.list();
|
||||||
CCache<Integer,MOrder> orders = new CCache<Integer,MOrder>(MOrder.Table_Name, 5);
|
for (MPPOrderNodeProduct subcontract : subcontracts)
|
||||||
|
|
||||||
|
|
||||||
for (MPPOrderNodeProduct subctract: subctracts )
|
|
||||||
{
|
{
|
||||||
MProduct product = MProduct.get(getCtx(), subctract.getM_Product_ID());
|
//
|
||||||
MProductPO m_product_po = null;
|
// If Product is not Purchased or is not Service, then it is not a subcontracting candidate [SKIP]
|
||||||
if(product.isPurchased() && product.getProductType().equals(MProduct.PRODUCTTYPE_Service))
|
MProduct product = MProduct.get(getCtx(), subcontract.getM_Product_ID());
|
||||||
|
if(product.isPurchased() && MProduct.PRODUCTTYPE_Service.equals(product.getProductType()))
|
||||||
{
|
{
|
||||||
C_BPartner_ID = activity.getC_BPartner_ID();
|
continue;
|
||||||
|
|
||||||
MProductPO[] ppos = MProductPO.getOfProduct(getCtx(), product.getM_Product_ID(), get_TrxName());
|
|
||||||
for (MProductPO ppo : ppos)
|
|
||||||
{
|
|
||||||
if(C_BPartner_ID == ppo.getC_BPartner_ID())
|
|
||||||
{
|
|
||||||
C_BPartner_ID = ppo.getC_BPartner_ID();
|
|
||||||
m_product_po = ppo;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (ppo.isCurrentVendor() && ppo.getC_BPartner_ID() != 0)
|
|
||||||
{
|
|
||||||
C_BPartner_ID = ppo.getC_BPartner_ID();
|
|
||||||
m_product_po = ppo;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(C_BPartner_ID == -1)
|
|
||||||
throw new AdempiereException(Msg.getMsg(getCtx(), "no.vendor.was.found.for")+" "
|
|
||||||
+Msg.getMsg(getCtx(),"M_Product_ID") + ":" + product.getName());
|
|
||||||
|
|
||||||
Timestamp today = new Timestamp(System.currentTimeMillis());
|
|
||||||
Timestamp datePromised = TimeUtil.addDays(today, m_product_po.getDeliveryTime_Promised());
|
|
||||||
|
|
||||||
MOrder order = orders.get(C_BPartner_ID);
|
|
||||||
if(order == null)
|
|
||||||
{
|
|
||||||
order = new MOrder(getCtx(), 0, get_TrxName());
|
|
||||||
MBPartner vendor = new MBPartner (getCtx(), C_BPartner_ID, get_TrxName());
|
|
||||||
order.setBPartner(vendor);
|
|
||||||
order.setIsSOTrx(false);
|
|
||||||
order.setC_DocTypeTarget_ID();
|
|
||||||
order.setDatePromised(datePromised);
|
|
||||||
order.setDescription(getPPOrder().getDocumentNo());
|
|
||||||
order.setDocStatus(MOrder.DOCSTATUS_Drafted);
|
|
||||||
order.setDocAction(MOrder.DOCACTION_Complete);
|
|
||||||
order.setAD_User_ID(getAD_User_ID());
|
|
||||||
//order.setSalesRep_ID(getAD_User_ID());
|
|
||||||
order.saveEx();
|
|
||||||
setDescription(getDescription() == null ? order.getDocumentNo() :
|
|
||||||
getDescription().concat(Msg.translate(getCtx(), "C_Order_ID")+":"+order.getDocumentNo()));
|
|
||||||
orders.put(C_BPartner_ID, order);
|
|
||||||
}
|
|
||||||
|
|
||||||
BigDecimal QtyOrdered = Env.ZERO;
|
|
||||||
// Check Order Min
|
|
||||||
if(subctract.getQty().signum() > 0 && m_product_po.getOrder_Min().signum() > 0)
|
|
||||||
{
|
|
||||||
QtyOrdered = QtyOrdered.max(m_product_po.getOrder_Min());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check Order Pack
|
|
||||||
if (m_product_po.getOrder_Pack().signum() > 0 && QtyOrdered.signum() > 0)
|
|
||||||
{
|
|
||||||
QtyOrdered = m_product_po.getOrder_Pack().multiply(QtyOrdered.divide(m_product_po.getOrder_Pack(), 0 , BigDecimal.ROUND_UP));
|
|
||||||
}
|
|
||||||
|
|
||||||
MOrderLine oline = new MOrderLine(order);
|
|
||||||
oline.setM_Product_ID(product.getM_Product_ID());
|
|
||||||
oline.setDescription(activity.getDescription());
|
|
||||||
oline.setQty(QtyOrdered);
|
|
||||||
//line.setPrice(m_product_po.getPricePO());
|
|
||||||
//oline.setPriceList(m_product_po.getPriceList());
|
|
||||||
oline.setPP_Cost_Collector_ID(get_ID());
|
|
||||||
oline.setDatePromised(datePromised);
|
|
||||||
oline.saveEx();
|
|
||||||
setProcessed(true);
|
|
||||||
}
|
}
|
||||||
}
|
//
|
||||||
|
// Find Vendor and Product PO data
|
||||||
|
int C_BPartner_ID = activity.getC_BPartner_ID();
|
||||||
|
MProductPO product_po = null;
|
||||||
|
for (MProductPO ppo : MProductPO.getOfProduct(getCtx(), product.get_ID(), null))
|
||||||
|
{
|
||||||
|
if(C_BPartner_ID == ppo.getC_BPartner_ID())
|
||||||
|
{
|
||||||
|
C_BPartner_ID = ppo.getC_BPartner_ID();
|
||||||
|
product_po = ppo;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ppo.isCurrentVendor() && ppo.getC_BPartner_ID() != 0)
|
||||||
|
{
|
||||||
|
C_BPartner_ID = ppo.getC_BPartner_ID();
|
||||||
|
product_po = ppo;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(C_BPartner_ID <= 0 || product_po == null)
|
||||||
|
{
|
||||||
|
throw new NoVendorForProductException(product.getName());
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Calculate Lead Time
|
||||||
|
Timestamp today = new Timestamp(System.currentTimeMillis());
|
||||||
|
Timestamp datePromised = TimeUtil.addDays(today, product_po.getDeliveryTime_Promised());
|
||||||
|
//
|
||||||
|
// Get/Create Purchase Order Header
|
||||||
|
MOrder order = orders.get(C_BPartner_ID);
|
||||||
|
if(order == null)
|
||||||
|
{
|
||||||
|
order = new MOrder(getCtx(), 0, get_TrxName());
|
||||||
|
MBPartner vendor = MBPartner.get(getCtx(), C_BPartner_ID);
|
||||||
|
order.setBPartner(vendor);
|
||||||
|
order.setIsSOTrx(false);
|
||||||
|
order.setC_DocTypeTarget_ID();
|
||||||
|
order.setDatePromised(datePromised);
|
||||||
|
order.setDescription(getPP_Order().getDocumentNo());
|
||||||
|
order.setDocStatus(MOrder.DOCSTATUS_Drafted);
|
||||||
|
order.setDocAction(MOrder.DOCACTION_Complete);
|
||||||
|
order.setAD_User_ID(getAD_User_ID());
|
||||||
|
//order.setSalesRep_ID(getAD_User_ID());
|
||||||
|
order.saveEx();
|
||||||
|
addDescription(Msg.translate(getCtx(), "C_Order_ID")+": "+order.getDocumentNo());
|
||||||
|
orders.put(C_BPartner_ID, order);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Create Order Line:
|
||||||
|
BigDecimal QtyOrdered = subcontract.getQty();
|
||||||
|
// Check Order Min
|
||||||
|
if(product_po.getOrder_Min().signum() > 0)
|
||||||
|
{
|
||||||
|
QtyOrdered = QtyOrdered.max(product_po.getOrder_Min());
|
||||||
|
}
|
||||||
|
// Check Order Pack
|
||||||
|
if (product_po.getOrder_Pack().signum() > 0 && QtyOrdered.signum() > 0)
|
||||||
|
{
|
||||||
|
QtyOrdered = product_po.getOrder_Pack().multiply(QtyOrdered.divide(product_po.getOrder_Pack(), 0 , BigDecimal.ROUND_UP));
|
||||||
|
}
|
||||||
|
MOrderLine oline = new MOrderLine(order);
|
||||||
|
oline.setM_Product_ID(product.getM_Product_ID());
|
||||||
|
oline.setDescription(activity.getDescription());
|
||||||
|
oline.setQty(QtyOrdered);
|
||||||
|
//line.setPrice(m_product_po.getPricePO());
|
||||||
|
//oline.setPriceList(m_product_po.getPriceList());
|
||||||
|
oline.setPP_Cost_Collector_ID(get_ID());
|
||||||
|
oline.setDatePromised(datePromised);
|
||||||
|
oline.saveEx();
|
||||||
|
//
|
||||||
|
// TODO: Mark this as processed?
|
||||||
|
setProcessed(true);
|
||||||
|
} // each subcontracting line
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public I_M_Product getM_Product()
|
||||||
|
{
|
||||||
|
return MProduct.get(getCtx(), getM_Product_ID());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public I_C_UOM getC_UOM()
|
||||||
|
{
|
||||||
|
return MUOM.get(getCtx(), getC_UOM_ID());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIssue()
|
public boolean isIssue()
|
||||||
|
@ -942,7 +988,7 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
* @param args ignored
|
* @param args ignored
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws FileNotFoundException
|
* @throws FileNotFoundException
|
||||||
*/
|
*
|
||||||
public static void main (String[] args) throws FileNotFoundException, IOException
|
public static void main (String[] args) throws FileNotFoundException, IOException
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -983,12 +1029,11 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
m_Ctx.setProperty("#AD_User_ID", new Integer(AD_User_ID_Value).toString());
|
m_Ctx.setProperty("#AD_User_ID", new Integer(AD_User_ID_Value).toString());
|
||||||
m_Ctx.setProperty("#AD_Client_ID", new Integer(AD_Client_ID_Value).toString());
|
m_Ctx.setProperty("#AD_Client_ID", new Integer(AD_Client_ID_Value).toString());
|
||||||
|
|
||||||
/*if (fileName_Value.length() < 1) {
|
// if (fileName_Value.length() < 1) {
|
||||||
throw new AdempiereException("Please specify path to Adempiere.properties file!");
|
// throw new AdempiereException("Please specify path to Adempiere.properties file!");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
System.setProperty("PropertyFile", fileName_Value);
|
// System.setProperty("PropertyFile", fileName_Value);
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//CLogMgt.setLevel(LogLevel_Value);
|
//CLogMgt.setLevel(LogLevel_Value);
|
||||||
|
@ -1010,4 +1055,5 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/**/
|
||||||
} // MPPCostCollector
|
} // MPPCostCollector
|
||||||
|
|
|
@ -18,10 +18,13 @@ package org.eevolution.model;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.compiere.model.MDocType;
|
import org.compiere.model.MDocType;
|
||||||
|
import org.compiere.model.MForecastLine;
|
||||||
import org.compiere.model.MLocator;
|
import org.compiere.model.MLocator;
|
||||||
import org.compiere.model.MOrder;
|
import org.compiere.model.MOrder;
|
||||||
import org.compiere.model.MOrderLine;
|
import org.compiere.model.MOrderLine;
|
||||||
|
@ -30,11 +33,11 @@ import org.compiere.model.MRequisition;
|
||||||
import org.compiere.model.MRequisitionLine;
|
import org.compiere.model.MRequisitionLine;
|
||||||
import org.compiere.model.MResource;
|
import org.compiere.model.MResource;
|
||||||
import org.compiere.model.MResourceType;
|
import org.compiere.model.MResourceType;
|
||||||
import org.compiere.model.MTable;
|
import org.compiere.model.PO;
|
||||||
import org.compiere.model.Query;
|
import org.compiere.model.Query;
|
||||||
import org.compiere.model.X_C_DocType;
|
|
||||||
import org.compiere.model.X_M_Forecast;
|
import org.compiere.model.X_M_Forecast;
|
||||||
import org.compiere.process.DocAction;
|
import org.compiere.process.DocAction;
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.TimeUtil;
|
import org.compiere.util.TimeUtil;
|
||||||
|
@ -53,6 +56,130 @@ public class MPPMRP extends X_PP_MRP
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private static CLogger s_log = CLogger.getCLogger(MPPMRP.class);
|
||||||
|
|
||||||
|
private static HashMap<String, String[]> s_sourceColumnNames = new HashMap<String, String[]>();
|
||||||
|
static
|
||||||
|
{
|
||||||
|
s_sourceColumnNames.put(MOrder.Table_Name, new String[]{
|
||||||
|
MOrder.COLUMNNAME_DatePromised,
|
||||||
|
MOrder.COLUMNNAME_DocStatus,
|
||||||
|
});
|
||||||
|
s_sourceColumnNames.put(MOrderLine.Table_Name, new String[]{
|
||||||
|
"AD_Org_ID",
|
||||||
|
MOrderLine.COLUMNNAME_DateOrdered,
|
||||||
|
MOrderLine.COLUMNNAME_DatePromised,
|
||||||
|
MOrderLine.COLUMNNAME_C_BPartner_ID,
|
||||||
|
MOrderLine.COLUMNNAME_M_Warehouse_ID,
|
||||||
|
MOrderLine.COLUMNNAME_M_Product_ID,
|
||||||
|
MOrderLine.COLUMNNAME_QtyOrdered,
|
||||||
|
MOrderLine.COLUMNNAME_QtyDelivered,
|
||||||
|
});
|
||||||
|
s_sourceColumnNames.put(MRequisition.Table_Name, new String[]{
|
||||||
|
MRequisition.COLUMNNAME_DateRequired,
|
||||||
|
MRequisition.COLUMNNAME_M_Warehouse_ID,
|
||||||
|
});
|
||||||
|
s_sourceColumnNames.put(MRequisitionLine.Table_Name, new String[]{
|
||||||
|
"AD_Org_ID",
|
||||||
|
MRequisitionLine.COLUMNNAME_M_Product_ID,
|
||||||
|
MRequisitionLine.COLUMNNAME_Qty,
|
||||||
|
MRequisitionLine.COLUMNNAME_C_OrderLine_ID, // QtyOrdered depends on that
|
||||||
|
});
|
||||||
|
s_sourceColumnNames.put(X_M_Forecast.Table_Name, new String[]{
|
||||||
|
});
|
||||||
|
s_sourceColumnNames.put(MForecastLine.Table_Name, new String[]{
|
||||||
|
"AD_Org_ID",
|
||||||
|
MForecastLine.COLUMNNAME_DatePromised,
|
||||||
|
MForecastLine.COLUMNNAME_M_Warehouse_ID,
|
||||||
|
MForecastLine.COLUMNNAME_M_Product_ID,
|
||||||
|
MForecastLine.COLUMNNAME_Qty,
|
||||||
|
});
|
||||||
|
s_sourceColumnNames.put(MDDOrderLine.Table_Name, new String[]{
|
||||||
|
"AD_Org_ID",
|
||||||
|
MDDOrderLine.COLUMNNAME_M_Product_ID,
|
||||||
|
MDDOrderLine.COLUMNNAME_DatePromised,
|
||||||
|
MDDOrderLine.COLUMNNAME_QtyOrdered,
|
||||||
|
MDDOrderLine.COLUMNNAME_QtyDelivered,
|
||||||
|
MDDOrderLine.COLUMNNAME_ConfirmedQty,
|
||||||
|
MDDOrderLine.COLUMNNAME_M_Locator_ID,
|
||||||
|
MDDOrderLine.COLUMNNAME_M_LocatorTo_ID,
|
||||||
|
MDDOrderLine.COLUMNNAME_ConfirmedQty,
|
||||||
|
});
|
||||||
|
s_sourceColumnNames.put(MPPOrder.Table_Name, new String[]{
|
||||||
|
"AD_Org_ID",
|
||||||
|
MPPOrder.COLUMNNAME_M_Product_ID,
|
||||||
|
MPPOrder.COLUMNNAME_DatePromised,
|
||||||
|
MPPOrder.COLUMNNAME_QtyOrdered,
|
||||||
|
MPPOrder.COLUMNNAME_QtyDelivered,
|
||||||
|
MPPOrder.COLUMNNAME_PP_Product_BOM_ID,
|
||||||
|
MPPOrder.COLUMNNAME_AD_Workflow_ID,
|
||||||
|
});
|
||||||
|
s_sourceColumnNames.put(MPPOrderBOMLine.Table_Name, new String[]{
|
||||||
|
MPPOrderBOMLine.COLUMNNAME_M_Product_ID,
|
||||||
|
MPPOrderBOMLine.COLUMNNAME_M_Warehouse_ID,
|
||||||
|
MPPOrderBOMLine.COLUMNNAME_QtyEntered,
|
||||||
|
MPPOrderBOMLine.COLUMNNAME_QtyDelivered,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a persistent object is changed, from MRP point of view
|
||||||
|
* @param po MRP relevant PO (e.g. MOrder, MOrderLine, MPPOrder etc)
|
||||||
|
* @return true if object changed
|
||||||
|
*/
|
||||||
|
public static boolean isChanged(PO po)
|
||||||
|
{
|
||||||
|
String[] columnNames = s_sourceColumnNames.get(po.get_TableName());
|
||||||
|
if (columnNames == null || columnNames.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (String columnName : columnNames)
|
||||||
|
{
|
||||||
|
if (po.is_ValueChanged(columnName))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void deleteMRP(PO po)
|
||||||
|
{
|
||||||
|
String tableName = po.get_TableName();
|
||||||
|
int no = DB.executeUpdateEx("DELETE FROM "+Table_Name+" WHERE "+tableName+"_ID=? AND AD_Client_ID=?",
|
||||||
|
new Object[]{po.get_ID(), po.getAD_Client_ID()},
|
||||||
|
po.get_TrxName());
|
||||||
|
s_log.finest("Deleted "+tableName+" #"+no);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Query getQuery(PO po, String typeMRP, String orderType)
|
||||||
|
{
|
||||||
|
ArrayList<Object> params = new ArrayList<Object>();
|
||||||
|
StringBuffer whereClause = new StringBuffer();
|
||||||
|
//
|
||||||
|
whereClause.append("AD_Client_ID=?");
|
||||||
|
params.add(po.getAD_Client_ID());
|
||||||
|
//
|
||||||
|
whereClause.append(" AND ").append(po.get_TableName()).append("_ID=?");
|
||||||
|
params.add(po.get_ID());
|
||||||
|
//
|
||||||
|
if (typeMRP != null)
|
||||||
|
{
|
||||||
|
whereClause.append(" AND ").append(COLUMNNAME_TypeMRP).append("=?");
|
||||||
|
params.add(typeMRP);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (orderType != null)
|
||||||
|
{
|
||||||
|
whereClause.append(" AND ").append(COLUMNNAME_OrderType).append("=?");
|
||||||
|
params.add(orderType);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
return new Query(po.getCtx(), Table_Name, whereClause.toString(), po.get_TrxName())
|
||||||
|
.setParameters(params);
|
||||||
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
|
@ -122,15 +249,12 @@ public class MPPMRP extends X_PP_MRP
|
||||||
|
|
||||||
if (delete)
|
if (delete)
|
||||||
{
|
{
|
||||||
final String sql = "DELETE FROM PP_MRP WHERE M_ForecastLine_ID=? AND AD_Client_ID=?";
|
deleteMRP(fl);
|
||||||
DB.executeUpdateEx(sql, new Object[]{fl.get_ID(), fl.getAD_Client_ID()}, trxName);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
X_M_Forecast f = new X_M_Forecast(ctx, fl.getM_Forecast_ID(), trxName);
|
X_M_Forecast f = new X_M_Forecast(ctx, fl.getM_Forecast_ID(), trxName);
|
||||||
MPPMRP mrp = new Query(ctx, MPPMRP.Table_Name, "M_ForecastLine_ID=?", trxName)
|
MPPMRP mrp = getQuery(fl, null, null).firstOnly();
|
||||||
.setParameters(new Object[]{fl.get_ID()})
|
|
||||||
.first();
|
|
||||||
if (mrp == null)
|
if (mrp == null)
|
||||||
{
|
{
|
||||||
mrp = new MPPMRP(ctx, 0, trxName);
|
mrp = new MPPMRP(ctx, 0, trxName);
|
||||||
|
@ -162,21 +286,14 @@ public class MPPMRP extends X_PP_MRP
|
||||||
*/
|
*/
|
||||||
public static void C_Order(MOrder o, boolean delete)
|
public static void C_Order(MOrder o, boolean delete)
|
||||||
{
|
{
|
||||||
String trxName = o.get_TrxName();
|
|
||||||
|
|
||||||
final String whereClause = COLUMNNAME_C_Order_ID+"=? AND AD_Client_ID=?";
|
|
||||||
Object[] params = new Object[]{o.get_ID(), o.getAD_Client_ID()};
|
|
||||||
|
|
||||||
if (delete)
|
if (delete)
|
||||||
{
|
{
|
||||||
final String sql = "DELETE FROM PP_MRP WHERE "+whereClause;
|
deleteMRP(o);
|
||||||
DB.executeUpdateEx(sql, params, trxName);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MDocType dt = MDocType.get(o.getCtx(), o.getC_DocType_ID());
|
MDocType dt = MDocType.get(o.getCtx(), o.getC_DocTypeTarget_ID());
|
||||||
String DocSubTypeSO = dt.getDocSubTypeSO();
|
String DocSubTypeSO = dt.getDocSubTypeSO();
|
||||||
|
|
||||||
if(MDocType.DOCSUBTYPESO_StandardOrder.equals(DocSubTypeSO) || !o.isSOTrx())
|
if(MDocType.DOCSUBTYPESO_StandardOrder.equals(DocSubTypeSO) || !o.isSOTrx())
|
||||||
{
|
{
|
||||||
if((o.getDocStatus().equals(MOrder.DOCSTATUS_InProgress)
|
if((o.getDocStatus().equals(MOrder.DOCSTATUS_InProgress)
|
||||||
|
@ -193,9 +310,7 @@ public class MPPMRP extends X_PP_MRP
|
||||||
|| o.is_ValueChanged(MOrder.COLUMNNAME_C_BPartner_ID)
|
|| o.is_ValueChanged(MOrder.COLUMNNAME_C_BPartner_ID)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
List<MPPMRP> list = new Query(o.getCtx(), MPPMRP.Table_Name, whereClause, trxName)
|
List<MPPMRP> list = getQuery(o, null, null).list();
|
||||||
.setParameters(params)
|
|
||||||
.list();
|
|
||||||
for (MPPMRP mrp : list)
|
for (MPPMRP mrp : list)
|
||||||
{
|
{
|
||||||
mrp.setC_Order(o);
|
mrp.setC_Order(o);
|
||||||
|
@ -213,29 +328,22 @@ public class MPPMRP extends X_PP_MRP
|
||||||
*/
|
*/
|
||||||
public static void C_OrderLine(MOrderLine ol, boolean delete)
|
public static void C_OrderLine(MOrderLine ol, boolean delete)
|
||||||
{
|
{
|
||||||
Properties ctx = ol.getCtx();
|
|
||||||
String trxName = ol.get_TrxName();
|
|
||||||
final String whereClause = "AD_Client_ID = ? AND C_OrderLine_ID = ?";
|
|
||||||
Object[] params = new Object[]{ol.getAD_Client_ID(),ol.getC_OrderLine_ID()};
|
|
||||||
if (delete)
|
if (delete)
|
||||||
{
|
{
|
||||||
DB.executeUpdateEx("DELETE FROM PP_MRP WHERE "+whereClause, params, trxName);
|
deleteMRP(ol);
|
||||||
MPPOrder order = new Query(ctx, MPPOrder.Table_Name, whereClause, trxName)
|
// Delete generated manufacturing order
|
||||||
.setParameters(params)
|
MPPOrder order = MPPOrder.forC_OrderLine_ID(ol.getCtx(), ol.get_ID(), ol.get_TrxName());
|
||||||
.first();
|
|
||||||
if (order != null && !order.isProcessed())
|
if (order != null && !order.isProcessed())
|
||||||
{
|
{
|
||||||
order.deleteEx(true, trxName);
|
order.deleteEx(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPPMRP mrp = new Query(ctx, MPPMRP.Table_Name, whereClause, trxName)
|
MPPMRP mrp = getQuery(ol, null, null).firstOnly();
|
||||||
.setParameters(params)
|
|
||||||
.first();
|
|
||||||
if(mrp == null)
|
if(mrp == null)
|
||||||
{
|
{
|
||||||
mrp = new MPPMRP(ctx, 0, trxName);
|
mrp = new MPPMRP(ol.getCtx(), 0, ol.get_TrxName());
|
||||||
mrp.setC_OrderLine_ID(ol.getC_OrderLine_ID());
|
mrp.setC_OrderLine_ID(ol.getC_OrderLine_ID());
|
||||||
}
|
}
|
||||||
mrp.setAD_Org_ID(ol.getAD_Org_ID());
|
mrp.setAD_Org_ID(ol.getAD_Org_ID());
|
||||||
|
@ -256,84 +364,64 @@ public class MPPMRP extends X_PP_MRP
|
||||||
String DocSubTypeSO = dt.getDocSubTypeSO();
|
String DocSubTypeSO = dt.getDocSubTypeSO();
|
||||||
if(MDocType.DOCSUBTYPESO_StandardOrder.equals(DocSubTypeSO))
|
if(MDocType.DOCSUBTYPESO_StandardOrder.equals(DocSubTypeSO))
|
||||||
{
|
{
|
||||||
MPPOrder order = new Query(ctx, MPPOrder.Table_Name, whereClause, trxName)
|
MPPOrder order = MPPOrder.forC_OrderLine_ID(ol.getCtx(), ol.get_ID(), ol.get_TrxName());
|
||||||
.setParameters(params)
|
|
||||||
.first();
|
|
||||||
if (order == null)
|
if (order == null)
|
||||||
{
|
{
|
||||||
String where = MPPProductBOM.COLUMNNAME_BOMType+"=?"
|
final String whereClause = MPPProductBOM.COLUMNNAME_BOMType+"=?"
|
||||||
+" AND "+MPPProductBOM.COLUMNNAME_M_Product_ID+"=?";
|
+" AND "+MPPProductBOM.COLUMNNAME_M_Product_ID+"=?";
|
||||||
MPPProductBOM bom = new Query(ctx, MPPProductBOM.Table_Name, where, trxName)
|
MPPProductBOM bom = new Query(ol.getCtx(), MPPProductBOM.Table_Name, whereClause, null)
|
||||||
.setParameters(new Object[]{MPPProductBOM.BOMTYPE_Make_To_Order, ol.getM_Product_ID()})
|
.setParameters(new Object[]{MPPProductBOM.BOMTYPE_Make_To_Order, ol.getM_Product_ID()})
|
||||||
.first();
|
.firstOnly();
|
||||||
|
|
||||||
MPPProductPlanning pp = null;
|
MPPProductPlanning pp = null;
|
||||||
//Validate the BOM based in planning data
|
//Validate the BOM based in planning data
|
||||||
if(bom == null)
|
if(bom == null)
|
||||||
{
|
{
|
||||||
pp = MPPProductPlanning.find( ctx, ol.getAD_Org_ID() , 0, 0, ol.getM_Product_ID(), trxName);
|
pp = MPPProductPlanning.find(ol.getCtx(), ol.getAD_Org_ID(), 0, 0, ol.getM_Product_ID(), null);
|
||||||
if(pp != null)
|
if(pp != null)
|
||||||
{
|
{
|
||||||
if(pp.getPP_Product_BOM_ID() != 0)
|
bom = (MPPProductBOM) pp.getPP_Product_BOM();
|
||||||
|
if(bom != null && !MPPProductBOM.BOMTYPE_Make_To_Order.equals(bom.getBOMType()))
|
||||||
{
|
{
|
||||||
bom = (MPPProductBOM) pp.getPP_Product_BOM();
|
bom = null;
|
||||||
if(!bom.getBOMType().equals(MPPProductBOM.BOMTYPE_Make_To_Order))
|
|
||||||
bom = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bom != null)
|
if (bom != null)
|
||||||
{
|
{
|
||||||
MProduct product = MProduct.get(ctx,ol.getM_Product_ID());
|
final MProduct product = MProduct.get(ol.getCtx(), ol.getM_Product_ID());
|
||||||
String WhereClause = "ManufacturingResourceType = 'PT' AND IsManufacturingResource = 'Y' AND AD_Client_ID = ? AND M_Warehouse_ID = ?";
|
final int plant_id = MPPProductPlanning.getPlantForWarehouse(ol.getM_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 workflow = MWorkflow.get(ol.getCtx(), MWorkflow.getWorkflowSearchKey(ol.getCtx(), product));
|
||||||
|
//Validate the workflow based in planning data
|
||||||
MWorkflow m_workflow = MWorkflow.get(ctx, MWorkflow.getWorkflowSearchKey(ctx, product));
|
if(workflow == null && pp != null)
|
||||||
|
{
|
||||||
//Validate the workflow based in planning data
|
workflow = pp.getAD_Workflow();
|
||||||
if(m_workflow == null)
|
}
|
||||||
{
|
//
|
||||||
if(pp != null && pp.getAD_Workflow_ID() != 0)
|
if (plant_id > 0 && workflow != null)
|
||||||
{
|
{
|
||||||
m_workflow = (MWorkflow) pp.getAD_Workflow();
|
int duration = MPPMRP.getDays(ol.getCtx(), plant_id, workflow.get_ID(), ol.getQtyOrdered(), ol.get_TrxName()).intValue();
|
||||||
}
|
//
|
||||||
}
|
order = new MPPOrder(ol.getCtx(), 0 , ol.get_TrxName());
|
||||||
|
order.setC_OrderLine_ID(ol.getC_OrderLine_ID());
|
||||||
if (m_resource != null && m_workflow != null)
|
order.setS_Resource_ID(plant_id);
|
||||||
{
|
order.setM_Warehouse_ID(ol.getM_Warehouse_ID());
|
||||||
MDocType[] doc = MDocType.getOfDocBaseType(ctx, X_C_DocType.DOCBASETYPE_ManufacturingOrder);
|
order.setM_Product_ID(ol.getM_Product_ID());
|
||||||
int C_DocType_ID = doc[0].getC_DocType_ID();
|
order.setM_AttributeSetInstance_ID(ol.getM_AttributeSetInstance_ID());
|
||||||
|
order.setPP_Product_BOM_ID(bom.get_ID());
|
||||||
order = new MPPOrder(ctx, 0 , trxName);
|
order.setAD_Workflow_ID(workflow.get_ID());
|
||||||
order.setC_OrderLine_ID(ol.getC_OrderLine_ID());
|
order.setPlanner_ID(ol.getParent().getSalesRep_ID());
|
||||||
order.setS_Resource_ID(m_resource.get_ID());
|
order.setLine(10);
|
||||||
order.setM_Warehouse_ID(ol.getM_Warehouse_ID());
|
order.setDateOrdered(ol.getDateOrdered());
|
||||||
order.setM_Product_ID(ol.getM_Product_ID());
|
order.setDatePromised(ol.getDatePromised());
|
||||||
order.setM_AttributeSetInstance_ID(ol.getM_AttributeSetInstance_ID());
|
order.setDateStartSchedule(TimeUtil.addDays(ol.getDatePromised(), 0 - duration));
|
||||||
order.setPP_Product_BOM_ID(bom.get_ID());
|
order.setDateFinishSchedule(ol.getDatePromised());
|
||||||
order.setAD_Workflow_ID(m_workflow.get_ID());
|
order.setC_UOM_ID(ol.getC_UOM_ID());
|
||||||
order.setPlanner_ID(ol.getParent().getSalesRep_ID());
|
order.setQty(ol.getQtyOrdered());
|
||||||
order.setLine(10);
|
order.setPriorityRule(MPPOrder.PRIORITYRULE_High);
|
||||||
order.setQtyDelivered(Env.ZERO);
|
order.saveEx();
|
||||||
order.setQtyReject(Env.ZERO);
|
order.prepareIt();
|
||||||
order.setQtyScrap(Env.ZERO);
|
order.saveEx();
|
||||||
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();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -370,18 +458,12 @@ public class MPPMRP extends X_PP_MRP
|
||||||
|
|
||||||
if (delete)
|
if (delete)
|
||||||
{
|
{
|
||||||
String sql = "DELETE FROM PP_MRP WHERE PP_Order_ID=? AND AD_Client_ID=?";
|
deleteMRP(o);
|
||||||
Object[] params = new Object[]{o.getPP_Order_ID(), o.getAD_Client_ID()};
|
|
||||||
DB.executeUpdateEx(sql, params, trxName);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Supply
|
// Supply
|
||||||
final String whereClause = "TypeMRP=? AND OrderType=? AND AD_Client_ID=? AND PP_Order_ID=?";
|
MPPMRP mrpSupply = getQuery(o, TYPEMRP_Supply, ORDERTYPE_ManufacturingOrder).firstOnly();
|
||||||
MPPMRP mrpSupply = new Query(ctx, MPPMRP.Table_Name, whereClause, trxName)
|
|
||||||
.setParameters(new Object[]{MPPMRP.TYPEMRP_Supply, MPPMRP.ORDERTYPE_ManufacturingOrder, o.getAD_Client_ID(), o.getPP_Order_ID()})
|
|
||||||
.first();
|
|
||||||
if(mrpSupply == null)
|
if(mrpSupply == null)
|
||||||
{
|
{
|
||||||
mrpSupply = new MPPMRP(ctx, 0, trxName);
|
mrpSupply = new MPPMRP(ctx, 0, trxName);
|
||||||
|
@ -393,13 +475,10 @@ public class MPPMRP extends X_PP_MRP
|
||||||
mrpSupply.setM_Product_ID(o.getM_Product_ID());
|
mrpSupply.setM_Product_ID(o.getM_Product_ID());
|
||||||
mrpSupply.setM_Warehouse_ID(o.getM_Warehouse_ID());
|
mrpSupply.setM_Warehouse_ID(o.getM_Warehouse_ID());
|
||||||
mrpSupply.saveEx();
|
mrpSupply.saveEx();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Demand
|
// Demand
|
||||||
List<MPPMRP> demand = new Query(ctx, MPPMRP.Table_Name, whereClause, trxName)
|
List<MPPMRP> mrpDemandList = getQuery(o, TYPEMRP_Demand, ORDERTYPE_ManufacturingOrder).list();
|
||||||
.setParameters(new Object[]{MPPMRP.TYPEMRP_Demand, MPPMRP.ORDERTYPE_ManufacturingOrder, o.getAD_Client_ID(), o.getPP_Order_ID()})
|
for (MPPMRP mrpDemand : mrpDemandList)
|
||||||
.list();
|
|
||||||
for (MPPMRP mrpDemand : demand)
|
|
||||||
{
|
{
|
||||||
mrpDemand.setPP_Order(o);
|
mrpDemand.setPP_Order(o);
|
||||||
mrpDemand.saveEx();
|
mrpDemand.saveEx();
|
||||||
|
@ -411,31 +490,39 @@ public class MPPMRP extends X_PP_MRP
|
||||||
* @param MPPOrderBOMLine Order BOM Line
|
* @param MPPOrderBOMLine Order BOM Line
|
||||||
* @param delete indicate if this record is delete
|
* @param delete indicate if this record is delete
|
||||||
*/
|
*/
|
||||||
public static void PP_Order_BOMLine(MPPOrderBOMLine obl,boolean delete)
|
public static void PP_Order_BOMLine(MPPOrderBOMLine obl, boolean delete)
|
||||||
{
|
{
|
||||||
String trxName = obl.get_TrxName();
|
String trxName = obl.get_TrxName();
|
||||||
Properties ctx = obl.getCtx();
|
Properties ctx = obl.getCtx();
|
||||||
if (delete)
|
if (delete)
|
||||||
{
|
{
|
||||||
final String sql = "DELETE FROM PP_MRP WHERE PP_Order_BOMLine_ID=? AND AD_Client_ID=?";
|
deleteMRP(obl);
|
||||||
DB.executeUpdateEx(sql, new Object[]{obl.get_ID(), obl.getAD_Client_ID()}, trxName);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//
|
||||||
final String whereClause = "TypeMRP=? AND OrderType=? AND PP_Order_BOMLine_ID=? AND AD_Client_ID=?";
|
String typeMRP = MPPMRP.TYPEMRP_Demand;
|
||||||
MPPMRP mrp = new Query(ctx, MPPMRP.Table_Name, whereClause, trxName)
|
BigDecimal qty = obl.getQtyRequiered().subtract(obl.getQtyDelivered());
|
||||||
.setParameters(new Object[]{TYPEMRP_Demand, ORDERTYPE_ManufacturingOrder, obl.get_ID(), obl.getAD_Client_ID()})
|
//
|
||||||
.first();
|
// By-Product support:
|
||||||
MPPOrder o = obl.getParent();
|
if (obl.isComponentType(MPPOrderBOMLine.COMPONENTTYPE_ByProduct))
|
||||||
|
{
|
||||||
|
// TODO: need to evaluate
|
||||||
|
deleteMRP(obl);
|
||||||
|
return;
|
||||||
|
// typeMRP = MPPMRP.TYPEMRP_Supply;
|
||||||
|
// qty = qty.negate();
|
||||||
|
}
|
||||||
|
//
|
||||||
|
MPPMRP mrp = getQuery(obl, typeMRP, ORDERTYPE_ManufacturingOrder).firstOnly();
|
||||||
if(mrp == null)
|
if(mrp == null)
|
||||||
{
|
{
|
||||||
mrp = new MPPMRP(ctx, 0, trxName);
|
mrp = new MPPMRP(ctx, 0, trxName);
|
||||||
mrp.setAD_Org_ID(obl.getAD_Org_ID());
|
|
||||||
mrp.setPP_Order_BOMLine_ID(obl.getPP_Order_BOMLine_ID());
|
mrp.setPP_Order_BOMLine_ID(obl.getPP_Order_BOMLine_ID());
|
||||||
mrp.setTypeMRP(MPPMRP.TYPEMRP_Demand);
|
|
||||||
}
|
}
|
||||||
mrp.setPP_Order(o);
|
mrp.setAD_Org_ID(obl.getAD_Org_ID());
|
||||||
mrp.setQty(obl.getQtyRequiered().subtract(obl.getQtyDelivered()));
|
mrp.setTypeMRP(typeMRP);
|
||||||
|
mrp.setPP_Order(obl.getParent());
|
||||||
|
mrp.setQty(qty);
|
||||||
mrp.setM_Product_ID(obl.getM_Product_ID());
|
mrp.setM_Product_ID(obl.getM_Product_ID());
|
||||||
mrp.setM_Warehouse_ID(obl.getM_Warehouse_ID());
|
mrp.setM_Warehouse_ID(obl.getM_Warehouse_ID());
|
||||||
mrp.saveEx();
|
mrp.saveEx();
|
||||||
|
@ -448,12 +535,9 @@ public class MPPMRP extends X_PP_MRP
|
||||||
*/
|
*/
|
||||||
public static void DD_Order(MDDOrder o, boolean delete)
|
public static void DD_Order(MDDOrder o, boolean delete)
|
||||||
{
|
{
|
||||||
String sql = null;
|
|
||||||
String trxName = o.get_TrxName();
|
|
||||||
if (delete)
|
if (delete)
|
||||||
{
|
{
|
||||||
sql = "DELETE FROM PP_MRP WHERE DD_Order_ID = "+ o.getDD_Order_ID() +" AND AD_Client_ID = " + o.getAD_Client_ID();
|
deleteMRP(o);
|
||||||
DB.executeUpdateEx(sql, trxName);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -465,20 +549,18 @@ public class MPPMRP extends X_PP_MRP
|
||||||
*/
|
*/
|
||||||
public static void DD_Order_Line(MDDOrderLine ol, boolean delete)
|
public static void DD_Order_Line(MDDOrderLine ol, boolean delete)
|
||||||
{
|
{
|
||||||
String sql = null;
|
|
||||||
String trxName = ol.getParent().get_TrxName();
|
String trxName = ol.getParent().get_TrxName();
|
||||||
Properties m_ctx = ol.getCtx();
|
Properties m_ctx = ol.getCtx();
|
||||||
if (delete)
|
if (delete)
|
||||||
{
|
{
|
||||||
sql = "DELETE FROM PP_MRP WHERE DD_OrderLine_ID = "+ ol.getDD_OrderLine_ID() +" AND AD_Client_ID = " + ol.getAD_Client_ID();
|
deleteMRP(ol);
|
||||||
DB.executeUpdateEx(sql ,trxName);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String whereClause = "TypeMRP = ? AND OrderType=? AND AD_Client_ID=? AND DD_OrderLine_ID = ?";
|
//
|
||||||
MPPMRP mrp = (MPPMRP)MTable.get(m_ctx, MPPMRP.Table_ID).getPO(whereClause, new Object[]{MPPMRP.TYPEMRP_Demand,"DOO",ol.getAD_Client_ID(),ol.getDD_OrderLine_ID()}, trxName);
|
MPPMRP mrp = getQuery(ol, TYPEMRP_Demand, ORDERTYPE_DistributionOrder).firstOnly();
|
||||||
MLocator source = MLocator.get( m_ctx , ol.getM_Locator_ID());
|
MLocator source = MLocator.get( m_ctx , ol.getM_Locator_ID());
|
||||||
MLocator target = MLocator.get( m_ctx , ol.getM_LocatorTo_ID());
|
MLocator target = MLocator.get( m_ctx , ol.getM_LocatorTo_ID());
|
||||||
if(mrp!=null)
|
if(mrp != null)
|
||||||
{
|
{
|
||||||
mrp.setAD_Org_ID(source.getAD_Org_ID());
|
mrp.setAD_Org_ID(source.getAD_Org_ID());
|
||||||
mrp.setName("MRP");
|
mrp.setName("MRP");
|
||||||
|
@ -510,8 +592,7 @@ public class MPPMRP extends X_PP_MRP
|
||||||
mrp.saveEx();
|
mrp.saveEx();
|
||||||
|
|
||||||
}
|
}
|
||||||
whereClause ="TypeMRP=? AND OrderType=? AND AD_Client_ID=? AND DD_OrderLine_ID = ? ";
|
mrp = getQuery(ol, TYPEMRP_Supply, ORDERTYPE_DistributionOrder).firstOnly();
|
||||||
mrp = (MPPMRP)MTable.get(m_ctx, MPPMRP.Table_ID).getPO(whereClause, new Object[]{MPPMRP.TYPEMRP_Supply,"DOO",ol.getAD_Client_ID(),ol.getDD_OrderLine_ID()}, trxName);
|
|
||||||
if(mrp!=null)
|
if(mrp!=null)
|
||||||
{
|
{
|
||||||
mrp.setAD_Org_ID(target.getAD_Org_ID());
|
mrp.setAD_Org_ID(target.getAD_Org_ID());
|
||||||
|
@ -554,37 +635,30 @@ public class MPPMRP extends X_PP_MRP
|
||||||
*/
|
*/
|
||||||
public static void M_RequisitionLine( MRequisitionLine rl , boolean delete)
|
public static void M_RequisitionLine( MRequisitionLine rl , boolean delete)
|
||||||
{
|
{
|
||||||
String trxName = rl.get_TrxName();
|
|
||||||
Properties ctx = rl.getCtx();
|
|
||||||
final String whereClause = "M_RequisitionLine_ID=? AND AD_Client_ID=?";
|
|
||||||
Object[] params = new Object[]{rl.getM_RequisitionLine_ID(), rl.getAD_Client_ID()};
|
|
||||||
|
|
||||||
if (delete)
|
if (delete)
|
||||||
{
|
{
|
||||||
DB.executeUpdateEx("DELETE FROM PP_MRP WHERE "+whereClause, params, trxName);
|
deleteMRP(rl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPPMRP mrp = new Query(ctx, MPPMRP.Table_Name, whereClause, trxName)
|
MPPMRP mrp = getQuery(rl, null, null).firstOnly();
|
||||||
.setParameters(params)
|
|
||||||
.first();
|
|
||||||
MRequisition r = rl.getParent();
|
MRequisition r = rl.getParent();
|
||||||
if (mrp == null)
|
if (mrp == null)
|
||||||
{
|
{
|
||||||
mrp = new MPPMRP(ctx, 0, trxName);
|
mrp = new MPPMRP(rl.getCtx(), 0, rl.get_TrxName());
|
||||||
mrp.setAD_Org_ID(r.getAD_Org_ID());
|
|
||||||
mrp.setM_Requisition_ID(rl.getM_Requisition_ID());
|
mrp.setM_Requisition_ID(rl.getM_Requisition_ID());
|
||||||
mrp.setM_RequisitionLine_ID(rl.getM_RequisitionLine_ID());
|
mrp.setM_RequisitionLine_ID(rl.getM_RequisitionLine_ID());
|
||||||
mrp.setOrderType(MPPMRP.ORDERTYPE_MaterialRequisition);
|
mrp.setOrderType(MPPMRP.ORDERTYPE_MaterialRequisition);
|
||||||
mrp.setTypeMRP(MPPMRP.TYPEMRP_Supply);
|
mrp.setTypeMRP(MPPMRP.TYPEMRP_Supply);
|
||||||
mrp.setIsAvailable(true);
|
mrp.setIsAvailable(true);
|
||||||
}
|
}
|
||||||
|
mrp.setAD_Org_ID(r.getAD_Org_ID());
|
||||||
mrp.setName("MRP");
|
mrp.setName("MRP");
|
||||||
mrp.setDescription(rl.getDescription());
|
mrp.setDescription(rl.getDescription());
|
||||||
|
mrp.setDateOrdered(r.getDateRequired());
|
||||||
mrp.setDatePromised(r.getDateRequired());
|
mrp.setDatePromised(r.getDateRequired());
|
||||||
mrp.setDateStartSchedule(r.getDateRequired());
|
mrp.setDateStartSchedule(r.getDateRequired());
|
||||||
mrp.setDateFinishSchedule(r.getDateRequired());
|
mrp.setDateFinishSchedule(r.getDateRequired());
|
||||||
mrp.setDateOrdered(r.getDateRequired());
|
|
||||||
mrp.setM_Product_ID(rl.getM_Product_ID());
|
mrp.setM_Product_ID(rl.getM_Product_ID());
|
||||||
mrp.setM_Warehouse_ID(r.getM_Warehouse_ID());
|
mrp.setM_Warehouse_ID(r.getM_Warehouse_ID());
|
||||||
// We create a MRP record only for Not Ordered Qty. The Order will generate a MRP record for Ordered Qty.
|
// We create a MRP record only for Not Ordered Qty. The Order will generate a MRP record for Ordered Qty.
|
||||||
|
@ -605,12 +679,9 @@ public class MPPMRP extends X_PP_MRP
|
||||||
*/
|
*/
|
||||||
public static BigDecimal getQtyOnHand(Properties ctx, int M_Warehouse_ID ,int M_Product_ID,String trxName)
|
public static BigDecimal getQtyOnHand(Properties ctx, int M_Warehouse_ID ,int M_Product_ID,String trxName)
|
||||||
{
|
{
|
||||||
final String sql = "SELECT SUM(bomQtyOnHand (M_Product_ID,?,0)) AS OnHand FROM M_Product"
|
final String sql = "SELECT COALESCE(bomQtyOnHand (M_Product_ID,?,0),0) FROM M_Product"
|
||||||
+" WHERE AD_Client_ID=? AND M_Product_ID=?";
|
+" WHERE AD_Client_ID=? AND M_Product_ID=?";
|
||||||
BigDecimal QtyOnHand = DB.getSQLValueBDEx(trxName, sql, new Object[]{M_Warehouse_ID,Env.getAD_Client_ID(ctx),M_Product_ID});
|
return DB.getSQLValueBDEx(trxName, sql, new Object[]{M_Warehouse_ID,Env.getAD_Client_ID(ctx),M_Product_ID});
|
||||||
if (QtyOnHand == null)
|
|
||||||
QtyOnHand = Env.ZERO;
|
|
||||||
return QtyOnHand;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -624,9 +695,17 @@ public class MPPMRP extends X_PP_MRP
|
||||||
*/
|
*/
|
||||||
public static BigDecimal getQtyReserved(Properties ctx, int M_Warehouse_ID ,int M_Product_ID, Timestamp To,String trxName)
|
public static BigDecimal getQtyReserved(Properties ctx, int M_Warehouse_ID ,int M_Product_ID, Timestamp To,String trxName)
|
||||||
{
|
{
|
||||||
StringBuffer sql = new StringBuffer("SELECT SUM(Qty) FROM PP_MRP WHERE TypeMRP=? AND DocStatus IN ('IN','CO')");
|
final String sql = "SELECT SUM(Qty) FROM PP_MRP WHERE "
|
||||||
sql.append(" AND OrderType IN ('SOO','MOP','DOO') AND AD_Client_ID= ? AND DatePromised <=? AND M_Warehouse_ID =? AND M_Product_ID=?");
|
+" TypeMRP=?"
|
||||||
BigDecimal qty = DB.getSQLValueBDEx(trxName, sql.toString(), new Object[]{MPPMRP.TYPEMRP_Demand,Env.getAD_Client_ID(ctx), To , M_Warehouse_ID, M_Product_ID});
|
+" AND DocStatus IN ('IN','CO')"
|
||||||
|
+" AND OrderType IN ('SOO','MOP','DOO')"
|
||||||
|
+" AND AD_Client_ID=? AND M_Warehouse_ID =? AND M_Product_ID=?"
|
||||||
|
+" AND DatePromised <=?";
|
||||||
|
BigDecimal qty = DB.getSQLValueBDEx(trxName, sql, new Object[]{
|
||||||
|
MPPMRP.TYPEMRP_Demand,
|
||||||
|
Env.getAD_Client_ID(ctx),M_Warehouse_ID, M_Product_ID,
|
||||||
|
To,
|
||||||
|
});
|
||||||
// SQL may return no rows or null
|
// SQL may return no rows or null
|
||||||
if (qty == null)
|
if (qty == null)
|
||||||
return Env.ZERO;
|
return Env.ZERO;
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.adempiere.exceptions.AdempiereException;
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
|
import org.adempiere.exceptions.DocTypeNotFoundException;
|
||||||
import org.compiere.model.MAcctSchema;
|
import org.compiere.model.MAcctSchema;
|
||||||
import org.compiere.model.MClient;
|
import org.compiere.model.MClient;
|
||||||
import org.compiere.model.MCost;
|
import org.compiere.model.MCost;
|
||||||
|
@ -67,65 +68,13 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
||||||
/** Product */
|
/** Product */
|
||||||
private MProduct m_product = null;
|
private MProduct m_product = null;
|
||||||
|
|
||||||
/**
|
public static MPPOrder forC_OrderLine_ID(Properties ctx, int C_OrderLine_ID, String trxName)
|
||||||
* Create new Order by copying
|
|
||||||
* @param ctx context
|
|
||||||
* @param C_Order_ID invoice
|
|
||||||
* @param dateDoc date of the document date
|
|
||||||
* @param counter create counter links
|
|
||||||
* @return Order
|
|
||||||
*/
|
|
||||||
public static MPPOrder copyFrom(MPPOrder from, Timestamp dateDoc, int C_DocTypeTarget_ID,
|
|
||||||
boolean isSOTrx, boolean counter)
|
|
||||||
{
|
{
|
||||||
MPPOrder to = new MPPOrder(from.getCtx(), 0, "PP_Order");
|
return new Query(ctx, MPPOrder.Table_Name, COLUMNNAME_C_OrderLine_ID+"=?", trxName)
|
||||||
PO.copyValues(from, to, from.getAD_Client_ID(), from.getAD_Org_ID());
|
.setParameters(new Object[]{C_OrderLine_ID})
|
||||||
to.setPP_Order_ID(0);
|
.firstOnly();
|
||||||
to.set_ValueNoCheck("DocumentNo", null);
|
}
|
||||||
//
|
|
||||||
to.setDocStatus(DOCSTATUS_Drafted); // Draft
|
|
||||||
to.setDocAction(DOCACTION_Prepare);
|
|
||||||
//
|
|
||||||
//to.setC_DocType_ID(this.C_DOCTYPE_ID_ManufacturingOrder);
|
|
||||||
//to.setC_DocTypeTarget_ID(C_DocTypeTarget_ID);
|
|
||||||
to.setIsSOTrx(isSOTrx);
|
|
||||||
//
|
|
||||||
to.setIsSelected(false);
|
|
||||||
/*to.setDateOrdered (dateDoc);
|
|
||||||
to.setDateAcct (dateDoc);
|
|
||||||
to.setDatePromised (dateDoc);
|
|
||||||
to.setDatePrinted(null);
|
|
||||||
to.setIsPrinted (false);
|
|
||||||
//*/
|
|
||||||
to.setIsApproved(false);
|
|
||||||
/*to.setIsCreditApproved(false);
|
|
||||||
to.setC_Payment_ID(0);
|
|
||||||
to.setC_CashLine_ID(0);
|
|
||||||
// Amounts are updated when adding lines
|
|
||||||
to.setGrandTotal(Env.ZERO);
|
|
||||||
to.setTotalLines(Env.ZERO);
|
|
||||||
//
|
|
||||||
to.setIsDelivered(false);
|
|
||||||
to.setIsInvoiced(false);
|
|
||||||
to.setIsSelfService(false);
|
|
||||||
to.setIsTransferred (false);*/
|
|
||||||
to.setPosted(false);
|
|
||||||
to.setProcessed(false);
|
|
||||||
/*if (counter)
|
|
||||||
to.setRef_Order_ID(from.getC_Order_ID());
|
|
||||||
else
|
|
||||||
to.setRef_Order_ID(0);
|
|
||||||
//
|
|
||||||
*/
|
|
||||||
to.saveEx();
|
|
||||||
/*if (counter)
|
|
||||||
from.setRef_Order_ID(to.getC_Order_ID());
|
|
||||||
|
|
||||||
if (to.copyLinesFrom(from, counter) == 0)
|
|
||||||
throw new IllegalStateException("Could not create Order Lines");
|
|
||||||
*/
|
|
||||||
return to;
|
|
||||||
} // copyFrom
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
|
@ -136,7 +85,11 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
||||||
{
|
{
|
||||||
super(ctx, PP_Order_ID, trxName);
|
super(ctx, PP_Order_ID, trxName);
|
||||||
// New
|
// New
|
||||||
if (PP_Order_ID == 0) {
|
if (PP_Order_ID == 0)
|
||||||
|
{
|
||||||
|
setQtyDelivered(Env.ZERO);
|
||||||
|
setQtyReject(Env.ZERO);
|
||||||
|
setQtyScrap(Env.ZERO);
|
||||||
setIsSelected(false);
|
setIsSelected(false);
|
||||||
setIsSOTrx(false);
|
setIsSOTrx(false);
|
||||||
setIsApproved(false);
|
setIsApproved(false);
|
||||||
|
@ -144,17 +97,10 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
||||||
setProcessed(false);
|
setProcessed(false);
|
||||||
setProcessing(false);
|
setProcessing(false);
|
||||||
setPosted(false);
|
setPosted(false);
|
||||||
MDocType[] doc = MDocType.getOfDocBaseType(getCtx(), MDocType.DOCBASETYPE_ManufacturingOrder);
|
//
|
||||||
if(doc == null)
|
setC_DocType_ID(0);
|
||||||
{
|
setC_DocTypeTarget_ID(MDocType.DOCBASETYPE_ManufacturingOrder);
|
||||||
throw new IllegalArgumentException ("C_DocType_ID is mandatory.");
|
//
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setC_DocType_ID(doc[0].getC_DocType_ID());
|
|
||||||
setC_DocTypeTarget_ID(doc[0].getC_DocType_ID());
|
|
||||||
}
|
|
||||||
|
|
||||||
//set_ValueNoCheck("DocumentNo", null);
|
//set_ValueNoCheck("DocumentNo", null);
|
||||||
setDocStatus(DOCSTATUS_Drafted);
|
setDocStatus(DOCSTATUS_Drafted);
|
||||||
setDocAction(DOCACTION_Prepare);
|
setDocAction(DOCACTION_Prepare);
|
||||||
|
@ -229,18 +175,47 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get BOM Lines of PP Order
|
* Get BOM Lines of PP Order
|
||||||
|
* @param requery
|
||||||
* @return Order BOM Lines
|
* @return Order BOM Lines
|
||||||
*/
|
*/
|
||||||
public MPPOrderBOMLine[] getLines()
|
public MPPOrderBOMLine[] getLines(boolean requery)
|
||||||
{
|
{
|
||||||
|
if (m_lines != null && !requery)
|
||||||
|
{
|
||||||
|
set_TrxName(m_lines, get_TrxName());
|
||||||
|
return m_lines;
|
||||||
|
}
|
||||||
String whereClause = MPPOrderBOMLine.COLUMNNAME_PP_Order_ID+"=?";
|
String whereClause = MPPOrderBOMLine.COLUMNNAME_PP_Order_ID+"=?";
|
||||||
//
|
|
||||||
List<MPPOrderBOMLine> list = new Query(getCtx(), MPPOrderBOMLine.Table_Name, whereClause, get_TrxName())
|
List<MPPOrderBOMLine> list = new Query(getCtx(), MPPOrderBOMLine.Table_Name, whereClause, get_TrxName())
|
||||||
.setParameters(new Object[]{getPP_Order_ID()})
|
.setParameters(new Object[]{getPP_Order_ID()})
|
||||||
.setOrderBy(MPPOrderBOMLine.COLUMNNAME_Line)
|
.setOrderBy(MPPOrderBOMLine.COLUMNNAME_Line)
|
||||||
.list();
|
.list();
|
||||||
return list.toArray(new MPPOrderBOMLine[list.size()]);
|
m_lines = list.toArray(new MPPOrderBOMLine[list.size()]);
|
||||||
} // getLines
|
return m_lines;
|
||||||
|
}
|
||||||
|
private MPPOrderBOMLine[] m_lines = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get BOM Lines of PP Order
|
||||||
|
* @return Order BOM Lines
|
||||||
|
*/
|
||||||
|
public MPPOrderBOMLine[] getLines()
|
||||||
|
{
|
||||||
|
return getLines(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setC_DocTypeTarget_ID(String docBaseType)
|
||||||
|
{
|
||||||
|
MDocType[] doc = MDocType.getOfDocBaseType(getCtx(), docBaseType);
|
||||||
|
if(doc == null)
|
||||||
|
{
|
||||||
|
throw new DocTypeNotFoundException(docBaseType, "");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setC_DocTypeTarget_ID(doc[0].get_ID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setProcessed(boolean processed)
|
public void setProcessed(boolean processed)
|
||||||
|
@ -297,32 +272,9 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( is_ValueChanged(MPPOrder.COLUMNNAME_QtyEntered) &&
|
if( is_ValueChanged(MPPOrder.COLUMNNAME_QtyEntered) && getDocStatus().equals(MPPOrder.DOCSTATUS_Drafted))
|
||||||
getDocStatus().equals(MPPOrder.DOCSTATUS_Drafted))
|
|
||||||
{
|
{
|
||||||
for(MPPOrderBOMLine line : getLines())
|
deleteWorkflowAndBOM();
|
||||||
{
|
|
||||||
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();
|
explotion();
|
||||||
}
|
}
|
||||||
if( is_ValueChanged(MPPOrder.COLUMNNAME_QtyEntered) && !getDocStatus().equals(MPPOrder.DOCSTATUS_Drafted))
|
if( is_ValueChanged(MPPOrder.COLUMNNAME_QtyEntered) && !getDocStatus().equals(MPPOrder.DOCSTATUS_Drafted))
|
||||||
|
@ -347,23 +299,37 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
||||||
{
|
{
|
||||||
String whereClause = "PP_Order_ID=? AND AD_Client_ID=?";
|
String whereClause = "PP_Order_ID=? AND AD_Client_ID=?";
|
||||||
Object[] params = new Object[]{get_ID(), getAD_Client_ID()};
|
Object[] params = new Object[]{get_ID(), getAD_Client_ID()};
|
||||||
|
//
|
||||||
// Delete Cost:
|
|
||||||
deletePO(MPPOrderCost.Table_Name, whereClause, params);
|
deletePO(MPPOrderCost.Table_Name, whereClause, params);
|
||||||
// Delete workflow:
|
deleteWorkflowAndBOM();
|
||||||
DB.executeUpdateEx("UPDATE PP_Order_Workflow SET PP_Order_Node_ID=NULL WHERE "+whereClause, params, get_TrxName()); // Reset workflow start node
|
|
||||||
deletePO(X_PP_Order_Node_Asset.Table_Name, whereClause, params);
|
|
||||||
deletePO(X_PP_Order_Node_Product.Table_Name, whereClause, params);
|
|
||||||
deletePO(MPPOrderNodeNext.Table_Name, whereClause, params);
|
|
||||||
deletePO(MPPOrderNode.Table_Name, whereClause, params);
|
|
||||||
deletePO(MPPOrderWorkflow.Table_Name, whereClause, params);
|
|
||||||
// Delete BOM:
|
|
||||||
deletePO(MPPOrderBOMLine.Table_Name, whereClause, params);
|
|
||||||
deletePO(MPPOrderBOM.Table_Name, whereClause, params);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} // beforeDelete
|
} // beforeDelete
|
||||||
|
|
||||||
|
private void deleteWorkflowAndBOM()
|
||||||
|
{
|
||||||
|
// New record, nothing to do
|
||||||
|
if (get_ID() <= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
String whereClause = "PP_Order_ID=? AND AD_Client_ID=?";
|
||||||
|
Object[] params = new Object[]{get_ID(), getAD_Client_ID()};
|
||||||
|
// Reset workflow start node
|
||||||
|
DB.executeUpdateEx("UPDATE PP_Order_Workflow SET PP_Order_Node_ID=NULL WHERE "+whereClause, params, get_TrxName());
|
||||||
|
// Delete workflow:
|
||||||
|
deletePO(X_PP_Order_Node_Asset.Table_Name, whereClause, params);
|
||||||
|
deletePO(X_PP_Order_Node_Product.Table_Name, whereClause, params);
|
||||||
|
deletePO(MPPOrderNodeNext.Table_Name, whereClause, params);
|
||||||
|
deletePO(MPPOrderNode.Table_Name, whereClause, params);
|
||||||
|
deletePO(MPPOrderWorkflow.Table_Name, whereClause, params);
|
||||||
|
// Delete BOM:
|
||||||
|
deletePO(MPPOrderBOMLine.Table_Name, whereClause, params);
|
||||||
|
deletePO(MPPOrderBOM.Table_Name, whereClause, params);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public boolean processIt(String processAction)
|
public boolean processIt(String processAction)
|
||||||
{
|
{
|
||||||
m_processMsg = null;
|
m_processMsg = null;
|
||||||
|
@ -651,13 +617,17 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
||||||
return DocAction.STATUS_Completed;
|
return DocAction.STATUS_Completed;
|
||||||
} // completeIt
|
} // completeIt
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the Quantity from all BOM Lines is available (QtyOnHand >= QtyRequired)
|
||||||
|
* @return true if entire Qty is available for this Order
|
||||||
|
*/
|
||||||
public boolean isAvailable()
|
public boolean isAvailable()
|
||||||
{
|
{
|
||||||
String whereClause = "QtyOnHand - QtyRequiered < 0 AND PP_Order_ID=?";
|
String whereClause = "QtyOnHand >= QtyRequiered AND PP_Order_ID=?";
|
||||||
boolean notAvailable = new Query(getCtx(), X_RV_PP_Order_Storage.Table_Name, whereClause, get_TrxName())
|
boolean available = new Query(getCtx(), "RV_PP_Order_Storage", whereClause, get_TrxName())
|
||||||
.setParameters(new Object[]{get_ID()})
|
.setParameters(new Object[]{get_ID()})
|
||||||
.match();
|
.match();
|
||||||
return !notAvailable;
|
return available;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean voidIt()
|
public boolean voidIt()
|
||||||
|
@ -879,7 +849,11 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
||||||
.first();
|
.first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void explotion()
|
/**
|
||||||
|
* Create PP_Order_BOM from PP_Product_BOM.
|
||||||
|
* Create PP_Order_Workflow from AD_Workflow.
|
||||||
|
*/
|
||||||
|
private void explotion()
|
||||||
{
|
{
|
||||||
// Create BOM Head
|
// Create BOM Head
|
||||||
MPPProductBOM PP_Product_BOM = MPPProductBOM.get(getCtx(), getPP_Product_BOM_ID());
|
MPPProductBOM PP_Product_BOM = MPPProductBOM.get(getCtx(), getPP_Product_BOM_ID());
|
||||||
|
@ -924,28 +898,22 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
||||||
|
|
||||||
for (MWFNodeNext AD_WF_NodeNext : AD_WF_Node.getTransitions(getAD_Client_ID()))
|
for (MWFNodeNext AD_WF_NodeNext : AD_WF_Node.getTransitions(getAD_Client_ID()))
|
||||||
{
|
{
|
||||||
MPPOrderNodeNext nodenext = new MPPOrderNodeNext(AD_WF_NodeNext, PP_Order_Node, get_TrxName());
|
MPPOrderNodeNext nodenext = new MPPOrderNodeNext(AD_WF_NodeNext, PP_Order_Node);
|
||||||
nodenext.setAD_Org_ID(getAD_Org_ID());
|
nodenext.setAD_Org_ID(getAD_Org_ID());
|
||||||
nodenext.saveEx();
|
nodenext.saveEx();
|
||||||
}// for NodeNext
|
}// for NodeNext
|
||||||
|
|
||||||
for (MPPWFNodeProduct wfnp : MPPWFNodeProduct.get(getCtx(), AD_WF_Node.get_ID() , get_TrxName()))
|
for (MPPWFNodeProduct wfnp : MPPWFNodeProduct.forAD_WF_Node_ID(getCtx(), AD_WF_Node.get_ID()))
|
||||||
{
|
{
|
||||||
MPPOrderNodeProduct nodeorderproduct = new MPPOrderNodeProduct(wfnp);
|
MPPOrderNodeProduct nodeorderproduct = new MPPOrderNodeProduct(wfnp, PP_Order_Node);
|
||||||
nodeorderproduct.setAD_Org_ID(getAD_Org_ID());
|
nodeorderproduct.setAD_Org_ID(getAD_Org_ID());
|
||||||
nodeorderproduct.setPP_Order_ID(getPP_Order_ID());
|
|
||||||
nodeorderproduct.setPP_Order_Workflow_ID(PP_Order_Node.getPP_Order_Workflow_ID());
|
|
||||||
nodeorderproduct.setPP_Order_Node_ID(PP_Order_Node.getPP_Order_Node_ID());
|
|
||||||
nodeorderproduct.saveEx();
|
nodeorderproduct.saveEx();
|
||||||
}// for NodeNext
|
}
|
||||||
|
|
||||||
for (MPPWFNodeAsset wfna : MPPWFNodeAsset.get(getCtx(), AD_WF_Node.get_ID() , get_TrxName()))
|
for (MPPWFNodeAsset wfna : MPPWFNodeAsset.forAD_WF_Node_ID(getCtx(), AD_WF_Node.get_ID()))
|
||||||
{
|
{
|
||||||
MPPOrderNodeAsset nodeorderasset = new MPPOrderNodeAsset(wfna);
|
MPPOrderNodeAsset nodeorderasset = new MPPOrderNodeAsset(wfna, PP_Order_Node);
|
||||||
nodeorderasset.setAD_Org_ID(getAD_Org_ID());
|
nodeorderasset.setAD_Org_ID(getAD_Org_ID());
|
||||||
nodeorderasset.setPP_Order_ID(getPP_Order_ID());
|
|
||||||
nodeorderasset.setPP_Order_Workflow_ID(PP_Order_Node.getPP_Order_Workflow_ID());
|
|
||||||
nodeorderasset.setPP_Order_Node_ID(PP_Order_Node.getPP_Order_Node_ID());
|
|
||||||
nodeorderasset.saveEx();
|
nodeorderasset.saveEx();
|
||||||
}
|
}
|
||||||
}// for node
|
}// for node
|
||||||
|
@ -956,7 +924,8 @@ public class MPPOrder extends X_PP_Order implements DocAction
|
||||||
for (MPPOrderNode orderNode : PP_Order_Workflow.getNodes(false, getAD_Client_ID()))
|
for (MPPOrderNode orderNode : PP_Order_Workflow.getNodes(false, getAD_Client_ID()))
|
||||||
{
|
{
|
||||||
// set workflow start node
|
// set workflow start node
|
||||||
if (PP_Order_Workflow.getAD_WF_Node_ID() == orderNode.getAD_WF_Node_ID()) {
|
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());
|
PP_Order_Workflow.setPP_Order_Node_ID(orderNode.getPP_Order_Node_ID());
|
||||||
}
|
}
|
||||||
// set node next
|
// set node next
|
||||||
|
|
|
@ -17,34 +17,42 @@
|
||||||
package org.eevolution.model;
|
package org.eevolution.model;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.adempiere.exceptions.AdempiereException;
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
|
import org.adempiere.exceptions.DBException;
|
||||||
import org.compiere.model.MProduct;
|
import org.compiere.model.MProduct;
|
||||||
|
import org.compiere.model.MUOM;
|
||||||
|
import org.compiere.model.MWarehouse;
|
||||||
|
import org.compiere.model.Query;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PP Order BOM Line Model.
|
* PP Order BOM Line Model.
|
||||||
*
|
|
||||||
* @author Victor Perez www.e-evolution.com
|
|
||||||
* @version $Id: MOrderLine.java,v 1.22 2004/03/22 07:15:03 vpj-cd Exp $
|
|
||||||
*
|
*
|
||||||
|
* @author Victor Perez www.e-evolution.com
|
||||||
* @author Teo Sarca, www.arhipac.ro
|
* @author Teo Sarca, www.arhipac.ro
|
||||||
*/
|
*/
|
||||||
public class MPPOrderBOMLine extends X_PP_Order_BOMLine
|
public class MPPOrderBOMLine extends X_PP_Order_BOMLine
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
public static MPPOrderBOMLine forM_Product_ID(Properties ctx, int PP_Order_ID, int M_Product_ID, String trxName)
|
||||||
* Default Constructor
|
|
||||||
* @param ctx context
|
|
||||||
* @param C_OrderLine_ID order line to load
|
|
||||||
*/
|
|
||||||
public MPPOrderBOMLine(Properties ctx, int PP_Order_BOMLine_ID,String trxName)
|
|
||||||
{
|
{
|
||||||
super (ctx, PP_Order_BOMLine_ID,trxName);
|
final String whereClause = COLUMNNAME_PP_Order_ID+"=? AND "+COLUMNNAME_M_Product_ID+"=?";
|
||||||
|
return new Query(ctx, Table_Name, whereClause, trxName)
|
||||||
|
.setParameters(new Object[]{PP_Order_ID, M_Product_ID})
|
||||||
|
.firstOnly();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MPPOrderBOMLine(Properties ctx, int PP_Order_BOMLine_ID, String trxName)
|
||||||
|
{
|
||||||
|
super (ctx, PP_Order_BOMLine_ID, trxName);
|
||||||
if (PP_Order_BOMLine_ID == 0)
|
if (PP_Order_BOMLine_ID == 0)
|
||||||
{
|
{
|
||||||
setQtyDelivered(Env.ZERO);
|
setQtyDelivered(Env.ZERO);
|
||||||
|
@ -57,11 +65,6 @@ public class MPPOrderBOMLine extends X_PP_Order_BOMLine
|
||||||
} // PP_Order_BOMLine_ID
|
} // PP_Order_BOMLine_ID
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load Constructor
|
|
||||||
* @param ctx context
|
|
||||||
* @param rs result set record
|
|
||||||
*/
|
|
||||||
public MPPOrderBOMLine(Properties ctx, ResultSet rs,String trxName)
|
public MPPOrderBOMLine(Properties ctx, ResultSet rs,String trxName)
|
||||||
{
|
{
|
||||||
super (ctx, rs,trxName);
|
super (ctx, rs,trxName);
|
||||||
|
@ -106,20 +109,27 @@ public class MPPOrderBOMLine extends X_PP_Order_BOMLine
|
||||||
setBackflushGroup(bomLine.getBackflushGroup());
|
setBackflushGroup(bomLine.getBackflushGroup());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parent (PP_Order)
|
||||||
|
*/
|
||||||
private MPPOrder m_parent = null;
|
private MPPOrder m_parent = null;
|
||||||
|
|
||||||
/** Qty used for exploding this BOM Line */
|
/**
|
||||||
|
* Qty used for exploding this BOM Line.
|
||||||
|
* When ComponentType is Phantom, it is set on beforeSave as QtyRequired and reset on afterSave.
|
||||||
|
*/
|
||||||
private BigDecimal m_qtyToExplode = null;
|
private BigDecimal m_qtyToExplode = null;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean beforeSave(boolean newRecord) {
|
protected boolean beforeSave(boolean newRecord)
|
||||||
|
{
|
||||||
// Get Line No
|
// Get Line No
|
||||||
if (getLine() == 0)
|
if (getLine() == 0)
|
||||||
{
|
{
|
||||||
String sql = "SELECT COALESCE(MAX("+COLUMNNAME_Line+"),0)+10 FROM "+Table_Name
|
String sql = "SELECT COALESCE(MAX("+COLUMNNAME_Line+"),0)+10 FROM "+Table_Name
|
||||||
+" WHERE "+COLUMNNAME_PP_Order_ID+"=?";
|
+" WHERE "+COLUMNNAME_PP_Order_ID+"=?";
|
||||||
int ii = DB.getSQLValue (get_TrxName(), sql, getPP_Order_ID());
|
int ii = DB.getSQLValueEx (get_TrxName(), sql, getPP_Order_ID());
|
||||||
setLine (ii);
|
setLine (ii);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,15 +157,15 @@ public class MPPOrderBOMLine extends X_PP_Order_BOMLine
|
||||||
MProduct parent = MProduct.get(getCtx(), getM_Product_ID());
|
MProduct parent = MProduct.get(getCtx(), getM_Product_ID());
|
||||||
int PP_Product_BOM_ID = MPPProductBOM.getBOMSearchKey(getCtx(), parent);
|
int PP_Product_BOM_ID = MPPProductBOM.getBOMSearchKey(getCtx(), parent);
|
||||||
if (PP_Product_BOM_ID <= 0)
|
if (PP_Product_BOM_ID <= 0)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
MPPProductBOM bom = MPPProductBOM.get(getCtx(), PP_Product_BOM_ID);
|
MPPProductBOM bom = MPPProductBOM.get(getCtx(), PP_Product_BOM_ID);
|
||||||
if (bom != null)
|
if (bom != null)
|
||||||
{
|
{
|
||||||
MPPProductBOMLine[] PP_Product_BOMline = bom.getLines();
|
for(MPPProductBOMLine PP_Product_BOMline : bom.getLines())
|
||||||
for(int i = 0 ; i < PP_Product_BOMline.length ; i++ )
|
|
||||||
{
|
{
|
||||||
MPPOrderBOMLine PP_Order_BOMLine = new MPPOrderBOMLine(PP_Product_BOMline[i],
|
MPPOrderBOMLine PP_Order_BOMLine = new MPPOrderBOMLine(PP_Product_BOMline,
|
||||||
getPP_Order_ID(), getPP_Order_BOM_ID(),
|
getPP_Order_ID(), getPP_Order_BOM_ID(),
|
||||||
getM_Warehouse_ID(),
|
getM_Warehouse_ID(),
|
||||||
get_TrxName());
|
get_TrxName());
|
||||||
|
@ -176,67 +186,159 @@ public class MPPOrderBOMLine extends X_PP_Order_BOMLine
|
||||||
return MProduct.get(getCtx(), getM_Product_ID());
|
return MProduct.get(getCtx(), getM_Product_ID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MUOM getC_UOM()
|
||||||
|
{
|
||||||
|
return MUOM.get(getCtx(), getC_UOM_ID());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MWarehouse getM_Warehouse()
|
||||||
|
{
|
||||||
|
return MWarehouse.get(getCtx(), getM_Warehouse_ID());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Parent
|
* Get Parent
|
||||||
* @return parent
|
* @return PP_Order
|
||||||
*/
|
*/
|
||||||
public MPPOrder getParent()
|
public MPPOrder getParent()
|
||||||
{
|
{
|
||||||
if (m_parent == null)
|
int id = getPP_Order_ID();
|
||||||
m_parent = new MPPOrder(getCtx(), getPP_Order_ID(), get_TrxName());
|
if (id <= 0)
|
||||||
|
{
|
||||||
|
m_parent = null;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (m_parent == null || m_parent.get_ID() != id)
|
||||||
|
{
|
||||||
|
m_parent = new MPPOrder(getCtx(), id, get_TrxName());
|
||||||
|
}
|
||||||
return m_parent;
|
return m_parent;
|
||||||
} // getParent
|
} // getParent
|
||||||
|
|
||||||
public void setQtyOrdered(BigDecimal QtyOrdered)
|
public void setQtyOrdered(BigDecimal QtyOrdered)
|
||||||
{
|
{
|
||||||
// Set Qty Required
|
BigDecimal multiplier = Env.ZERO;
|
||||||
if (isQtyPercentage())
|
if (isQtyPercentage())
|
||||||
{
|
{
|
||||||
BigDecimal qty = getQtyBatch().multiply(QtyOrdered);
|
multiplier = getQtyBatch().divide(Env.ONEHUNDRED, 8, RoundingMode.UP);
|
||||||
if (getComponentType().equals(COMPONENTTYPE_Component)
|
|
||||||
|| getComponentType().equals(COMPONENTTYPE_Phantom))
|
|
||||||
{
|
|
||||||
setQtyRequiered(qty.divide(Env.ONEHUNDRED, 8, BigDecimal.ROUND_UP));
|
|
||||||
}
|
|
||||||
else if (getComponentType().equals(COMPONENTTYPE_Packing))
|
|
||||||
{
|
|
||||||
setQtyRequiered(qty.divide(Env.ONEHUNDRED, 8, BigDecimal.ROUND_UP));
|
|
||||||
}
|
|
||||||
else if (getComponentType().equals(COMPONENTTYPE_Tools))
|
|
||||||
{
|
|
||||||
setQtyRequiered(getQtyBOM());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new AdempiereException("@NotSupported@ @ComponentType@ "+getComponentType());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (getComponentType().equals(COMPONENTTYPE_Component)
|
multiplier = getQtyBOM();
|
||||||
|| getComponentType().equals(COMPONENTTYPE_Phantom))
|
|
||||||
{
|
|
||||||
setQtyRequiered(getQtyBOM().multiply(QtyOrdered));
|
|
||||||
}
|
|
||||||
else if (getComponentType().equals(COMPONENTTYPE_Packing))
|
|
||||||
{
|
|
||||||
setQtyRequiered(getQtyBOM().multiply(QtyOrdered));
|
|
||||||
}
|
|
||||||
else if (getComponentType().equals(COMPONENTTYPE_Tools))
|
|
||||||
{
|
|
||||||
setQtyRequiered(getQtyBOM());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new AdempiereException("@NotSupported@ @ComponentType@ "+getComponentType());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
BigDecimal qty = QtyOrdered.multiply(multiplier).setScale(8, RoundingMode.UP);
|
||||||
|
|
||||||
|
if (isComponentType(COMPONENTTYPE_Component,COMPONENTTYPE_Phantom
|
||||||
|
,COMPONENTTYPE_Packing
|
||||||
|
,COMPONENTTYPE_ByProduct))
|
||||||
|
{
|
||||||
|
setQtyRequiered(qty);
|
||||||
|
}
|
||||||
|
else if (isComponentType(COMPONENTTYPE_Tools))
|
||||||
|
{
|
||||||
|
setQtyRequiered(multiplier);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new AdempiereException("@NotSupported@ @ComponentType@ "+getComponentType());
|
||||||
|
}
|
||||||
|
//
|
||||||
// Set Scrap of Component
|
// Set Scrap of Component
|
||||||
BigDecimal Scrap = getScrap();
|
BigDecimal Scrap = getScrap();
|
||||||
if (Scrap.signum() != 0) {
|
if (Scrap.signum() != 0)
|
||||||
|
{
|
||||||
Scrap = Scrap.divide(Env.ONEHUNDRED, 8, BigDecimal.ROUND_UP);
|
Scrap = Scrap.divide(Env.ONEHUNDRED, 8, BigDecimal.ROUND_UP);
|
||||||
setQtyRequiered(getQtyRequiered().divide(Env.ONE.subtract(Scrap), 8, BigDecimal.ROUND_HALF_UP));
|
setQtyRequiered(getQtyRequiered().divide(Env.ONE.subtract(Scrap), 8, BigDecimal.ROUND_HALF_UP));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Qty Open (Requiered - Delivered)
|
||||||
|
*/
|
||||||
|
public BigDecimal getQtyOpen()
|
||||||
|
{
|
||||||
|
return getQtyRequiered().subtract(getQtyDelivered());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Storage Qty On Hand */
|
||||||
|
private BigDecimal m_qtyOnHand = null;
|
||||||
|
/** Storage Qty Available */
|
||||||
|
private BigDecimal m_qtyAvailable = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load Storage Info
|
||||||
|
* @param reload
|
||||||
|
*/
|
||||||
|
private void loadStorage(boolean reload)
|
||||||
|
{
|
||||||
|
if (!reload && m_qtyOnHand != null && m_qtyAvailable != null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
final String sql = "SELECT "
|
||||||
|
+" bomQtyAvailable("+COLUMNNAME_M_Product_ID+", "+COLUMNNAME_M_Warehouse_ID+", 0)"
|
||||||
|
+",bomQtyOnHand("+COLUMNNAME_M_Product_ID+", "+COLUMNNAME_M_Warehouse_ID+", 0)"
|
||||||
|
+" FROM "+Table_Name
|
||||||
|
+" WHERE "+COLUMNNAME_PP_Order_BOMLine_ID+"=?";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt = DB.prepareStatement(sql, get_TrxName());
|
||||||
|
DB.setParameters(pstmt, new Object[]{get_ID()});
|
||||||
|
rs = pstmt.executeQuery();
|
||||||
|
if (rs.next())
|
||||||
|
{
|
||||||
|
m_qtyAvailable = rs.getBigDecimal(1);
|
||||||
|
m_qtyOnHand = rs.getBigDecimal(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
throw new DBException(e, sql);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DB.close(rs, pstmt);
|
||||||
|
rs = null; pstmt = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return storage Available Qty
|
||||||
|
*/
|
||||||
|
public BigDecimal getQtyAvailable()
|
||||||
|
{
|
||||||
|
loadStorage(false);
|
||||||
|
return m_qtyAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return storage Qty On Hand
|
||||||
|
*/
|
||||||
|
public BigDecimal getQtyOnHand()
|
||||||
|
{
|
||||||
|
loadStorage(false);
|
||||||
|
return m_qtyOnHand;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param componentTypes one or more component types
|
||||||
|
* @return true of Component Type is any of following types
|
||||||
|
*/
|
||||||
|
public boolean isComponentType(String ... componentTypes)
|
||||||
|
{
|
||||||
|
String currentType = getComponentType();
|
||||||
|
for (String type : componentTypes)
|
||||||
|
{
|
||||||
|
if (currentType.equals(type))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,10 @@ import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shipment Material Allocation
|
* Cost Collector Material Allocation
|
||||||
*
|
*
|
||||||
* @author Victor Perez www.e-evolution.com
|
* @author Victor Perez www.e-evolution.com
|
||||||
* @version $Id: MPPOrderBOMLineMA.java,v 1.1 2005/04/01 05:59:48 vpj-cd Exp $
|
* @author Teo Sarca, http://www.arhipac.ro
|
||||||
*
|
|
||||||
* @author Teo Sarca, http://www.arhipac.ro
|
|
||||||
*/
|
*/
|
||||||
public class MPPOrderBOMLineMA extends X_PP_Order_BOMLineMA
|
public class MPPOrderBOMLineMA extends X_PP_Order_BOMLineMA
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,33 +16,25 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.eevolution.model;
|
package org.eevolution.model;
|
||||||
|
|
||||||
import java.awt.Point;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.adempiere.exceptions.AdempiereException;
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
import org.compiere.model.MColumn;
|
|
||||||
import org.compiere.model.MResource;
|
import org.compiere.model.MResource;
|
||||||
import org.compiere.model.MUOM;
|
import org.compiere.model.MUOM;
|
||||||
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;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Msg;
|
|
||||||
import org.compiere.wf.MWFNode;
|
import org.compiere.wf.MWFNode;
|
||||||
import org.compiere.wf.MWorkflow;
|
|
||||||
import org.jfree.util.Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PP Order Workflow Node Model
|
* PP Order Workflow Node Model
|
||||||
*
|
|
||||||
* @author Jorg Janke
|
|
||||||
* @version $Id: MWFNode.java,v 1.2 2006/07/30 00:51:05 jjanke Exp $
|
|
||||||
*
|
*
|
||||||
|
* @author Victor Perez, e-Evolution, S.C.
|
||||||
* @author Teo Sarca, http://www.arhipac.ro
|
* @author Teo Sarca, http://www.arhipac.ro
|
||||||
*/
|
*/
|
||||||
public class MPPOrderNode extends X_PP_Order_Node
|
public class MPPOrderNode extends X_PP_Order_Node
|
||||||
|
@ -67,6 +59,19 @@ public class MPPOrderNode extends X_PP_Order_Node
|
||||||
return retValue;
|
return retValue;
|
||||||
} // get
|
} // get
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if this is last node
|
||||||
|
*/
|
||||||
|
public static boolean isLastNode(Properties ctx, int PP_Order_Node_ID, String trxName)
|
||||||
|
{
|
||||||
|
String whereClause = MPPOrderNodeNext.COLUMNNAME_PP_Order_Node_ID+"=?";
|
||||||
|
return false == new Query(ctx, MPPOrderNodeNext.Table_Name, whereClause, trxName)
|
||||||
|
.setOnlyActiveRecords(true)
|
||||||
|
.setParameters(new Object[]{PP_Order_Node_ID})
|
||||||
|
.match();
|
||||||
|
}
|
||||||
|
|
||||||
/** Cache */
|
/** Cache */
|
||||||
private static CCache<Integer,MPPOrderNode> s_cache = new CCache<Integer,MPPOrderNode> (Table_Name, 50);
|
private static CCache<Integer,MPPOrderNode> s_cache = new CCache<Integer,MPPOrderNode> (Table_Name, 50);
|
||||||
|
|
||||||
|
@ -196,8 +201,6 @@ public class MPPOrderNode extends X_PP_Order_Node
|
||||||
|
|
||||||
/** Next Modes */
|
/** Next Modes */
|
||||||
private List<MPPOrderNodeNext> m_next = new ArrayList<MPPOrderNodeNext>();
|
private List<MPPOrderNodeNext> m_next = new ArrayList<MPPOrderNodeNext>();
|
||||||
/** Column */
|
|
||||||
private MColumn m_column = null;
|
|
||||||
/** Duration Base MS */
|
/** Duration Base MS */
|
||||||
private long m_durationBaseMS = -1;
|
private long m_durationBaseMS = -1;
|
||||||
|
|
||||||
|
@ -207,22 +210,27 @@ public class MPPOrderNode extends X_PP_Order_Node
|
||||||
private void loadNext()
|
private void loadNext()
|
||||||
{
|
{
|
||||||
boolean splitAnd = SPLITELEMENT_AND.equals(getSplitElement());
|
boolean splitAnd = SPLITELEMENT_AND.equals(getSplitElement());
|
||||||
String whereClause = "PP_Order_Node_ID=? ";
|
String whereClause = MPPOrderNodeNext.COLUMNNAME_PP_Order_Node_ID+"=?";
|
||||||
m_next = new Query(getCtx(), MPPOrderNodeNext.Table_Name, whereClause, get_TrxName())
|
m_next = new Query(getCtx(), MPPOrderNodeNext.Table_Name, whereClause, get_TrxName())
|
||||||
.setParameters(new Object[]{get_ID()})
|
.setParameters(new Object[]{get_ID()})
|
||||||
.setOnlyActiveRecords(true)
|
.setOnlyActiveRecords(true)
|
||||||
.setOrderBy(MPPOrderNodeNext.COLUMNNAME_SeqNo)
|
.setOrderBy(MPPOrderNodeNext.COLUMNNAME_SeqNo)
|
||||||
.list();
|
.list();
|
||||||
for (MPPOrderNodeNext next : m_next) {
|
for (MPPOrderNodeNext next : m_next)
|
||||||
|
{
|
||||||
next.setFromSplitAnd(splitAnd);
|
next.setFromSplitAnd(splitAnd);
|
||||||
}
|
}
|
||||||
log.fine("#" + m_next.size());
|
log.fine("#" + m_next.size());
|
||||||
} // loadNext
|
} // loadNext
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Qty Required and DurationRequired (Duration * qtyOrdered)
|
||||||
|
* @param qtyOrdered
|
||||||
|
*/
|
||||||
public void setQtyOrdered(BigDecimal qtyOrdered)
|
public void setQtyOrdered(BigDecimal qtyOrdered)
|
||||||
{
|
{
|
||||||
setQtyRequiered(qtyOrdered);
|
setQtyRequiered(qtyOrdered);
|
||||||
BigDecimal time = new BigDecimal(getDuration()).multiply(qtyOrdered);
|
BigDecimal time = BigDecimal.valueOf(getDuration()).multiply(qtyOrdered);
|
||||||
setDurationRequiered(time.intValue());
|
setDurationRequiered(time.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,146 +251,16 @@ public class MPPOrderNode extends X_PP_Order_Node
|
||||||
public MPPOrderNodeNext[] getTransitions(int AD_Client_ID)
|
public MPPOrderNodeNext[] getTransitions(int AD_Client_ID)
|
||||||
{
|
{
|
||||||
ArrayList<MPPOrderNodeNext> list = new ArrayList<MPPOrderNodeNext>();
|
ArrayList<MPPOrderNodeNext> list = new ArrayList<MPPOrderNodeNext>();
|
||||||
for (int i = 0; i < m_next.size(); i++)
|
for (MPPOrderNodeNext next : m_next)
|
||||||
{
|
{
|
||||||
MPPOrderNodeNext next = m_next.get(i);
|
|
||||||
if (next.getAD_Client_ID() == 0 || next.getAD_Client_ID() == AD_Client_ID)
|
if (next.getAD_Client_ID() == 0 || next.getAD_Client_ID() == AD_Client_ID)
|
||||||
|
{
|
||||||
list.add(next);
|
list.add(next);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
MPPOrderNodeNext[] retValue = new MPPOrderNodeNext [list.size()];
|
return list.toArray(new MPPOrderNodeNext [list.size()]);
|
||||||
list.toArray(retValue);
|
|
||||||
return retValue;
|
|
||||||
} // getNextNodes
|
} // getNextNodes
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Position
|
|
||||||
* @param position point
|
|
||||||
*/
|
|
||||||
public void setPosition (Point position)
|
|
||||||
{
|
|
||||||
setPosition(position.x, position.y);
|
|
||||||
} // setPosition
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Position
|
|
||||||
* @param x x
|
|
||||||
* @param y y
|
|
||||||
*/
|
|
||||||
public void setPosition (int x, int y)
|
|
||||||
{
|
|
||||||
setXPosition(x);
|
|
||||||
setYPosition(y);
|
|
||||||
} // setPosition
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Position
|
|
||||||
* @return position point
|
|
||||||
*/
|
|
||||||
public Point getPosition ()
|
|
||||||
{
|
|
||||||
return new Point (getXPosition(), getYPosition());
|
|
||||||
} // getPosition
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Action Info
|
|
||||||
* @return info
|
|
||||||
*/
|
|
||||||
public String getActionInfo()
|
|
||||||
{
|
|
||||||
String action = getAction();
|
|
||||||
if (ACTION_AppsProcess.equals(action))
|
|
||||||
return "Process:AD_Process_ID=" + getAD_Process_ID();
|
|
||||||
else if (ACTION_DocumentAction.equals(action))
|
|
||||||
return "DocumentAction=" + getDocAction();
|
|
||||||
else if (ACTION_AppsReport.equals(action))
|
|
||||||
return "Report:AD_Process_ID=" + getAD_Process_ID();
|
|
||||||
else if (ACTION_AppsTask.equals(action))
|
|
||||||
return "Task:AD_Task_ID=" + getAD_Task_ID();
|
|
||||||
else if (ACTION_SetVariable.equals(action))
|
|
||||||
return "SetVariable:AD_Column_ID=" + getAD_Column_ID();
|
|
||||||
else if (ACTION_SubWorkflow.equals(action))
|
|
||||||
return "Workflow:PP_Order_Workflow_ID=" + getPP_Order_Workflow_ID();
|
|
||||||
else if (ACTION_UserChoice.equals(action))
|
|
||||||
return "UserChoice:AD_Column_ID=" + getAD_Column_ID();
|
|
||||||
else if (ACTION_UserWorkbench.equals(action))
|
|
||||||
return "Workbench:?";
|
|
||||||
else if (ACTION_UserForm.equals(action))
|
|
||||||
return "Form:AD_Form_ID=" + getAD_Form_ID();
|
|
||||||
else if (ACTION_UserWindow.equals(action))
|
|
||||||
return "Window:AD_Window_ID=" + getAD_Window_ID();
|
|
||||||
//else if (ACTION_WaitSleep.equals(action))
|
|
||||||
// return "Sleep:WaitTime=" + getWaitTime();
|
|
||||||
return "??";
|
|
||||||
} // getActionInfo
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Attribute Name
|
|
||||||
* @see org.compiere.model.X_PP_Order_Node#getAttributeName()
|
|
||||||
* @return Attribute Name
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getAttributeName ()
|
|
||||||
{
|
|
||||||
if (getAD_Column_ID() == 0)
|
|
||||||
return super.getAttributeName();
|
|
||||||
// We have a column
|
|
||||||
String attribute = super.getAttributeName();
|
|
||||||
if (attribute != null && attribute.length() > 0)
|
|
||||||
return attribute;
|
|
||||||
setAttributeName(getColumn().getColumnName());
|
|
||||||
return super.getAttributeName ();
|
|
||||||
} // getAttributeName
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Column
|
|
||||||
* @return column if valid
|
|
||||||
*/
|
|
||||||
public MColumn getColumn()
|
|
||||||
{
|
|
||||||
if (getAD_Column_ID() == 0)
|
|
||||||
return null;
|
|
||||||
if (m_column == null)
|
|
||||||
m_column = MColumn.get(getCtx(), getAD_Column_ID());
|
|
||||||
return m_column;
|
|
||||||
} // getColumn
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is this an Approval setp?
|
|
||||||
* @return true if User Approval
|
|
||||||
*/
|
|
||||||
public boolean isUserApproval()
|
|
||||||
{
|
|
||||||
if (!ACTION_UserChoice.equals(getAction()))
|
|
||||||
return false;
|
|
||||||
return getColumn() != null
|
|
||||||
&& "IsApproved".equals(getColumn().getColumnName());
|
|
||||||
} // isApproval
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is this a User Choice step?
|
|
||||||
* @return true if User Choice
|
|
||||||
*/
|
|
||||||
public boolean isUserChoice()
|
|
||||||
{
|
|
||||||
return ACTION_UserChoice.equals(getAction());
|
|
||||||
} // isUserChoice
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is this a Manual user step?
|
|
||||||
* @return true if Window/Form/Workbench
|
|
||||||
*/
|
|
||||||
public boolean isUserManual()
|
|
||||||
{
|
|
||||||
if (ACTION_UserForm.equals(getAction())
|
|
||||||
|| ACTION_UserWindow.equals(getAction())
|
|
||||||
|| ACTION_UserWorkbench.equals(getAction()))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
} // isUserManual
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Duration in ms
|
* Get Duration in ms
|
||||||
* @return duration in ms
|
* @return duration in ms
|
||||||
|
@ -421,7 +299,7 @@ public class MPPOrderNode extends X_PP_Order_Node
|
||||||
} // getDurationCalendarField
|
} // getDurationCalendarField
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Workflow
|
* Get Workflow (NoTrx)
|
||||||
* @return workflow
|
* @return workflow
|
||||||
*/
|
*/
|
||||||
public MPPOrderWorkflow getPPOrderWorkflow()
|
public MPPOrderWorkflow getPPOrderWorkflow()
|
||||||
|
@ -438,126 +316,10 @@ public class MPPOrderNode extends X_PP_Order_Node
|
||||||
StringBuffer sb = new StringBuffer ("MPPOrderNode[");
|
StringBuffer sb = new StringBuffer ("MPPOrderNode[");
|
||||||
sb.append(get_ID())
|
sb.append(get_ID())
|
||||||
.append("-").append(getName())
|
.append("-").append(getName())
|
||||||
.append(",Action=").append(getActionInfo())
|
|
||||||
.append ("]");
|
.append ("]");
|
||||||
return sb.toString ();
|
return sb.toString ();
|
||||||
} // toString
|
} // toString
|
||||||
|
|
||||||
/**
|
|
||||||
* User String Representation
|
|
||||||
* @return info
|
|
||||||
*/
|
|
||||||
public String toStringX()
|
|
||||||
{
|
|
||||||
StringBuffer sb = new StringBuffer ("MPPOrderNode[");
|
|
||||||
sb.append(getName())
|
|
||||||
.append("-").append(getActionInfo())
|
|
||||||
.append("]");
|
|
||||||
return sb.toString ();
|
|
||||||
} // toStringX
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean beforeSave (boolean newRecord)
|
|
||||||
{
|
|
||||||
String action = getAction();
|
|
||||||
if (action.equals(ACTION_WaitSleep))
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
else if (action.equals(ACTION_AppsProcess) || action.equals(ACTION_AppsReport))
|
|
||||||
{
|
|
||||||
if (getAD_Process_ID() == 0)
|
|
||||||
{
|
|
||||||
log.saveError("FillMandatory", Msg.getElement(getCtx(), "AD_Process_ID"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (action.equals(ACTION_AppsTask))
|
|
||||||
{
|
|
||||||
if (getAD_Task_ID() == 0)
|
|
||||||
{
|
|
||||||
log.saveError("FillMandatory", Msg.getElement(getCtx(), "AD_Task_ID"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (action.equals(ACTION_DocumentAction))
|
|
||||||
{
|
|
||||||
if (getDocAction() == null || getDocAction().length() == 0)
|
|
||||||
{
|
|
||||||
log.saveError("FillMandatory", Msg.getElement(getCtx(), "DocAction"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*else if (action.equals(ACTION_EMail))
|
|
||||||
{
|
|
||||||
if (getR_MailText_ID() == 0)
|
|
||||||
{
|
|
||||||
log.saveError("FillMandatory", Msg.getElement(getCtx(), "R_MailText_ID"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
else if (action.equals(ACTION_SetVariable))
|
|
||||||
{
|
|
||||||
if (getAttributeValue() == null)
|
|
||||||
{
|
|
||||||
log.saveError("FillMandatory", Msg.getElement(getCtx(), "AttributeValue"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (action.equals(ACTION_SubWorkflow))
|
|
||||||
{
|
|
||||||
if (getPP_Order_Workflow_ID() == 0)
|
|
||||||
{
|
|
||||||
log.saveError("FillMandatory", Msg.getElement(getCtx(), "PP_Order_Workflow_ID"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (action.equals(ACTION_UserChoice))
|
|
||||||
{
|
|
||||||
if (getAD_Column_ID() == 0)
|
|
||||||
{
|
|
||||||
log.saveError("FillMandatory", Msg.getElement(getCtx(), "AD_Column_ID"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (action.equals(ACTION_UserForm))
|
|
||||||
{
|
|
||||||
if (getAD_Form_ID() == 0)
|
|
||||||
{
|
|
||||||
log.saveError("FillMandatory", Msg.getElement(getCtx(), "AD_Form_ID"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (action.equals(ACTION_UserWindow))
|
|
||||||
{
|
|
||||||
if (getAD_Window_ID() == 0)
|
|
||||||
{
|
|
||||||
log.saveError("FillMandatory", Msg.getElement(getCtx(), "AD_Window_ID"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// else if (action.equals(ACTION_UserWorkbench))
|
|
||||||
// {
|
|
||||||
// && getAD_Workbench_ID() == 0)
|
|
||||||
// log.saveError("FillMandatory", Msg.getElement(getCtx(), "AD_Workbench_ID"));
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} // beforeSave
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return true if this is last node
|
|
||||||
*/
|
|
||||||
public static boolean isLastNode(Properties ctx, int PP_Order_Node_ID, String trxName)
|
|
||||||
{
|
|
||||||
String whereClause = MPPOrderNodeNext.COLUMNNAME_PP_Order_Node_ID+"=?";
|
|
||||||
return false == new Query(ctx, MPPOrderNodeNext.Table_Name, whereClause, trxName)
|
|
||||||
.setOnlyActiveRecords(true)
|
|
||||||
.setParameters(new Object[]{PP_Order_Node_ID})
|
|
||||||
.match();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the cost for this Activity using the Cost Element Type
|
* Calculate the cost for this Activity using the Cost Element Type
|
||||||
* @param CostElementType Cost Element Type (Labor or Burden)
|
* @param CostElementType Cost Element Type (Labor or Burden)
|
||||||
|
@ -581,7 +343,7 @@ public class MPPOrderNode extends X_PP_Order_Node
|
||||||
return Env.ZERO;
|
return Env.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
int C_UOM_ID = DB.getSQLValue(get_TrxName(),"SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? " , getS_Resource_ID());
|
int C_UOM_ID = DB.getSQLValueEx(get_TrxName(),"SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? " , getS_Resource_ID());
|
||||||
MUOM uom = MUOM.get(getCtx(), C_UOM_ID);
|
MUOM uom = MUOM.get(getCtx(), C_UOM_ID);
|
||||||
if (uom.isHour())
|
if (uom.isHour())
|
||||||
{
|
{
|
||||||
|
@ -597,4 +359,4 @@ public class MPPOrderNode extends X_PP_Order_Node
|
||||||
}
|
}
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
} // M_WFNext
|
}
|
||||||
|
|
|
@ -12,78 +12,50 @@
|
||||||
* For the text or an alternative of this public license, you may reach us *
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
||||||
* Contributor(s): Victor Perez www.e-evolution.com *
|
* Contributor(s): Victor Perez www.e-evolution.com *
|
||||||
|
* Teo Sarca, www.arhipac.ro *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.eevolution.model;
|
package org.eevolution.model;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.compiere.model.Query;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forcast Line Model
|
* Order Node Asset Model
|
||||||
*
|
*
|
||||||
* @author Victor Perez www.e-evolution.com
|
* @author Victor Perez www.e-evolution.com
|
||||||
* @version $Id: MPPWFNodeAsset.java,v 1.11 2005/05/17 05:29:52 vpj-cd vpj-cd $
|
* @author Teo Sarca, www.arhipac.ro
|
||||||
*/
|
*/
|
||||||
public class MPPOrderNodeAsset extends X_PP_Order_Node_Asset
|
public class MPPOrderNodeAsset extends X_PP_Order_Node_Asset
|
||||||
{
|
{
|
||||||
/**
|
private static final long serialVersionUID = 1L;
|
||||||
* Standard Constructor
|
|
||||||
* @param ctx context
|
|
||||||
* @param M_ForecastLine_ID id
|
|
||||||
*/
|
|
||||||
public MPPOrderNodeAsset (Properties ctx, int PP_Order_Node_Asset_ID, String trxName)
|
public MPPOrderNodeAsset (Properties ctx, int PP_Order_Node_Asset_ID, String trxName)
|
||||||
{
|
{
|
||||||
super (ctx, PP_Order_Node_Asset_ID, trxName);
|
super (ctx, PP_Order_Node_Asset_ID, trxName);
|
||||||
if (PP_Order_Node_Asset_ID == 0)
|
if (PP_Order_Node_Asset_ID == 0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public MPPOrderNodeAsset (Properties ctx, ResultSet rs, String trxName)
|
||||||
|
{
|
||||||
|
super(ctx, rs, trxName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new MPPOrderNodeAsset based in MPPWFNodeProduct
|
* Create a new MPPOrderNodeAsset based in MPPWFNodeProduct
|
||||||
* @param np
|
* @param na
|
||||||
|
* @param PP_Order_Node
|
||||||
*/
|
*/
|
||||||
public MPPOrderNodeAsset (MPPWFNodeAsset na)
|
public MPPOrderNodeAsset (MPPWFNodeAsset na, MPPOrderNode PP_Order_Node)
|
||||||
{
|
{
|
||||||
this(na.getCtx(), 0, na.get_TrxName());
|
this(PP_Order_Node.getCtx(), 0, PP_Order_Node.get_TrxName());
|
||||||
|
setClientOrg(PP_Order_Node);
|
||||||
//setSeqNo(na.getSeqNo());
|
//setSeqNo(na.getSeqNo());
|
||||||
setIsActive(na.isActive());
|
|
||||||
setA_Asset_ID(na.getA_Asset_ID());
|
setA_Asset_ID(na.getA_Asset_ID());
|
||||||
|
//
|
||||||
|
setPP_Order_ID(PP_Order_Node.getPP_Order_ID());
|
||||||
|
setPP_Order_Workflow_ID(PP_Order_Node.getPP_Order_Workflow_ID());
|
||||||
|
setPP_Order_Node_ID(PP_Order_Node.get_ID());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Load Constructor
|
|
||||||
* @param ctx context
|
|
||||||
* @param rs result set
|
|
||||||
*/
|
|
||||||
public MPPOrderNodeAsset (Properties ctx, ResultSet rs, String trxName)
|
|
||||||
{
|
|
||||||
super(ctx, rs, trxName);
|
|
||||||
} // MPPWFNodeAsset
|
|
||||||
|
|
||||||
/** Lines */
|
|
||||||
private static Collection<MPPOrderNodeAsset> m_lines = new ArrayList<MPPOrderNodeAsset>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Lines
|
|
||||||
* @return array of lines
|
|
||||||
*/
|
|
||||||
public Collection<MPPOrderNodeAsset> getNodeAsset()
|
|
||||||
{
|
|
||||||
if(!m_lines.isEmpty())
|
|
||||||
return m_lines;
|
|
||||||
|
|
||||||
String whereClause = "PP_Order_Node_Asset_ID=? ";
|
|
||||||
m_lines = new Query(getCtx(), MPPOrderNodeAsset.Table_Name, whereClause, get_TrxName())
|
|
||||||
.setParameters(new Object[]{get_ID()})
|
|
||||||
.setOnlyActiveRecords(true)
|
|
||||||
//.setOrderBy(MPPOrderNodeAsset.COLUMNNAME_SeqNo)
|
|
||||||
.list();
|
|
||||||
return m_lines;
|
|
||||||
} // getLines
|
|
||||||
} // MPPWFNodeAsset
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
* under the terms version 2 of the GNU General Public License as published *
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
* by the Free Software Foundation. This program is distributed in the hope *
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
@ -11,8 +10,9 @@
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
* For the text or an alternative of this public license, you may reach us *
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
||||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
* Contributor(s): Victor Perez www.e-evolution.com *
|
||||||
|
* Teo Sarca, www.arhipac.ro *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.eevolution.model;
|
package org.eevolution.model;
|
||||||
|
|
||||||
|
@ -23,11 +23,9 @@ import org.compiere.util.DB;
|
||||||
import org.compiere.wf.MWFNodeNext;
|
import org.compiere.wf.MWFNodeNext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PP Order Workflow Node Next - Transition
|
* PP Order Workflow Node Next - Transition
|
||||||
*
|
|
||||||
* @author Jorg Janke
|
|
||||||
* @version $Id: MPPOrdeNodeNext.java,v 1.3 2006/10/06 00:42:24 jjanke Exp $
|
|
||||||
*
|
*
|
||||||
|
* @author Victor Perez www.e-evolution.com
|
||||||
* @author Teo Sarca, http://www.arhipac.ro
|
* @author Teo Sarca, http://www.arhipac.ro
|
||||||
*/
|
*/
|
||||||
public class MPPOrderNodeNext extends X_PP_Order_NodeNext
|
public class MPPOrderNodeNext extends X_PP_Order_NodeNext
|
||||||
|
@ -73,22 +71,20 @@ public class MPPOrderNodeNext extends X_PP_Order_NodeNext
|
||||||
{
|
{
|
||||||
this(parent.getCtx(), 0, parent.get_TrxName());
|
this(parent.getCtx(), 0, parent.get_TrxName());
|
||||||
setClientOrg(parent);
|
setClientOrg(parent);
|
||||||
setPP_Order_Node_ID(parent.getPP_Order_Node_ID());
|
setPP_Order_ID(parent.getPP_Order_ID());
|
||||||
|
setPP_Order_Node_ID(parent.get_ID());
|
||||||
setPP_Order_Next_ID(PP_Order_Next_ID);
|
setPP_Order_Next_ID(PP_Order_Next_ID);
|
||||||
} // MPPOrderNodeNext
|
} // MPPOrderNodeNext
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Peer constructor
|
* Peer constructor
|
||||||
* @param wfNodeNext
|
* @param wfNodeNext
|
||||||
* @param PP_Order_Node
|
* @param parent
|
||||||
* @param trxName
|
* @param trxName
|
||||||
*/
|
*/
|
||||||
public MPPOrderNodeNext (MWFNodeNext wfNodeNext, MPPOrderNode PP_Order_Node, String trxName)
|
public MPPOrderNodeNext (MWFNodeNext wfNodeNext, MPPOrderNode parent)
|
||||||
{
|
{
|
||||||
this(wfNodeNext.getCtx(), 0, trxName);
|
this(parent, 0);
|
||||||
setPP_Order_Node_ID(PP_Order_Node.get_ID());
|
|
||||||
setPP_Order_ID(PP_Order_Node.getPP_Order_ID());
|
|
||||||
setPP_Order_Next_ID(0);
|
|
||||||
//
|
//
|
||||||
setAD_WF_Node_ID(wfNodeNext.getAD_WF_Node_ID());
|
setAD_WF_Node_ID(wfNodeNext.getAD_WF_Node_ID());
|
||||||
setAD_WF_Next_ID(wfNodeNext.getAD_WF_Next_ID());
|
setAD_WF_Next_ID(wfNodeNext.getAD_WF_Next_ID());
|
||||||
|
@ -104,21 +100,8 @@ public class MPPOrderNodeNext extends X_PP_Order_NodeNext
|
||||||
/** To (Join Element) is AND */
|
/** To (Join Element) is AND */
|
||||||
public Boolean m_toJoinAnd = null;
|
public Boolean m_toJoinAnd = null;
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Set Client Org
|
public String toString()
|
||||||
* @param AD_Client_ID client
|
|
||||||
* @param AD_Org_ID org
|
|
||||||
*/
|
|
||||||
public void setClientOrg (int AD_Client_ID, int AD_Org_ID)
|
|
||||||
{
|
|
||||||
super.setClientOrg (AD_Client_ID, AD_Org_ID);
|
|
||||||
} // setClientOrg
|
|
||||||
|
|
||||||
/**
|
|
||||||
* String Representation
|
|
||||||
* @return info
|
|
||||||
*/
|
|
||||||
public String toString ()
|
|
||||||
{
|
{
|
||||||
StringBuffer sb = new StringBuffer ("MPPOrderNodeNext[");
|
StringBuffer sb = new StringBuffer ("MPPOrderNodeNext[");
|
||||||
sb.append(getSeqNo())
|
sb.append(getSeqNo())
|
||||||
|
@ -181,8 +164,7 @@ public class MPPOrderNodeNext extends X_PP_Order_NodeNext
|
||||||
{
|
{
|
||||||
final String sql = "SELECT PP_Order_Node_ID FROM PP_Order_Node "
|
final String sql = "SELECT PP_Order_Node_ID FROM PP_Order_Node "
|
||||||
+ " WHERE PP_Order_ID=? AND AD_WF_Node_ID=? AND AD_Client_ID=?";
|
+ " WHERE PP_Order_ID=? AND AD_WF_Node_ID=? AND AD_Client_ID=?";
|
||||||
int id = DB.getSQLValue(get_TrxName(), sql, getPP_Order_ID(), getAD_WF_Next_ID(), getAD_Client_ID());
|
int id = DB.getSQLValueEx(get_TrxName(), sql, getPP_Order_ID(), getAD_WF_Next_ID(), getAD_Client_ID());
|
||||||
if (id > 0)
|
setPP_Order_Next_ID(id > 0 ? id : 0);
|
||||||
setPP_Order_Next_ID(id);
|
|
||||||
}
|
}
|
||||||
} // MPPOrderNodeNext
|
} // MPPOrderNodeNext
|
||||||
|
|
|
@ -12,86 +12,54 @@
|
||||||
* For the text or an alternative of this public license, you may reach us *
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
||||||
* Contributor(s): Victor Perez www.e-evolution.com *
|
* Contributor(s): Victor Perez www.e-evolution.com *
|
||||||
|
* Teo Sarca, www.arhipac.ro *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.eevolution.model;
|
package org.eevolution.model;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.compiere.model.Query;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forcast Line Model
|
* Order Node Product Model
|
||||||
*
|
*
|
||||||
* @author Victor Perez www.e-evolution.com
|
* @author Victor Perez www.e-evolution.com
|
||||||
* @version $Id: MPPWFNodeProduct.java,v 1.11 2005/05/17 05:29:52 vpj-cd vpj-cd $
|
* @author Teo Sarca, www.arhipac.ro
|
||||||
*/
|
*/
|
||||||
public class MPPOrderNodeProduct extends X_PP_Order_Node_Product
|
public class MPPOrderNodeProduct extends X_PP_Order_Node_Product
|
||||||
{
|
{
|
||||||
/**
|
private static final long serialVersionUID = 1L;
|
||||||
* Standard Constructor
|
|
||||||
* @param ctx context
|
|
||||||
* @param M_ForecastLine_ID id
|
|
||||||
*/
|
|
||||||
public MPPOrderNodeProduct (Properties ctx, int PP_WF_Order_Product_ID, String trxName)
|
public MPPOrderNodeProduct (Properties ctx, int PP_WF_Order_Product_ID, String trxName)
|
||||||
{
|
{
|
||||||
super (ctx, PP_WF_Order_Product_ID, trxName);
|
super (ctx, PP_WF_Order_Product_ID, trxName);
|
||||||
if (PP_WF_Order_Product_ID == 0)
|
if (PP_WF_Order_Product_ID == 0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // MQMSpecification
|
public MPPOrderNodeProduct (Properties ctx, ResultSet rs, String trxName)
|
||||||
|
{
|
||||||
|
super(ctx, rs, trxName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new MPPOrderNodeProduct based in MPPWFNodeProduct
|
* Create a new MPPOrderNodeProduct based in MPPWFNodeProduct
|
||||||
* @param np
|
* @param np
|
||||||
|
* @param PP_Order_Node order node
|
||||||
*/
|
*/
|
||||||
public MPPOrderNodeProduct (MPPWFNodeProduct np)
|
public MPPOrderNodeProduct (MPPWFNodeProduct np, MPPOrderNode PP_Order_Node)
|
||||||
{
|
{
|
||||||
this(np.getCtx(), 0, np.get_TrxName());
|
this(PP_Order_Node.getCtx(), 0, PP_Order_Node.get_TrxName());
|
||||||
|
setClientOrg(PP_Order_Node);
|
||||||
setSeqNo(np.getSeqNo());
|
setSeqNo(np.getSeqNo());
|
||||||
setIsActive(np.isActive());
|
setIsActive(np.isActive());
|
||||||
setM_Product_ID(np.getM_Product_ID());
|
setM_Product_ID(np.getM_Product_ID());
|
||||||
setQty(np.getQty());
|
setQty(np.getQty());
|
||||||
setIsSubcontracting(np.isSubcontracting());
|
setIsSubcontracting(np.isSubcontracting());
|
||||||
setYield(np.getYield());
|
setYield(np.getYield());
|
||||||
|
//
|
||||||
|
setPP_Order_ID(PP_Order_Node.getPP_Order_ID());
|
||||||
|
setPP_Order_Workflow_ID(PP_Order_Node.getPP_Order_Workflow_ID());
|
||||||
|
setPP_Order_Node_ID(PP_Order_Node.get_ID());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Load Constructor
|
|
||||||
* @param ctx context
|
|
||||||
* @param rs result set
|
|
||||||
*/
|
|
||||||
public MPPOrderNodeProduct (Properties ctx, ResultSet rs, String trxName)
|
|
||||||
{
|
|
||||||
super(ctx, rs, trxName);
|
|
||||||
} // MQMSpecification
|
|
||||||
|
|
||||||
/** Lines */
|
|
||||||
private static Collection<MPPOrderNodeProduct> m_lines = new ArrayList<MPPOrderNodeProduct>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param ctx
|
|
||||||
* @param AD_WF_Node_ID
|
|
||||||
* @param trxName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Collection<MPPOrderNodeProduct> getNodeProduct()
|
|
||||||
{
|
|
||||||
if(!m_lines.isEmpty())
|
|
||||||
return m_lines;
|
|
||||||
|
|
||||||
String whereClause = "PP_Order_Node_Product_ID=? ";
|
|
||||||
m_lines = new Query(getCtx(), MPPOrderNodeProduct.Table_Name, whereClause, get_TrxName())
|
|
||||||
.setParameters(new Object[]{get_ID()})
|
|
||||||
.setOnlyActiveRecords(true)
|
|
||||||
.setOrderBy(MPPOrderNodeProduct.COLUMNNAME_SeqNo)
|
|
||||||
.list();
|
|
||||||
return m_lines;
|
|
||||||
} // getMPPOrderNodeProduct
|
|
||||||
|
|
||||||
} // MPPWFNodeProduct
|
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.eevolution.model;
|
package org.eevolution.model;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
@ -28,7 +27,6 @@ import org.compiere.model.MClient;
|
||||||
import org.compiere.model.Query;
|
import org.compiere.model.Query;
|
||||||
import org.compiere.util.CCache;
|
import org.compiere.util.CCache;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.wf.MWFNode;
|
|
||||||
import org.compiere.wf.MWorkflow;
|
import org.compiere.wf.MWorkflow;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -183,18 +181,19 @@ public class MPPOrderWorkflow extends X_PP_Order_Workflow
|
||||||
public MPPOrderNode[] getNodes(boolean ordered, int AD_Client_ID)
|
public MPPOrderNode[] getNodes(boolean ordered, int AD_Client_ID)
|
||||||
{
|
{
|
||||||
if (ordered)
|
if (ordered)
|
||||||
|
{
|
||||||
return getNodesInOrder(AD_Client_ID);
|
return getNodesInOrder(AD_Client_ID);
|
||||||
|
}
|
||||||
//
|
//
|
||||||
ArrayList<MPPOrderNode> list = new ArrayList<MPPOrderNode>();
|
ArrayList<MPPOrderNode> list = new ArrayList<MPPOrderNode>();
|
||||||
for (int i = 0; i < m_nodes.size(); i++)
|
for (MPPOrderNode node : m_nodes)
|
||||||
{
|
{
|
||||||
MPPOrderNode node = m_nodes.get(i);
|
|
||||||
if (node.getAD_Client_ID() == 0 || node.getAD_Client_ID() == AD_Client_ID)
|
if (node.getAD_Client_ID() == 0 || node.getAD_Client_ID() == AD_Client_ID)
|
||||||
|
{
|
||||||
list.add(node);
|
list.add(node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
MPPOrderNode[] retValue = new MPPOrderNode [list.size()];
|
return list.toArray(new MPPOrderNode [list.size()]);
|
||||||
list.toArray(retValue);
|
|
||||||
return retValue;
|
|
||||||
} // getNodes
|
} // getNodes
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -207,17 +206,18 @@ public class MPPOrderWorkflow extends X_PP_Order_Workflow
|
||||||
} // getFirstNode
|
} // getFirstNode
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Node with ID in Workflow
|
* Get Node with given ID
|
||||||
* @param PP_Order_Node_ID ID
|
* @param PP_Order_Node_ID ID
|
||||||
* @return node or null
|
* @return node or null
|
||||||
*/
|
*/
|
||||||
public MPPOrderNode getNode (int PP_Order_Node_ID)
|
public MPPOrderNode getNode (int PP_Order_Node_ID)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_nodes.size(); i++)
|
for (MPPOrderNode node : m_nodes)
|
||||||
{
|
{
|
||||||
MPPOrderNode node = (MPPOrderNode)m_nodes.get(i);
|
|
||||||
if (node.getPP_Order_Node_ID() == PP_Order_Node_ID)
|
if (node.getPP_Order_Node_ID() == PP_Order_Node_ID)
|
||||||
|
{
|
||||||
return node;
|
return node;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} // getNode
|
} // getNode
|
||||||
|
@ -232,21 +232,22 @@ public class MPPOrderWorkflow extends X_PP_Order_Workflow
|
||||||
{
|
{
|
||||||
MPPOrderNode node = getNode(PP_Order_Node_ID);
|
MPPOrderNode node = getNode(PP_Order_Node_ID);
|
||||||
if (node == null || node.getNextNodeCount() == 0)
|
if (node == null || node.getNextNodeCount() == 0)
|
||||||
return null;
|
|
||||||
//
|
|
||||||
MPPOrderNodeNext[] nexts = node.getTransitions(AD_Client_ID);
|
|
||||||
ArrayList<MPPOrderNode> list = new ArrayList<MPPOrderNode>();
|
|
||||||
for (int i = 0; i < nexts.length; i++)
|
|
||||||
{
|
{
|
||||||
MPPOrderNode next = getNode (nexts[i].getPP_Order_Next_ID());
|
return null;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
ArrayList<MPPOrderNode> list = new ArrayList<MPPOrderNode>();
|
||||||
|
for (MPPOrderNodeNext nextTr : node.getTransitions(AD_Client_ID))
|
||||||
|
{
|
||||||
|
MPPOrderNode next = getNode (nextTr.getPP_Order_Next_ID());
|
||||||
if (next != null)
|
if (next != null)
|
||||||
|
{
|
||||||
list.add(next);
|
list.add(next);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return Nodes
|
// Return Nodes
|
||||||
MPPOrderNode[] retValue = new MPPOrderNode [list.size()];
|
return list.toArray(new MPPOrderNode [list.size()]);
|
||||||
list.toArray(retValue);
|
|
||||||
return retValue;
|
|
||||||
} // getNextNodes
|
} // getNextNodes
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,35 +21,30 @@ import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.compiere.model.MProduct;
|
import org.compiere.model.MProduct;
|
||||||
import org.compiere.model.PO;
|
|
||||||
import org.compiere.model.Query;
|
import org.compiere.model.Query;
|
||||||
import org.compiere.util.CCache;
|
import org.compiere.util.CCache;
|
||||||
import org.compiere.util.CLogger;
|
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PP Product BOM Model.
|
* PP Product BOM Model.
|
||||||
*
|
|
||||||
* @author Victor Perez www.e-evolution.com
|
|
||||||
* @version $Id: MOrder.java,v 1.40 2004/04/13 04:19:30 vpj-cd Exp $
|
|
||||||
*
|
*
|
||||||
|
* @author Victor Perez www.e-evolution.com
|
||||||
* @author Teo Sarca, http://www.arhipac.ro
|
* @author Teo Sarca, http://www.arhipac.ro
|
||||||
*/
|
*/
|
||||||
public class MPPProductBOM extends X_PP_Product_BOM
|
public class MPPProductBOM extends X_PP_Product_BOM
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** Static Logger */
|
|
||||||
private static CLogger log = CLogger.getCLogger(MPPProductBOM.class);
|
|
||||||
/** Cache */
|
/** Cache */
|
||||||
private static CCache<Integer,MPPProductBOM> s_cache = new CCache<Integer,MPPProductBOM>(Table_Name, 40, 5);
|
private static CCache<Integer,MPPProductBOM> s_cache = new CCache<Integer,MPPProductBOM>(Table_Name, 40, 5);
|
||||||
|
/** BOM Lines */
|
||||||
|
private List<MPPProductBOMLine> m_lines = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load/Get Product BOM by ID (cached)
|
* Get Product BOM by ID (cached)
|
||||||
* @param ctx
|
* @param ctx
|
||||||
* @param PP_Product_BOM_ID
|
* @param PP_Product_BOM_ID
|
||||||
* @return product bom
|
* @return product bom
|
||||||
|
@ -62,110 +57,42 @@ public class MPPProductBOM extends X_PP_Product_BOM
|
||||||
if (bom != null)
|
if (bom != null)
|
||||||
return bom;
|
return bom;
|
||||||
bom = new MPPProductBOM(ctx, PP_Product_BOM_ID, null);
|
bom = new MPPProductBOM(ctx, PP_Product_BOM_ID, null);
|
||||||
if (bom.get_ID() == PP_Product_BOM_ID) {
|
if (bom.get_ID() == PP_Product_BOM_ID)
|
||||||
|
{
|
||||||
s_cache.put(PP_Product_BOM_ID, bom);
|
s_cache.put(PP_Product_BOM_ID, bom);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
bom = null;
|
bom = null;
|
||||||
}
|
}
|
||||||
return bom;
|
return bom;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Get PP_Product_BOM_ID for given M_Product_ID
|
||||||
* @param ctx context
|
* @param M_Product_ID
|
||||||
* @param C_Order_ID order to load, (0 create new order)
|
* @return PP_Product_BOM_ID
|
||||||
*/
|
*/
|
||||||
public MPPProductBOM(Properties ctx, int PP_Product_BOM_ID,String trxName)
|
public static int getBOMSearchKey(Properties ctx, MProduct product)
|
||||||
{
|
{
|
||||||
super (ctx, PP_Product_BOM_ID, trxName);
|
int AD_Client_ID = Env.getAD_Client_ID(ctx);
|
||||||
} // MPPProductBOM
|
String sql = "SELECT PP_Product_BOM_ID FROM PP_Product_BOM"
|
||||||
|
+" WHERE Value=? AND M_Product_ID=? AND AD_Client_ID=?";
|
||||||
|
return DB.getSQLValueEx(null, sql, product.getValue(), product.get_ID(), AD_Client_ID);
|
||||||
/**
|
|
||||||
* Load Constructor
|
|
||||||
* @param ctx context
|
|
||||||
* @param rs result set record
|
|
||||||
*/
|
|
||||||
public MPPProductBOM(Properties ctx, ResultSet rs,String trxName)
|
|
||||||
{
|
|
||||||
super (ctx, rs,trxName);
|
|
||||||
} // MOrder
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy Lines From other BOM
|
|
||||||
* @param order order
|
|
||||||
* @return number of lines copied
|
|
||||||
*/
|
|
||||||
public int copyLinesFrom (MPPProductBOM bom)
|
|
||||||
{
|
|
||||||
if (bom == null)
|
|
||||||
return 0;
|
|
||||||
MPPProductBOMLine[] fromLines = bom.getLines();
|
|
||||||
int count = 0;
|
|
||||||
for (int i = 0; i < fromLines.length; i++)
|
|
||||||
{
|
|
||||||
MPPProductBOMLine line = new MPPProductBOMLine (this);
|
|
||||||
PO.copyValues(fromLines[i], line, getAD_Client_ID(), getAD_Org_ID());
|
|
||||||
line.setPP_Product_BOM_ID(getPP_Product_BOM_ID());
|
|
||||||
if (line.save(get_TrxName()))
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
if (fromLines.length != count)
|
|
||||||
log.log(Level.SEVERE,"copyLinesFrom - Line difference - From=" + fromLines.length + " <> Saved=" + count);
|
|
||||||
return count;
|
|
||||||
} // copyLinesFrom
|
|
||||||
|
|
||||||
/*************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BUG #104
|
|
||||||
* @param lines
|
|
||||||
*/
|
|
||||||
private void setLines(List<MPPProductBOMLine> lines)
|
|
||||||
{
|
|
||||||
this.lines = lines;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<MPPProductBOMLine> lines = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BUG #? - Does not persist objects!
|
|
||||||
* @param ctx
|
|
||||||
* @param from
|
|
||||||
* @param copyLines
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static MPPProductBOM copyFrom(Properties ctx, MPPProductBOM from, boolean copyLines) {
|
|
||||||
MPPProductBOM newBom = new MPPProductBOM(ctx, 0,null);
|
|
||||||
PO.copyValues(from, newBom, Env.getAD_Client_ID(ctx), Env.getAD_Org_ID(ctx));
|
|
||||||
newBom.setDocumentNo(null);
|
|
||||||
|
|
||||||
if (copyLines) {
|
|
||||||
List<MPPProductBOMLine> newLines = new ArrayList<MPPProductBOMLine>();
|
|
||||||
MPPProductBOMLine[] fromLines = from.getLines();
|
|
||||||
for (int i = 0; i < fromLines.length; i++) {
|
|
||||||
MPPProductBOMLine line = new MPPProductBOMLine(ctx, 0,null);
|
|
||||||
PO.copyValues(fromLines[i], line, Env.getAD_Client_ID(ctx), Env.getAD_Org_ID(ctx));
|
|
||||||
newLines.add(line);
|
|
||||||
}
|
|
||||||
newBom.setLines(newLines);
|
|
||||||
}
|
|
||||||
|
|
||||||
return newBom;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String Representation
|
* Get BOM with Default Logic (Product = BOM Product and BOM Value = Product Value)
|
||||||
* @return info
|
* @param product
|
||||||
|
* @param trxName
|
||||||
|
* @return product BOM
|
||||||
*/
|
*/
|
||||||
public String toString ()
|
public static MPPProductBOM getDefault(MProduct product, String trxName)
|
||||||
{
|
{
|
||||||
StringBuffer sb = new StringBuffer ("MPP_ProductBOM[")
|
return new Query(product.getCtx(), Table_Name, "M_Product_ID=? AND Value=?", trxName)
|
||||||
.append(get_ID()).append("-").append(getDocumentNo())
|
.setParameters(new Object[]{product.getM_Product_ID(), product.getValue()})
|
||||||
.append ("]");
|
.first();
|
||||||
return sb.toString ();
|
}
|
||||||
} // toString
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get BOM for Product
|
* Get BOM for Product
|
||||||
|
@ -176,13 +103,13 @@ public class MPPProductBOM extends X_PP_Product_BOM
|
||||||
*/
|
*/
|
||||||
public static MPPProductBOM get(MProduct product, int ad_org_id, String trxName)
|
public static MPPProductBOM get(MProduct product, int ad_org_id, String trxName)
|
||||||
{
|
{
|
||||||
MPPProductBOM bom = null;
|
MPPProductBOM bom = null;
|
||||||
Properties ctx = product.getCtx();
|
Properties ctx = product.getCtx();
|
||||||
// find Default BOM in Product Data Planning
|
// find Default BOM in Product Data Planning
|
||||||
if (ad_org_id > 0 )
|
if (ad_org_id > 0 )
|
||||||
{
|
{
|
||||||
MPPProductPlanning pp = MPPProductPlanning.get(ctx, product.getAD_Client_ID(),ad_org_id, product.getM_Product_ID(), trxName);
|
MPPProductPlanning pp = MPPProductPlanning.get(ctx, product.getAD_Client_ID(),ad_org_id, product.getM_Product_ID(), trxName);
|
||||||
if(pp != null && pp.getPP_Product_BOM_ID() > 0 )
|
if(pp != null && pp.getPP_Product_BOM_ID() > 0)
|
||||||
{
|
{
|
||||||
bom = new MPPProductBOM(ctx, pp.getPP_Product_BOM_ID(),trxName);
|
bom = new MPPProductBOM(ctx, pp.getPP_Product_BOM_ID(),trxName);
|
||||||
}
|
}
|
||||||
|
@ -194,8 +121,7 @@ public class MPPProductBOM extends X_PP_Product_BOM
|
||||||
}
|
}
|
||||||
|
|
||||||
return bom;
|
return bom;
|
||||||
|
}
|
||||||
} // getBOM
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get BOM with valid dates for Product
|
* Get BOM with valid dates for Product
|
||||||
|
@ -213,8 +139,19 @@ public class MPPProductBOM extends X_PP_Product_BOM
|
||||||
return bom;
|
return bom;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
} // getBOM
|
|
||||||
|
public MPPProductBOM(Properties ctx, int PP_Product_BOM_ID,String trxName)
|
||||||
|
{
|
||||||
|
super (ctx, PP_Product_BOM_ID, trxName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public MPPProductBOM(Properties ctx, ResultSet rs,String trxName)
|
||||||
|
{
|
||||||
|
super (ctx, rs,trxName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get BOM Lines valid date for Product BOM
|
* Get BOM Lines valid date for Product BOM
|
||||||
|
@ -223,10 +160,11 @@ public class MPPProductBOM extends X_PP_Product_BOM
|
||||||
*/
|
*/
|
||||||
public MPPProductBOMLine[] getLines (Timestamp valid)
|
public MPPProductBOMLine[] getLines (Timestamp valid)
|
||||||
{
|
{
|
||||||
MPPProductBOMLine[] bomlines = getLines(); // All BOM Lines
|
|
||||||
List<MPPProductBOMLine> list = new ArrayList<MPPProductBOMLine>(); // Selected BOM Lines Only
|
List<MPPProductBOMLine> list = new ArrayList<MPPProductBOMLine>(); // Selected BOM Lines Only
|
||||||
for (MPPProductBOMLine bl : bomlines) {
|
for (MPPProductBOMLine bl : getLines())
|
||||||
if (bl.isValidFromTo(valid)) {
|
{
|
||||||
|
if (bl.isValidFromTo(valid))
|
||||||
|
{
|
||||||
list.add(bl);
|
list.add(bl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,42 +178,17 @@ public class MPPProductBOM extends X_PP_Product_BOM
|
||||||
*/
|
*/
|
||||||
public MPPProductBOMLine[] getLines()
|
public MPPProductBOMLine[] getLines()
|
||||||
{
|
{
|
||||||
if (this.lines == null)
|
if (this.m_lines == null)
|
||||||
{
|
{
|
||||||
final String whereClause = MPPProductBOMLine.COLUMNNAME_PP_Product_BOM_ID+"=?";
|
final String whereClause = MPPProductBOMLine.COLUMNNAME_PP_Product_BOM_ID+"=?";
|
||||||
this.lines = new Query(getCtx(), MPPProductBOMLine.Table_Name, whereClause, get_TrxName())
|
this.m_lines = new Query(getCtx(), MPPProductBOMLine.Table_Name, whereClause, get_TrxName())
|
||||||
.setParameters(new Object[]{getPP_Product_BOM_ID()})
|
.setParameters(new Object[]{getPP_Product_BOM_ID()})
|
||||||
.setOrderBy(MPPProductBOMLine.COLUMNNAME_Line)
|
.setOrderBy(MPPProductBOMLine.COLUMNNAME_Line)
|
||||||
.list();
|
.list();
|
||||||
}
|
}
|
||||||
return this.lines.toArray(new MPPProductBOMLine[this.lines.size()]);
|
return this.m_lines.toArray(new MPPProductBOMLine[this.m_lines.size()]);
|
||||||
} // getLines
|
} // getLines
|
||||||
|
|
||||||
/**
|
|
||||||
* Get PP_Product_BOM_ID for given M_Product_ID
|
|
||||||
* @param M_Product_ID
|
|
||||||
* @return PP_Product_BOM_ID
|
|
||||||
*/
|
|
||||||
public static int getBOMSearchKey(Properties ctx, MProduct product)
|
|
||||||
{
|
|
||||||
int AD_Client_ID = Env.getAD_Client_ID(ctx);
|
|
||||||
String sql = "SELECT pb.PP_Product_BOM_ID FROM PP_Product_BOM pb"
|
|
||||||
+" WHERE pb.Value = ? AND pb.M_Product_ID=? AND pb.AD_Client_ID = ?";
|
|
||||||
return DB.getSQLValue(null, sql, product.getValue(), product.get_ID(), AD_Client_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get BOM with Default Logic (Product = BOM Product and BOM Value = Product Value)
|
|
||||||
* @param product
|
|
||||||
* @param trxName
|
|
||||||
* @return product BOM
|
|
||||||
*/
|
|
||||||
public static MPPProductBOM getDefault(MProduct product, String trxName) {
|
|
||||||
return new Query(product.getCtx(), Table_Name, "M_Product_ID=? AND Value=?", trxName)
|
|
||||||
.setParameters(new Object[]{product.getM_Product_ID(), product.getValue()})
|
|
||||||
.first();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isValidFromTo(Timestamp date)
|
public boolean isValidFromTo(Timestamp date)
|
||||||
{
|
{
|
||||||
Timestamp validFrom = getValidFrom();
|
Timestamp validFrom = getValidFrom();
|
||||||
|
@ -289,7 +202,8 @@ public class MPPProductBOM extends X_PP_Product_BOM
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean afterDelete(boolean success) {
|
protected boolean afterDelete(boolean success)
|
||||||
|
{
|
||||||
if (!success)
|
if (!success)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -298,7 +212,8 @@ public class MPPProductBOM extends X_PP_Product_BOM
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean afterSave(boolean newRecord, boolean success) {
|
protected boolean afterSave(boolean newRecord, boolean success)
|
||||||
|
{
|
||||||
if (!success)
|
if (!success)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -311,13 +226,21 @@ public class MPPProductBOM extends X_PP_Product_BOM
|
||||||
|
|
||||||
private void updateProduct()
|
private void updateProduct()
|
||||||
{
|
{
|
||||||
int count = new Query(getCtx(), Table_Name, "M_Product_ID=? AND IsActive=?", get_TrxName())
|
int count = new Query(getCtx(), Table_Name, COLUMNNAME_M_Product_ID+"=?", get_TrxName())
|
||||||
.setParameters(new Object[]{getM_Product_ID(), "Y"})
|
.setParameters(new Object[]{getM_Product_ID()})
|
||||||
|
.setOnlyActiveRecords(true)
|
||||||
.count();
|
.count();
|
||||||
MProduct product = new MProduct(getCtx(), getM_Product_ID(), get_TrxName());
|
MProduct product = new MProduct(getCtx(), getM_Product_ID(), get_TrxName());
|
||||||
product.setIsBOM(count > 0);
|
product.setIsBOM(count > 0);
|
||||||
product.saveEx();
|
product.saveEx();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString ()
|
||||||
|
{
|
||||||
|
StringBuffer sb = new StringBuffer ("MPP_ProductBOM[")
|
||||||
|
.append(get_ID()).append("-").append(getDocumentNo())
|
||||||
|
.append ("]");
|
||||||
|
return sb.toString ();
|
||||||
|
}
|
||||||
} // MPPProductBOM
|
} // MPPProductBOM
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
* For the text or an alternative of this public license, you may reach us *
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
||||||
* Contributor(s): Victor Perez www.e-evolution.com *
|
* Contributor(s): Victor Perez www.e-evolution.com *
|
||||||
|
* Teo Sarca, www.arhipac.ro *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.eevolution.model;
|
package org.eevolution.model;
|
||||||
|
|
||||||
|
@ -38,10 +39,9 @@ import org.compiere.util.Env;
|
||||||
* l.setQty(wbl.getQuantity());;
|
* l.setQty(wbl.getQuantity());;
|
||||||
* l.saveEx();
|
* l.saveEx();
|
||||||
* </code>
|
* </code>
|
||||||
* @author Victor Perez www.e-evolution.com
|
|
||||||
* @version $Id: MOrderLine.java,v 1.22 2004/03/22 07:15:03 vpj-cd Exp $
|
|
||||||
*
|
*
|
||||||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
* @author Victor Perez www.e-evolution.com
|
||||||
|
* @author Teo Sarca, www.arhipac.ro
|
||||||
*/
|
*/
|
||||||
public class MPPProductBOMLine extends X_PP_Product_BOMLine
|
public class MPPProductBOMLine extends X_PP_Product_BOMLine
|
||||||
{
|
{
|
||||||
|
@ -108,7 +108,7 @@ public class MPPProductBOMLine extends X_PP_Product_BOMLine
|
||||||
{
|
{
|
||||||
final String sql = "SELECT COALESCE(MAX("+COLUMNNAME_Line+"),0) + 10 FROM "+Table_Name
|
final String sql = "SELECT COALESCE(MAX("+COLUMNNAME_Line+"),0) + 10 FROM "+Table_Name
|
||||||
+" WHERE "+COLUMNNAME_PP_Product_BOM_ID+"=?";
|
+" WHERE "+COLUMNNAME_PP_Product_BOM_ID+"=?";
|
||||||
int line = DB.getSQLValue(get_TrxName(), sql, getPP_Product_BOM_ID());
|
int line = DB.getSQLValueEx(get_TrxName(), sql, getPP_Product_BOM_ID());
|
||||||
setLine(line);
|
setLine(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +141,8 @@ public class MPPProductBOMLine extends X_PP_Product_BOMLine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProductLowLevelCalculator {
|
class ProductLowLevelCalculator
|
||||||
|
{
|
||||||
private Hashtable<Integer, Integer> tableproduct = new Hashtable<Integer, Integer>();
|
private Hashtable<Integer, Integer> tableproduct = new Hashtable<Integer, Integer>();
|
||||||
private Properties m_ctx = null;
|
private Properties m_ctx = null;
|
||||||
private String m_trxName = null;
|
private String m_trxName = null;
|
||||||
|
@ -180,17 +181,15 @@ class ProductLowLevelCalculator {
|
||||||
|
|
||||||
DefaultMutableTreeNode parent = new DefaultMutableTreeNode(Integer.toString(M_Product_ID) + "|" + Integer.toString(PP_Product_BOM_ID));
|
DefaultMutableTreeNode parent = new DefaultMutableTreeNode(Integer.toString(M_Product_ID) + "|" + Integer.toString(PP_Product_BOM_ID));
|
||||||
|
|
||||||
String sql = new String(
|
String sql = "SELECT PP_Product_BOMLine_ID FROM PP_Product_BOMLine"
|
||||||
"SELECT pboml.PP_Product_BOMLine_ID FROM PP_Product_BOMLine pboml"
|
+ " WHERE IsActive=? AND AD_Client_ID=? AND M_Product_ID=?";
|
||||||
+ " WHERE pboml.IsActive= 'Y' AND pboml.AD_Client_ID = ? AND pboml.M_Product_ID = ? ");
|
|
||||||
|
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, m_trxName);
|
pstmt = DB.prepareStatement(sql, m_trxName);
|
||||||
pstmt.setInt(1, AD_Client_ID);
|
DB.setParameters(pstmt, new Object[]{true, AD_Client_ID, M_Product_ID});
|
||||||
pstmt.setInt(2, M_Product_ID);
|
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
{
|
{
|
||||||
|
@ -212,10 +211,10 @@ class ProductLowLevelCalculator {
|
||||||
{
|
{
|
||||||
throw new DBException(e);
|
throw new DBException(e);
|
||||||
}
|
}
|
||||||
finally {
|
finally
|
||||||
|
{
|
||||||
DB.close(rs, pstmt);
|
DB.close(rs, pstmt);
|
||||||
rs = null;
|
rs = null; pstmt = null;
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
@ -228,17 +227,16 @@ class ProductLowLevelCalculator {
|
||||||
*/
|
*/
|
||||||
private DefaultMutableTreeNode icomponent(int AD_Client_ID, int PP_Product_BOMLine_ID, int M_Product_ID, DefaultMutableTreeNode bom)
|
private DefaultMutableTreeNode icomponent(int AD_Client_ID, int PP_Product_BOMLine_ID, int M_Product_ID, DefaultMutableTreeNode bom)
|
||||||
{
|
{
|
||||||
String sql =
|
final String sql =
|
||||||
"SELECT pbom.M_Product_ID , pbom.Value , pbom.PP_Product_BOM_ID FROM PP_Product_BOMLine pboml"
|
"SELECT pbom.M_Product_ID , pbom.Value , pbom.PP_Product_BOM_ID FROM PP_Product_BOMLine pboml"
|
||||||
+ " INNER JOIN PP_Product_BOM pbom ON (pbom.PP_Product_BOM_ID = pboml.PP_Product_BOM_ID)"
|
+ " INNER JOIN PP_Product_BOM pbom ON (pbom.PP_Product_BOM_ID = pboml.PP_Product_BOM_ID)"
|
||||||
+ " WHERE pbom.IsActive= 'Y' AND pboml.IsActive= 'Y' AND pboml.AD_Client_ID =? AND pboml.PP_Product_BOMLine_ID = ? ";
|
+ " WHERE pbom.IsActive=? AND pboml.IsActive=? AND pboml.AD_Client_ID=? AND pboml.PP_Product_BOMLine_ID=? ";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, m_trxName);
|
pstmt = DB.prepareStatement(sql, m_trxName);
|
||||||
pstmt.setInt(1, AD_Client_ID);
|
DB.setParameters(pstmt, new Object[]{true, true, AD_Client_ID, PP_Product_BOMLine_ID});
|
||||||
pstmt.setInt(2, PP_Product_BOMLine_ID);
|
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
{
|
{
|
||||||
|
@ -246,7 +244,9 @@ class ProductLowLevelCalculator {
|
||||||
{
|
{
|
||||||
//BOM Loop Error
|
//BOM Loop Error
|
||||||
if (!tableproduct(rs.getInt(1), rs.getInt(3)))
|
if (!tableproduct(rs.getInt(1), rs.getInt(3)))
|
||||||
|
{
|
||||||
bom.add(iparent(AD_Client_ID, rs.getInt(1), rs.getInt(3)));
|
bom.add(iparent(AD_Client_ID, rs.getInt(1), rs.getInt(3)));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new AdempiereException("Cycle BOM & Formula:" + rs.getString(2) + "(" + rs.getString(3) + ")");
|
throw new AdempiereException("Cycle BOM & Formula:" + rs.getString(2) + "(" + rs.getString(3) + ")");
|
||||||
|
@ -265,10 +265,10 @@ class ProductLowLevelCalculator {
|
||||||
{
|
{
|
||||||
throw new DBException(e);
|
throw new DBException(e);
|
||||||
}
|
}
|
||||||
finally {
|
finally
|
||||||
|
{
|
||||||
DB.close(rs, pstmt);
|
DB.close(rs, pstmt);
|
||||||
rs = null;
|
rs = null; pstmt = null;
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -281,14 +281,11 @@ class ProductLowLevelCalculator {
|
||||||
*/
|
*/
|
||||||
private boolean tableproduct(int M_Product_ID, int PP_Product_BOM_ID)
|
private boolean tableproduct(int M_Product_ID, int PP_Product_BOM_ID)
|
||||||
{
|
{
|
||||||
Integer p = new Integer(M_Product_ID);
|
if (tableproduct.containsKey(M_Product_ID))
|
||||||
Integer bom = new Integer(PP_Product_BOM_ID);
|
|
||||||
|
|
||||||
if (tableproduct.containsKey(p))
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
tableproduct.put(p, bom);
|
tableproduct.put(M_Product_ID, PP_Product_BOM_ID);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.eevolution.model;
|
package org.eevolution.model;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -27,13 +28,12 @@ import org.compiere.util.CLogMgt;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.wf.MWorkflow;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Product Data Planning
|
* Product Data Planning
|
||||||
*
|
|
||||||
* @author Victor Perez www.e-evolution.com
|
|
||||||
* @version $Id: MPProductPlannning.java,v 1.4 2004/05/13 06:05:22 vpj-cd Exp $
|
|
||||||
*
|
*
|
||||||
|
* @author Victor Perez www.e-evolution.com
|
||||||
* @author Teo Sarca, www.arhipac.ro
|
* @author Teo Sarca, www.arhipac.ro
|
||||||
*/
|
*/
|
||||||
public class MPPProductPlanning extends X_PP_Product_Planning
|
public class MPPProductPlanning extends X_PP_Product_Planning
|
||||||
|
@ -72,7 +72,7 @@ public class MPPProductPlanning extends X_PP_Product_Planning
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Data Product Planning to Organization
|
* Get Data Product Planning to Organization
|
||||||
* @param ctx Context
|
* @param ctx Context
|
||||||
* @param ad_org_id Organization ID
|
* @param ad_org_id Organization ID
|
||||||
* @param m_product_id Product ID
|
* @param m_product_id Product ID
|
||||||
|
@ -83,19 +83,17 @@ public class MPPProductPlanning extends X_PP_Product_Planning
|
||||||
int m_product_id,
|
int m_product_id,
|
||||||
String trxname)
|
String trxname)
|
||||||
{
|
{
|
||||||
int m_M_Warehouse_ID = MOrgInfo.get(ctx, ad_org_id).getM_Warehouse_ID();
|
int M_Warehouse_ID = MOrgInfo.get(ctx, ad_org_id).getM_Warehouse_ID();
|
||||||
if(m_M_Warehouse_ID <= 0)
|
if(M_Warehouse_ID <= 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
int S_Resource_ID = getPlantForWarehouse(M_Warehouse_ID);
|
||||||
|
if (S_Resource_ID <= 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Get plant resource for warehouse. If more than one resource is found, first will be used
|
return get(ctx, ad_client_id,ad_org_id, M_Warehouse_ID, S_Resource_ID, m_product_id, trxname);
|
||||||
final String sql = "SELECT MIN(S_Resource_ID) FROM S_Resource"
|
|
||||||
+" WHERE IsManufacturingResource=? AND ManufacturingResourceType=?"
|
|
||||||
+" AND AD_Client_ID=? AND M_Warehouse_ID= ?";
|
|
||||||
int m_S_Resource_ID = DB.getSQLValue(trxname, sql, "Y", MResource.MANUFACTURINGRESOURCETYPE_Plant, ad_client_id, m_M_Warehouse_ID);
|
|
||||||
if (m_S_Resource_ID <= 0)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return get(ctx, ad_client_id,ad_org_id, m_M_Warehouse_ID, m_S_Resource_ID, m_product_id, trxname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,7 +113,8 @@ public class MPPProductPlanning extends X_PP_Product_Planning
|
||||||
{
|
{
|
||||||
log.info("AD_Client_ID=" + ad_client_id + " AD_Org_ID=" + ad_org_id + " M_Product_ID=" + m_product_id + " M_Warehouse_ID=" + m_warehouse_id + " S_Resource_ID=" + s_resource_id );
|
log.info("AD_Client_ID=" + ad_client_id + " AD_Org_ID=" + ad_org_id + " M_Product_ID=" + m_product_id + " M_Warehouse_ID=" + m_warehouse_id + " S_Resource_ID=" + s_resource_id );
|
||||||
String sql_warehouse = COLUMNNAME_M_Warehouse_ID+"=?";
|
String sql_warehouse = COLUMNNAME_M_Warehouse_ID+"=?";
|
||||||
if(m_warehouse_id == 0) {
|
if(m_warehouse_id == 0)
|
||||||
|
{
|
||||||
sql_warehouse += " OR "+COLUMNNAME_M_Warehouse_ID+" IS NULL";
|
sql_warehouse += " OR "+COLUMNNAME_M_Warehouse_ID+" IS NULL";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +126,7 @@ public class MPPProductPlanning extends X_PP_Product_Planning
|
||||||
|
|
||||||
return new Query(ctx, MPPProductPlanning.Table_Name, whereClause, trxname)
|
return new Query(ctx, MPPProductPlanning.Table_Name, whereClause, trxname)
|
||||||
.setParameters(new Object[]{ad_client_id, ad_org_id, m_product_id, m_warehouse_id, s_resource_id})
|
.setParameters(new Object[]{ad_client_id, ad_org_id, m_product_id, m_warehouse_id, s_resource_id})
|
||||||
.first();
|
.firstOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -158,6 +157,26 @@ public class MPPProductPlanning extends X_PP_Product_Planning
|
||||||
.first();
|
.first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getPlantForWarehouse(int M_Warehouse_ID)
|
||||||
|
{
|
||||||
|
// Get plant resource for warehouse. If more than one resource is found, first will be used
|
||||||
|
final String sql = "SELECT MIN("+MResource.COLUMNNAME_S_Resource_ID+")"
|
||||||
|
+" FROM "+MResource.Table_Name
|
||||||
|
+" WHERE "+MResource.COLUMNNAME_IsManufacturingResource+"=?"
|
||||||
|
+" AND "+MResource.COLUMNNAME_ManufacturingResourceType+"=?"
|
||||||
|
+" AND "+MResource.COLUMNNAME_M_Warehouse_ID+"=?";
|
||||||
|
int plant_id = DB.getSQLValueEx(null, sql, true, MResource.MANUFACTURINGRESOURCETYPE_Plant, M_Warehouse_ID);
|
||||||
|
return plant_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Qty On Hand
|
||||||
|
*/
|
||||||
|
public BigDecimal getQtyOnHand()
|
||||||
|
{
|
||||||
|
return MPPMRP.getQtyOnHand(getCtx(), getM_Warehouse_ID(), getM_Product_ID(), get_TrxName());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean beforeSave(boolean newRecord)
|
protected boolean beforeSave(boolean newRecord)
|
||||||
{
|
{
|
||||||
|
@ -171,6 +190,18 @@ public class MPPProductPlanning extends X_PP_Product_Planning
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MPPProductBOM getPP_Product_BOM()
|
||||||
|
{
|
||||||
|
return MPPProductBOM.get(getCtx(), getPP_Product_BOM_ID());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MWorkflow getAD_Workflow()
|
||||||
|
{
|
||||||
|
return MWorkflow.get(getCtx(), getAD_Workflow_ID());
|
||||||
|
}
|
||||||
|
|
||||||
public void dump()
|
public void dump()
|
||||||
{
|
{
|
||||||
if (!CLogMgt.isLevelInfo())
|
if (!CLogMgt.isLevelInfo())
|
||||||
|
@ -184,9 +215,8 @@ public class MPPProductPlanning extends X_PP_Product_Planning
|
||||||
log.info(" Network Distribution: " + getDD_NetworkDistribution_ID());
|
log.info(" Network Distribution: " + getDD_NetworkDistribution_ID());
|
||||||
log.info("Delivery Time Promised: " + getDeliveryTime_Promised());
|
log.info("Delivery Time Promised: " + getDeliveryTime_Promised());
|
||||||
log.info(" TransfertTime: " + getTransfertTime ());
|
log.info(" TransfertTime: " + getTransfertTime ());
|
||||||
log.info(" Max Order: " + getOrder_Max());
|
log.info(" Order Min/Max: " + getOrder_Min() + " / " + getOrder_Max());
|
||||||
log.info(" Min Order: " + getOrder_Min());
|
log.info(" Order Pack: " + getOrder_Pack());
|
||||||
log.info(" Pack Order: " + getOrder_Pack());
|
|
||||||
log.info(" Safety Stock: " + getSafetyStock());
|
log.info(" Safety Stock: " + getSafetyStock());
|
||||||
log.info(" Order Period: " + getOrder_Period());
|
log.info(" Order Period: " + getOrder_Period());
|
||||||
log.info(" Order Policy: " + getOrder_Policy());
|
log.info(" Order Policy: " + getOrder_Policy());
|
||||||
|
|
|
@ -12,71 +12,62 @@
|
||||||
* For the text or an alternative of this public license, you may reach us *
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
||||||
* Contributor(s): Victor Perez www.e-evolution.com *
|
* Contributor(s): Victor Perez www.e-evolution.com *
|
||||||
|
* Teo Sarca, www.arhipac.ro *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.eevolution.model;
|
package org.eevolution.model;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.compiere.model.Query;
|
import org.compiere.model.Query;
|
||||||
|
import org.compiere.util.CCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forcast Line Model
|
* Workflow Node Asset Model
|
||||||
*
|
*
|
||||||
* @author Victor Perez www.e-evolution.com
|
* @author Victor Perez www.e-evolution.com
|
||||||
* @version $Id: MPPWFNodeAsset.java,v 1.11 2005/05/17 05:29:52 vpj-cd vpj-cd $
|
* @author Teo Sarca, www.arhipac.ro
|
||||||
*/
|
*/
|
||||||
public class MPPWFNodeAsset extends X_PP_WF_Node_Asset
|
public class MPPWFNodeAsset extends X_PP_WF_Node_Asset
|
||||||
{
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** Cache */
|
||||||
|
private static CCache<Integer, Collection<MPPWFNodeAsset>>
|
||||||
|
s_cache = new CCache<Integer, Collection<MPPWFNodeAsset>>(Table_Name, 20);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Constructor
|
* @return array of node assets
|
||||||
* @param ctx context
|
|
||||||
* @param M_ForecastLine_ID id
|
|
||||||
*/
|
*/
|
||||||
|
public static Collection<MPPWFNodeAsset> forAD_WF_Node_ID(Properties ctx, int AD_WF_Node_ID)
|
||||||
|
{
|
||||||
|
Collection<MPPWFNodeAsset> lines = s_cache.get(AD_WF_Node_ID);
|
||||||
|
if (lines != null)
|
||||||
|
{
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String whereClause = COLUMNNAME_AD_WF_Node_ID+"=?";
|
||||||
|
lines = new Query(ctx, Table_Name, whereClause, null)
|
||||||
|
.setParameters(new Object[]{AD_WF_Node_ID})
|
||||||
|
.setOnlyActiveRecords(true)
|
||||||
|
.setOrderBy(COLUMNNAME_SeqNo)
|
||||||
|
.list();
|
||||||
|
s_cache.put(AD_WF_Node_ID, lines);
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
public MPPWFNodeAsset (Properties ctx, int PP_WF_Node_Asset_ID, String trxName)
|
public MPPWFNodeAsset (Properties ctx, int PP_WF_Node_Asset_ID, String trxName)
|
||||||
{
|
{
|
||||||
super (ctx, PP_WF_Node_Asset_ID, trxName);
|
super (ctx, PP_WF_Node_Asset_ID, trxName);
|
||||||
if (PP_WF_Node_Asset_ID == 0)
|
if (PP_WF_Node_Asset_ID == 0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // MQMSpecification
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load Constructor
|
|
||||||
* @param ctx context
|
|
||||||
* @param rs result set
|
|
||||||
*/
|
|
||||||
public MPPWFNodeAsset (Properties ctx, ResultSet rs, String trxName)
|
public MPPWFNodeAsset (Properties ctx, ResultSet rs, String trxName)
|
||||||
{
|
{
|
||||||
super(ctx, rs, trxName);
|
super(ctx, rs, trxName);
|
||||||
} // MPPWFNodeAsset
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Lines */
|
|
||||||
private static Collection <MPPWFNodeAsset> m_lines = new ArrayList<MPPWFNodeAsset>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param ctx
|
|
||||||
* @param AD_WF_Node_ID
|
|
||||||
* @param trxName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static Collection<MPPWFNodeAsset> get(Properties ctx, int AD_WF_Node_ID , String trxName)
|
|
||||||
{
|
|
||||||
if(!m_lines.isEmpty())
|
|
||||||
return m_lines;
|
|
||||||
|
|
||||||
String whereClause = "AD_WF_Node_ID=? ";
|
|
||||||
m_lines = new Query(ctx, MPPWFNodeAsset.Table_Name, whereClause, trxName)
|
|
||||||
.setParameters(new Object[]{AD_WF_Node_ID})
|
|
||||||
.setOnlyActiveRecords(true)
|
|
||||||
//.setOrderBy(MPPOrderNodeAsset.COLUMNNAME_SeqNo)
|
|
||||||
.list();
|
|
||||||
return m_lines;
|
|
||||||
} // getLines
|
|
||||||
} // MPPWFNodeAsset
|
|
||||||
|
|
|
@ -12,67 +12,80 @@
|
||||||
* For the text or an alternative of this public license, you may reach us *
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
||||||
* Contributor(s): Victor Perez www.e-evolution.com *
|
* Contributor(s): Victor Perez www.e-evolution.com *
|
||||||
|
* Teo Sarca, www.arhipac.ro *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.eevolution.model;
|
package org.eevolution.model;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.compiere.model.Query;
|
import org.compiere.model.Query;
|
||||||
|
import org.compiere.util.CCache;
|
||||||
|
import org.compiere.util.DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forcast Line Model
|
* Workflow Node Product Model
|
||||||
*
|
*
|
||||||
* @author Victor Perez www.e-evolution.com
|
* @author Victor Perez www.e-evolution.com
|
||||||
* @version $Id: MPPWFNodeProduct.java,v 1.11 2005/05/17 05:29:52 vpj-cd vpj-cd $
|
* @author Teo Sarca, www.arhipac.ro
|
||||||
*/
|
*/
|
||||||
public class MPPWFNodeProduct extends X_PP_WF_Node_Product
|
public class MPPWFNodeProduct extends X_PP_WF_Node_Product
|
||||||
{
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** Cache */
|
||||||
|
private static CCache<Integer, Collection<MPPWFNodeProduct>>
|
||||||
|
s_cache = new CCache<Integer, Collection<MPPWFNodeProduct>>(Table_Name, 20);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Constructor
|
* @return array of node products
|
||||||
* @param ctx context
|
|
||||||
* @param M_ForecastLine_ID id
|
|
||||||
*/
|
*/
|
||||||
|
public static Collection<MPPWFNodeProduct> forAD_WF_Node_ID(Properties ctx, int AD_WF_Node_ID)
|
||||||
|
{
|
||||||
|
Collection<MPPWFNodeProduct> lines = s_cache.get(AD_WF_Node_ID);
|
||||||
|
if (lines != null)
|
||||||
|
{
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String whereClause = COLUMNNAME_AD_WF_Node_ID+"=?";
|
||||||
|
lines = new Query(ctx, Table_Name, whereClause, null)
|
||||||
|
.setParameters(new Object[]{AD_WF_Node_ID})
|
||||||
|
.setOnlyActiveRecords(true)
|
||||||
|
.setOrderBy(COLUMNNAME_SeqNo)
|
||||||
|
.list();
|
||||||
|
s_cache.put(AD_WF_Node_ID, lines);
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
public MPPWFNodeProduct (Properties ctx, int PP_WF_Node_Product_ID, String trxName)
|
public MPPWFNodeProduct (Properties ctx, int PP_WF_Node_Product_ID, String trxName)
|
||||||
{
|
{
|
||||||
super (ctx, PP_WF_Node_Product_ID, trxName);
|
super (ctx, PP_WF_Node_Product_ID, trxName);
|
||||||
if (PP_WF_Node_Product_ID == 0)
|
if (PP_WF_Node_Product_ID == 0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // MQMSpecification
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load Constructor
|
|
||||||
* @param ctx context
|
|
||||||
* @param rs result set
|
|
||||||
*/
|
|
||||||
public MPPWFNodeProduct (Properties ctx, ResultSet rs, String trxName)
|
public MPPWFNodeProduct (Properties ctx, ResultSet rs, String trxName)
|
||||||
{
|
{
|
||||||
super(ctx, rs, trxName);
|
super(ctx, rs, trxName);
|
||||||
} // MQMSpecification
|
}
|
||||||
|
|
||||||
/** Lines */
|
@Override
|
||||||
private static Collection <MPPWFNodeProduct> m_lines = new ArrayList<MPPWFNodeProduct>();
|
protected boolean beforeSave(boolean newRecord)
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Lines
|
|
||||||
* @return array of lines
|
|
||||||
*/
|
|
||||||
public static Collection<MPPWFNodeProduct> get(Properties ctx, int AD_WF_Node_ID , String trxName)
|
|
||||||
{
|
{
|
||||||
if(!m_lines.isEmpty())
|
if (getSeqNo() == 0)
|
||||||
return m_lines;
|
{
|
||||||
|
final String sql = "SELECT COALESCE(MAX("+COLUMNNAME_SeqNo+"),0)+10 FROM "+Table_Name+" WHERE "
|
||||||
|
+" "+COLUMNNAME_AD_WF_Node_ID+"=?"
|
||||||
|
+" AND "+COLUMNNAME_PP_WF_Node_Product_ID+"<>?";
|
||||||
|
int seqNo = DB.getSQLValueEx(get_TrxName(), sql, getAD_WF_Node_ID(), get_ID());
|
||||||
|
setSeqNo(seqNo);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
String whereClause = "AD_WF_Node_ID=?";
|
|
||||||
m_lines = new Query(ctx, MPPWFNodeProduct.Table_Name, whereClause, trxName)
|
|
||||||
.setParameters(new Object[]{AD_WF_Node_ID})
|
|
||||||
.setOnlyActiveRecords(true)
|
|
||||||
.setOrderBy(MPPWFNodeProduct.COLUMNNAME_SeqNo)
|
|
||||||
.list();
|
|
||||||
return m_lines;
|
|
||||||
} // getMPPOrderNodeProduct
|
|
||||||
|
|
||||||
} // MPPWFNodeProduct
|
} // MPPWFNodeProduct
|
||||||
|
|
|
@ -1,109 +0,0 @@
|
||||||
/******************************************************************************
|
|
||||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
|
||||||
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
|
|
||||||
* This program is free software;
|
|
||||||
you can redistribute it and/or modify it *
|
|
||||||
* under the terms version 2 of the GNU General Public License as published *
|
|
||||||
* by the Free Software Foundation. This program is distributed in the hope *
|
|
||||||
* that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
without even the implied *
|
|
||||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
|
||||||
* See the GNU General Public License for more details. *
|
|
||||||
* You should have received a copy of the GNU General Public License along *
|
|
||||||
* with this program;
|
|
||||||
if not, write to the Free Software Foundation, Inc., *
|
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
|
||||||
* For the text or an alternative of this public license, you may reach us *
|
|
||||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
|
||||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
|
||||||
*****************************************************************************/
|
|
||||||
package org.eevolution.model;
|
|
||||||
|
|
||||||
/** Generated Model - DO NOT CHANGE */
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.compiere.model.MTable;
|
|
||||||
import org.compiere.model.PO;
|
|
||||||
import org.compiere.model.POInfo;
|
|
||||||
import org.compiere.util.KeyNamePair;
|
|
||||||
/** Generated Model for RV_PP_Order_Storage
|
|
||||||
* @author Adempiere (generated)
|
|
||||||
* @version Release 3.1.5 - $Id$ */
|
|
||||||
public class X_RV_PP_Order_Storage extends PO
|
|
||||||
{
|
|
||||||
/** Standard Constructor
|
|
||||||
@param ctx context
|
|
||||||
@param RV_PP_Order_Storage_ID id
|
|
||||||
@param trxName transaction
|
|
||||||
*/
|
|
||||||
public X_RV_PP_Order_Storage (Properties ctx, int RV_PP_Order_Storage_ID, String trxName)
|
|
||||||
{
|
|
||||||
super (ctx, RV_PP_Order_Storage_ID, trxName);
|
|
||||||
/** if (RV_PP_Order_Storage_ID == 0)
|
|
||||||
{
|
|
||||||
setRV_PP_Order_Storage_ID (0);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
/** Load Constructor
|
|
||||||
@param ctx context
|
|
||||||
@param rs result set
|
|
||||||
@param trxName transaction
|
|
||||||
*/
|
|
||||||
public X_RV_PP_Order_Storage (Properties ctx, ResultSet rs, String trxName)
|
|
||||||
{
|
|
||||||
super (ctx, rs, trxName);
|
|
||||||
}
|
|
||||||
/** AD_Table_ID=50057 */
|
|
||||||
public static final int Table_ID=MTable.getTable_ID("RV_PP_Order_Storage");
|
|
||||||
|
|
||||||
/** TableName=RV_PP_Order_Storage */
|
|
||||||
public static final String Table_Name="RV_PP_Order_Storage";
|
|
||||||
|
|
||||||
protected static KeyNamePair Model = new KeyNamePair(Table_ID,"RV_PP_Order_Storage");
|
|
||||||
|
|
||||||
protected BigDecimal accessLevel = BigDecimal.valueOf(3);
|
|
||||||
/** AccessLevel
|
|
||||||
@return 3 - Client - Org
|
|
||||||
*/
|
|
||||||
protected int get_AccessLevel()
|
|
||||||
{
|
|
||||||
return accessLevel.intValue();
|
|
||||||
}
|
|
||||||
/** Load Meta Data
|
|
||||||
@param ctx context
|
|
||||||
@return PO Info
|
|
||||||
*/
|
|
||||||
protected POInfo initPO (Properties ctx)
|
|
||||||
{
|
|
||||||
POInfo poi = POInfo.getPOInfo (ctx, Table_ID);
|
|
||||||
return poi;
|
|
||||||
}
|
|
||||||
/** Info
|
|
||||||
@return info
|
|
||||||
*/
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuffer sb = new StringBuffer ("X_RV_PP_Order_Storage[").append(get_ID()).append("]");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
/** Set RV_PP_Order_Storage.
|
|
||||||
@param RV_PP_Order_Storage_ID RV_PP_Order_Storage */
|
|
||||||
public void setRV_PP_Order_Storage_ID (int RV_PP_Order_Storage_ID)
|
|
||||||
{
|
|
||||||
if (RV_PP_Order_Storage_ID < 1) throw new IllegalArgumentException ("RV_PP_Order_Storage_ID is mandatory.");
|
|
||||||
set_ValueNoCheck ("RV_PP_Order_Storage_ID", Integer.valueOf(RV_PP_Order_Storage_ID));
|
|
||||||
}
|
|
||||||
/** Get RV_PP_Order_Storage.
|
|
||||||
@return RV_PP_Order_Storage */
|
|
||||||
public int getRV_PP_Order_Storage_ID()
|
|
||||||
{
|
|
||||||
Integer ii = (Integer)get_Value("RV_PP_Order_Storage_ID");
|
|
||||||
if (ii == null) return 0;
|
|
||||||
return ii.intValue();
|
|
||||||
}
|
|
||||||
/** Column name RV_PP_Order_Storage_ID */
|
|
||||||
public static final String COLUMNNAME_RV_PP_Order_Storage_ID = "RV_PP_Order_Storage_ID";
|
|
||||||
}
|
|
|
@ -97,7 +97,10 @@ public class CRPReasoner
|
||||||
params.add(Env.getAD_Client_ID(getCtx()));
|
params.add(Env.getAD_Client_ID(getCtx()));
|
||||||
|
|
||||||
// Skip voided, reversed and closed orders:
|
// Skip voided, reversed and closed orders:
|
||||||
whereClause.append(" AND ").append(MPPOrder.COLUMNNAME_DocStatus).append(" NOT IN ('VO', 'RE', 'CL')");
|
whereClause.append(" AND ").append(MPPOrder.COLUMNNAME_DocStatus).append(" NOT IN (?,?,?)");
|
||||||
|
params.add(MPPOrder.DOCSTATUS_Voided);
|
||||||
|
params.add(MPPOrder.DOCSTATUS_Reversed);
|
||||||
|
params.add(MPPOrder.DOCSTATUS_Closed);
|
||||||
|
|
||||||
|
|
||||||
// For given resource (if any)
|
// For given resource (if any)
|
||||||
|
@ -124,7 +127,9 @@ public class CRPReasoner
|
||||||
params.add(r.get_ID());
|
params.add(r.get_ID());
|
||||||
final String whereClause =
|
final String whereClause =
|
||||||
// Checks the requested resource id directly on order node, not on resource id of the order
|
// Checks the requested resource id directly on order node, not on resource id of the order
|
||||||
"PP_Order_ID IN (SELECT PP_Order_ID FROM PP_Order_Node WHERE S_Resource_ID=?"
|
"EXISTS (SELECT 1 FROM PP_Order_Node WHERE "
|
||||||
|
+" PP_Order_Node.PP_Order_ID=PP_Order.PP_Order_ID"
|
||||||
|
+" AND S_Resource_ID=?"
|
||||||
// ... and only the orders running on given day
|
// ... and only the orders running on given day
|
||||||
+" AND "+getSQLDayRestriction(dateTime, r, params)
|
+" AND "+getSQLDayRestriction(dateTime, r, params)
|
||||||
+")"
|
+")"
|
||||||
|
@ -168,6 +173,13 @@ public class CRPReasoner
|
||||||
return r.getResourceType().isAvailable();
|
return r.getResourceType().isAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Next/Previous Available Date
|
||||||
|
* @param t
|
||||||
|
* @param dateTime
|
||||||
|
* @param isScheduleBackward
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private Timestamp getAvailableDate(MResourceType t, Timestamp dateTime, boolean isScheduleBackward)
|
private Timestamp getAvailableDate(MResourceType t, Timestamp dateTime, boolean isScheduleBackward)
|
||||||
{
|
{
|
||||||
Timestamp date = TimeUtil.trunc(dateTime, TimeUtil.TRUNC_DAY);
|
Timestamp date = TimeUtil.trunc(dateTime, TimeUtil.TRUNC_DAY);
|
||||||
|
|
|
@ -77,8 +77,8 @@ public class CRP extends SvrProcess {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String doIt() throws Exception {
|
protected String doIt() throws Exception
|
||||||
|
{
|
||||||
return runCRP();
|
return runCRP();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,8 @@ public class CRP extends SvrProcess {
|
||||||
log.fine("PP_Order Node:" + node.getName() != null ? node.getName() : "" + " Description:" + node.getDescription() != null ? node.getDescription() : "");
|
log.fine("PP_Order Node:" + node.getName() != null ? node.getName() : "" + " Description:" + node.getDescription() != null ? node.getDescription() : "");
|
||||||
MResource resource = MResource.get(getCtx(), node.getS_Resource_ID());
|
MResource resource = MResource.get(getCtx(), node.getS_Resource_ID());
|
||||||
|
|
||||||
if(resource== null)
|
// Skip this node if there is no resource
|
||||||
|
if(resource == null)
|
||||||
{
|
{
|
||||||
nodeId = owf.getNext(nodeId, getAD_Client_ID());
|
nodeId = owf.getNext(nodeId, getAD_Client_ID());
|
||||||
continue;
|
continue;
|
||||||
|
@ -145,6 +146,7 @@ public class CRP extends SvrProcess {
|
||||||
date = node.getDateFinishSchedule();
|
date = node.getDateFinishSchedule();
|
||||||
nodeId = owf.getNext(nodeId, getAD_Client_ID());
|
nodeId = owf.getNext(nodeId, getAD_Client_ID());
|
||||||
}
|
}
|
||||||
|
// Update order finish date
|
||||||
if (node != null && node.getDateFinishSchedule()!= null)
|
if (node != null && node.getDateFinishSchedule()!= null)
|
||||||
{
|
{
|
||||||
order.setDateFinishSchedule(node.getDateFinishSchedule());
|
order.setDateFinishSchedule(node.getDateFinishSchedule());
|
||||||
|
@ -163,7 +165,8 @@ public class CRP extends SvrProcess {
|
||||||
log.fine("PP_Order Node:" + node.getName() != null ? node.getName() : "" + " Description:" + node.getDescription() != null ? node.getDescription() : "");
|
log.fine("PP_Order Node:" + node.getName() != null ? node.getName() : "" + " Description:" + node.getDescription() != null ? node.getDescription() : "");
|
||||||
MResource resource = MResource.get(getCtx(), node.getS_Resource_ID());
|
MResource resource = MResource.get(getCtx(), node.getS_Resource_ID());
|
||||||
|
|
||||||
if(resource== null)
|
// Skip this node if there is no resource
|
||||||
|
if(resource == null)
|
||||||
{
|
{
|
||||||
nodeId = owf.getPrevious(nodeId, getAD_Client_ID());
|
nodeId = owf.getPrevious(nodeId, getAD_Client_ID());
|
||||||
continue;
|
continue;
|
||||||
|
@ -186,14 +189,15 @@ public class CRP extends SvrProcess {
|
||||||
date = node.getDateStartSchedule();
|
date = node.getDateStartSchedule();
|
||||||
nodeId = owf.getPrevious(nodeId, getAD_Client_ID());
|
nodeId = owf.getPrevious(nodeId, getAD_Client_ID());
|
||||||
}
|
}
|
||||||
if (node != null && node.getDateFinishSchedule()!= null)
|
// Update order start date
|
||||||
|
if (node != null && node.getDateStartSchedule() != null)
|
||||||
{
|
{
|
||||||
order.setDateStartSchedule(node.getDateStartSchedule()) ;
|
order.setDateStartSchedule(node.getDateStartSchedule()) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new AdempiereException("@Unknown scheduling method - "+p_ScheduleType);
|
throw new AdempiereException("Unknown scheduling method - "+p_ScheduleType);
|
||||||
}
|
}
|
||||||
|
|
||||||
order.saveEx(get_TrxName());
|
order.saveEx(get_TrxName());
|
||||||
|
@ -210,7 +214,7 @@ public class CRP extends SvrProcess {
|
||||||
// ... its static single parts ...
|
// ... its static single parts ...
|
||||||
long totalDuration =
|
long totalDuration =
|
||||||
//node.getQueuingTime()
|
//node.getQueuingTime()
|
||||||
node.getSetupTimeRequiered() // Use the present required setup time to notice later changes
|
+ node.getSetupTimeRequiered() // Use the present required setup time to notice later changes
|
||||||
+ node.getMovingTime()
|
+ node.getMovingTime()
|
||||||
+ node.getWaitingTime()
|
+ node.getWaitingTime()
|
||||||
;
|
;
|
||||||
|
@ -222,7 +226,7 @@ public class CRP extends SvrProcess {
|
||||||
return (long)(totalDuration * commonBase * 1000);
|
return (long)(totalDuration * commonBase * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Timestamp scheduleForward(Timestamp start, long nodeDuration, MResource r, MResourceType t)
|
private Timestamp scheduleForward(Timestamp start, long nodeDurationMillis, MResource r, MResourceType t)
|
||||||
{
|
{
|
||||||
Timestamp end = null;
|
Timestamp end = null;
|
||||||
int iteration = 0; // statistical interation count
|
int iteration = 0; // statistical interation count
|
||||||
|
@ -242,39 +246,40 @@ public class CRP extends SvrProcess {
|
||||||
long availableDayDuration = dayEnd.getTime() - dayStart.getTime();
|
long availableDayDuration = dayEnd.getTime() - dayStart.getTime();
|
||||||
|
|
||||||
// The work can be finish on this day.
|
// The work can be finish on this day.
|
||||||
if(availableDayDuration >= nodeDuration)
|
if(availableDayDuration >= nodeDurationMillis)
|
||||||
{
|
{
|
||||||
end = new Timestamp(dayStart.getTime() + nodeDuration);
|
end = new Timestamp(dayStart.getTime() + nodeDurationMillis);
|
||||||
nodeDuration = 0;
|
nodeDurationMillis = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Otherwise recall with next day and the remained node duration.
|
// Otherwise recall with next day and the remained node duration.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
start = TimeUtil.addDays(TimeUtil.getDayBorder(start, null, false), 1);
|
start = TimeUtil.addDays(TimeUtil.getDayBorder(start, null, false), 1);
|
||||||
nodeDuration -= availableDayDuration;
|
nodeDurationMillis -= availableDayDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
iteration++;
|
iteration++;
|
||||||
} while (nodeDuration > 0);
|
} while (nodeDurationMillis > 0);
|
||||||
|
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Timestamp scheduleBackward(Timestamp end, long nodeDuration, MResource r, MResourceType t)
|
private Timestamp scheduleBackward(Timestamp end, long nodeDurationMillis, MResource r, MResourceType t)
|
||||||
{
|
{
|
||||||
log.fine("--> ResourceType " + t);
|
log.fine("--> ResourceType " + t);
|
||||||
Timestamp start = null;
|
Timestamp start = null;
|
||||||
int iteration = 0; // statistical interation count
|
int iteration = 0; // statistical iteration count
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
log.fine("--> end " +end);
|
log.fine("--> end=" + end);
|
||||||
log.fine("--> nodeDuration=" +nodeDuration);
|
log.fine("--> nodeDuration=" + nodeDurationMillis);
|
||||||
|
|
||||||
end = reasoner.getAvailableDate(r, end, true);
|
end = reasoner.getAvailableDate(r, end, true);
|
||||||
Timestamp dayEnd = t.getDayEnd(end);
|
Timestamp dayEnd = t.getDayEnd(end);
|
||||||
Timestamp dayStart = t.getDayStart(end);
|
Timestamp dayStart = t.getDayStart(end);
|
||||||
log.fine("--> dayEnd=" + dayEnd + ", dayStart=" + dayStart);
|
log.fine("--> dayStart=" + dayStart + ", dayEnd=" + dayEnd);
|
||||||
|
|
||||||
// If working has already began at this day and the value is in the range of the
|
// If working has already began at this day and the value is in the range of the
|
||||||
// resource's availability, switch end time to the given again
|
// resource's availability, switch end time to the given again
|
||||||
if(end.before(dayEnd) && end.after(dayStart))
|
if(end.before(dayEnd) && end.after(dayStart))
|
||||||
|
@ -287,26 +292,26 @@ public class CRP extends SvrProcess {
|
||||||
log.fine("--> availableDayDuration " + availableDayDuration);
|
log.fine("--> availableDayDuration " + availableDayDuration);
|
||||||
|
|
||||||
// The work can be finish on this day.
|
// The work can be finish on this day.
|
||||||
if(availableDayDuration >= nodeDuration)
|
if(availableDayDuration >= nodeDurationMillis)
|
||||||
{
|
{
|
||||||
log.fine("--> availableDayDuration >= nodeDuration true " + availableDayDuration + "|" + nodeDuration );
|
log.fine("--> availableDayDuration >= nodeDuration true " + availableDayDuration + "|" + nodeDurationMillis );
|
||||||
start = new Timestamp(dayEnd.getTime() - nodeDuration);
|
start = new Timestamp(dayEnd.getTime() - nodeDurationMillis);
|
||||||
nodeDuration = 0;
|
nodeDurationMillis = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Otherwise recall with previous day and the remained node duration.
|
// Otherwise recall with previous day and the remained node duration.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log.fine("--> availableDayDuration >= nodeDuration false " + availableDayDuration + "|" + nodeDuration );
|
log.fine("--> availableDayDuration >= nodeDuration false " + availableDayDuration + "|" + nodeDurationMillis );
|
||||||
log.fine("--> nodeDuration-availableDayDuration " + (nodeDuration-availableDayDuration) );
|
log.fine("--> nodeDuration-availableDayDuration " + (nodeDurationMillis-availableDayDuration) );
|
||||||
|
|
||||||
end = TimeUtil.addDays(TimeUtil.getDayBorder(end, null, true), -1);
|
end = TimeUtil.addDays(TimeUtil.getDayBorder(end, null, true), -1);
|
||||||
nodeDuration -= availableDayDuration;
|
nodeDurationMillis -= availableDayDuration;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
iteration++;
|
iteration++;
|
||||||
}
|
}
|
||||||
while(nodeDuration > 0);
|
while(nodeDurationMillis > 0);
|
||||||
|
|
||||||
log.fine(" --> start=" + start + " <---------------------------------------- ");
|
log.fine(" --> start=" + start + " <---------------------------------------- ");
|
||||||
return start;
|
return start;
|
||||||
|
|
|
@ -371,9 +371,9 @@ public class MRP extends SvrProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
// New Product
|
// New Product
|
||||||
if (product == null || product.get_ID() != rs.getInt("M_Product_ID"))
|
if (product == null || product.get_ID() != rs.getInt(MPPMRP.COLUMNNAME_M_Product_ID))
|
||||||
{
|
{
|
||||||
product = MProduct.get(getCtx(), rs.getInt("M_Product_ID"));
|
product = MProduct.get(getCtx(), rs.getInt(MPPMRP.COLUMNNAME_M_Product_ID));
|
||||||
log.info("Calculte Plan to this Product:" + product.getName());
|
log.info("Calculte Plan to this Product:" + product.getName());
|
||||||
|
|
||||||
//if exist QtyGrossReq of last Demand verify plan
|
//if exist QtyGrossReq of last Demand verify plan
|
||||||
|
|
|
@ -59,24 +59,22 @@ public class RollupBillOfMaterial extends SvrProcess
|
||||||
*/
|
*/
|
||||||
protected void prepare()
|
protected void prepare()
|
||||||
{
|
{
|
||||||
ProcessInfoParameter[] para = getParameter();
|
for (ProcessInfoParameter para : getParameter())
|
||||||
|
|
||||||
for (int i = 0; i < para.length; i++)
|
|
||||||
{
|
{
|
||||||
String name = para[i].getParameterName();
|
String name = para.getParameterName();
|
||||||
|
|
||||||
if (para[i].getParameter() == null)
|
if (para.getParameter() == null)
|
||||||
;
|
;
|
||||||
else if (name.equals("AD_Org_ID"))
|
else if (name.equals("AD_Org_ID"))
|
||||||
p_AD_Org_ID = para[i].getParameterAsInt();
|
p_AD_Org_ID = para.getParameterAsInt();
|
||||||
else if (name.equals(MAcctSchema.COLUMNNAME_C_AcctSchema_ID))
|
else if (name.equals(MAcctSchema.COLUMNNAME_C_AcctSchema_ID))
|
||||||
p_C_AcctSchema_ID = para[i].getParameterAsInt();
|
p_C_AcctSchema_ID = para.getParameterAsInt();
|
||||||
else if (name.equals(MCostType.COLUMNNAME_M_CostType_ID))
|
else if (name.equals(MCostType.COLUMNNAME_M_CostType_ID))
|
||||||
p_M_CostType_ID = para[i].getParameterAsInt();
|
p_M_CostType_ID = para.getParameterAsInt();
|
||||||
else if (name.equals(MProduct.COLUMNNAME_M_Product_ID))
|
else if (name.equals(MProduct.COLUMNNAME_M_Product_ID))
|
||||||
p_M_Product_ID = para[i].getParameterAsInt();
|
p_M_Product_ID = para.getParameterAsInt();
|
||||||
else if (name.equals(MProduct.COLUMNNAME_M_Product_Category_ID))
|
else if (name.equals(MProduct.COLUMNNAME_M_Product_Category_ID))
|
||||||
p_M_Product_Category_ID = para[i].getParameterAsInt();
|
p_M_Product_Category_ID = para.getParameterAsInt();
|
||||||
else
|
else
|
||||||
log.log(Level.SEVERE,"prepare - Unknown Parameter: " + name);
|
log.log(Level.SEVERE,"prepare - Unknown Parameter: " + name);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue