diff --git a/base/src/org/compiere/process/DistributionRun.java b/base/src/org/compiere/process/DistributionRun.java index 7fc9b7ea31..51c048f935 100644 --- a/base/src/org/compiere/process/DistributionRun.java +++ b/base/src/org/compiere/process/DistributionRun.java @@ -18,9 +18,15 @@ package org.compiere.process; import java.math.*; import java.sql.*; +import java.util.List; import java.util.logging.*; + +import org.adempiere.exceptions.AdempiereException; import org.compiere.model.*; import org.compiere.util.*; +import org.eevolution.model.MDDOrder; +import org.eevolution.model.MDDOrderLine; +import org.eevolution.model.MPPMRP; /** * Create Distribution @@ -38,6 +44,10 @@ public class DistributionRun extends SvrProcess private int p_C_DocType_ID = 0; /** Test Mode */ private boolean p_IsTest = false; + /** Warehouse to Distribution Order */ + private int p_M_Warehouse_ID = 0; + /** Create Ordered **/ + private boolean p_CreateDO = true; /** Distribution Run */ private MDistributionRun m_run = null; @@ -66,11 +76,18 @@ public class DistributionRun extends SvrProcess if (para[i].getParameter() == null) ; else if (name.equals("C_DocType_ID")) + { p_C_DocType_ID = ((BigDecimal)para[i].getParameter()).intValue(); + m_docType = new MDocType(getCtx(),p_C_DocType_ID, get_TrxName()); + } else if (name.equals("DatePromised")) p_DatePromised = (Timestamp)para[i].getParameter(); else if (name.equals("IsTest")) p_IsTest = "Y".equals(para[i].getParameter()); + else if (m_docType.getDocBaseType().equals(MDocType.DOCBASETYPE_DistributionOrder) & name.equals("M_Warehouse_ID")) + p_M_Warehouse_ID=((BigDecimal)para[i].getParameter()).intValue(); + else if (m_docType.getDocBaseType().equals(MDocType.DOCBASETYPE_DistributionOrder) & name.equals("CreateDO")) + p_CreateDO="Y".equals((String)para[i].getParameter()); else log.log(Level.SEVERE, "prepare - Unknown Parameter: " + name); } @@ -109,9 +126,18 @@ public class DistributionRun extends SvrProcess if (p_DatePromised == null) p_DatePromised = m_DateOrdered; - // Create Temp Lines - if (insertDetails() == 0) - throw new Exception ("No Lines"); + if(m_docType.getDocBaseType().equals(MDocType.DOCBASETYPE_DistributionOrder) & p_M_Warehouse_ID > 0) + { + //Create Temp Lines + if (insertDetailsDistribution() == 0) + throw new Exception ("No Lines"); + } + else + { + // Create Temp Lines + if (insertDetails() == 0) + throw new Exception ("No Lines"); + } // Order By Distribution Run Line m_details = MDistributionRunDetail.get(getCtx(), p_M_DistributionRun_ID, false, get_TrxName()); @@ -130,6 +156,13 @@ public class DistributionRun extends SvrProcess // Order By Business Partner m_details = MDistributionRunDetail.get(getCtx(), p_M_DistributionRun_ID, true, get_TrxName()); + + //Implement Distribution Order + if(m_docType.getDocBaseType().equals(MDocType.DOCBASETYPE_DistributionOrder)) + { + distributionOrders(); + } + else // Create Orders createOrders(); @@ -502,4 +535,320 @@ public class DistributionRun extends SvrProcess return true; } // createOrders + + /** + * Insert Details + * @return number of rows inserted + */ + private int insertDetailsDistribution() + { + // Handle NULL + String sql = "UPDATE M_DistributionRunLine SET MinQty = 0 WHERE MinQty IS NULL"; + int no = DB.executeUpdate(sql, get_TrxName()); + + sql = "UPDATE M_DistributionListLine SET MinQty = 0 WHERE MinQty IS NULL"; + no = DB.executeUpdate(sql, get_TrxName()); + + // Delete Old + sql = "DELETE FROM T_DistributionRunDetail WHERE M_DistributionRun_ID=" + + p_M_DistributionRun_ID; + no = DB.executeUpdate(sql, get_TrxName()); + log.fine("insertDetails - deleted #" + no); + + // Insert New + sql = "INSERT INTO T_DistributionRunDetail " + + "(M_DistributionRun_ID, M_DistributionRunLine_ID, M_DistributionList_ID, M_DistributionListLine_ID," + + "AD_Client_ID,AD_Org_ID, IsActive, Created,CreatedBy, Updated,UpdatedBy," + + "C_BPartner_ID, C_BPartner_Location_ID, M_Product_ID," + + "Ratio, MinQty, Qty) " + +"SELECT rl.M_DistributionRun_ID, rl.M_DistributionRunLine_ID,ll.M_DistributionList_ID, ll.M_DistributionListLine_ID, " + +"rl.AD_Client_ID,rl.AD_Org_ID, rl.IsActive, rl.Created,rl.CreatedBy, rl.Updated,rl.UpdatedBy, " + +"ll.C_BPartner_ID, ll.C_BPartner_Location_ID, rl.M_Product_ID, ll.Ratio, " + +"ol.PickedQty AS MinQty , 0 FROM M_DistributionRunLine rl " + +"INNER JOIN M_DistributionList l ON (rl.M_DistributionList_ID=l.M_DistributionList_ID) " + +"INNER JOIN M_DistributionListLine ll ON (rl.M_DistributionList_ID=ll.M_DistributionList_ID) " + +"INNER JOIN DD_Order o ON (o.C_BPartner_ID=ll.C_BPartner_ID) " + +"INNER JOIN DD_OrderLine ol ON (ol.DD_Order_ID=o.DD_Order_ID AND ol.M_Product_ID=rl.M_Product_ID) AND ol.DatePromised BETWEEN " + + DB.TO_DATE(new Timestamp (System.currentTimeMillis())) +" AND "+ DB.TO_DATE(p_DatePromised) + +" INNER JOIN M_Locator loc ON (loc.M_Locator_ID=ol.M_Locator_ID AND loc.M_Warehouse_ID="+p_M_Warehouse_ID+") " + +" WHERE rl.M_DistributionRun_ID="+p_M_DistributionRun_ID+" AND l.RatioTotal<>0 AND rl.IsActive='Y' AND ll.IsActive='Y'"; + no = DB.executeUpdate(sql, get_TrxName()); + + Query query = MTable.get(getCtx(), MDistributionRunDetail.Table_ID). + createQuery(MDistributionRunDetail.COLUMNNAME_M_DistributionRun_ID + "=?", get_TrxName()); + query.setParameters(new Object[]{p_M_DistributionRun_ID}); + + List records = query.list(); + + for(MDistributionRunDetail record : records) + { + BigDecimal total_ration = DB.getSQLValueBD(get_TrxName(), + "SELECT SUM(Ratio) FROM T_DistributionRunDetail WHERE M_DistributionRun_ID=? AND M_Product_ID=? GROUP BY M_Product_ID" + , p_M_DistributionRun_ID, record.getM_Product_ID()); + MDistributionRunLine drl = (MDistributionRunLine) MTable.get(getCtx(), MDistributionRunLine.Table_ID).getPO(record.getM_DistributionRunLine_ID(), get_TrxName()); + BigDecimal ration = record.getRatio(); + BigDecimal factor = ration.divide(total_ration,BigDecimal.ROUND_HALF_UP); + record.setQty(factor.multiply(drl.getTotalQty())); + record.save(); + } + log.fine("inserted #" + no); + return no; + } // insertDetails + + + /************************************************************************** + * Create Orders + * @return true if created + */ + private boolean distributionOrders() + { + if (!p_CreateDO) + { + // For all lines + for (int i = 0; i < m_details.length; i++) + { + MDistributionRunDetail detail = m_details[i]; + + StringBuffer sql = new StringBuffer("SELECT * FROM DD_OrderLine ol INNER JOIN DD_Order o ON (o.DD_Order_ID=ol.DD_Order_ID) INNER JOIN M_Locator l ON (l.M_Locator_ID=ol.M_Locator_ID) "); + sql.append(" WHERE o.DocStatus IN ('DR','IN') AND o.C_BPartner_ID = ? AND M_Product_ID=? AND l.M_Warehouse_ID=? AND ol.DatePromised BETWEEN ? AND ? "); + + PreparedStatement pstmt = null; + ResultSet rs = null; + Timestamp today = new Timestamp (System.currentTimeMillis()); + try + { + pstmt = DB.prepareStatement (sql.toString(),get_TrxName()); + pstmt.setInt(1, detail.getC_BPartner_ID()); + pstmt.setInt(2, detail.getM_Product_ID()); + pstmt.setInt(3, p_M_Warehouse_ID); + pstmt.setTimestamp(4, today); + pstmt.setTimestamp(5, p_DatePromised); + + + rs = pstmt.executeQuery(); + while (rs.next()) + { + // Create Order Line + MDDOrderLine line = new MDDOrderLine(getCtx(), rs , get_TrxName()); + line.setM_Product_ID(detail.getM_Product_ID()); + line.setConfirmedQty(detail.getActualAllocation()); + + //line.setPrice(); + if (!line.save()) + { + log.log(Level.SEVERE, "OrderLine not saved"); + return false; + } + break; + //addLog(0,null, detail.getActualAllocation(), order.getDocumentNo() + // + ": " + bp.getName() + " - " + product.getName()); + } + } + catch (Exception e) + { + log.log(Level.SEVERE,"doIt - " + sql, e); + return false; + } + finally + { + DB.close(rs, pstmt); + rs = null; + pstmt = null; + } + } + + return true; + } + + // Get Counter Org/BP + int runAD_Org_ID = m_run.getAD_Org_ID(); + if (runAD_Org_ID == 0) + runAD_Org_ID = Env.getAD_Org_ID(getCtx()); + MOrg runOrg = MOrg.get(getCtx(), runAD_Org_ID); + int runC_BPartner_ID = runOrg.getLinkedC_BPartner_ID(get_TrxName()); + boolean counter = !m_run.isCreateSingleOrder() // no single Order + && runC_BPartner_ID > 0 // Org linked to BP + && !m_docType.isSOTrx(); // PO + MBPartner runBPartner = counter ? new MBPartner(getCtx(), runC_BPartner_ID, get_TrxName()) : null; + if (!counter || runBPartner == null || runBPartner.get_ID() != runC_BPartner_ID) + counter = false; + if (counter) + log.info("RunBP=" + runBPartner + + " - " + m_docType); + log.info("Single=" + m_run.isCreateSingleOrder() + + " - " + m_docType + ",SO=" + m_docType.isSOTrx()); + log.fine("Counter=" + counter + + ",C_BPartner_ID=" + runC_BPartner_ID + "," + runBPartner); + // + MBPartner bp = null; + MDDOrder singleOrder = null; + MProduct product = null; + // Consolidated Order + if (m_run.isCreateSingleOrder()) + { + bp = new MBPartner (getCtx(), m_run.getC_BPartner_ID(), get_TrxName()); + if (bp.get_ID() == 0) + throw new IllegalArgumentException("Business Partner not found - C_BPartner_ID=" + m_run.getC_BPartner_ID()); + // + if (!p_IsTest) + { + singleOrder = new MDDOrder (getCtx(), 0, get_TrxName()); + //singleOrder.setC_DocTypeTarget_ID(m_docType.getC_DocType_ID()); + singleOrder.setC_DocType_ID(m_docType.getC_DocType_ID()); + singleOrder.setIsSOTrx(m_docType.isSOTrx()); + singleOrder.setBPartner(bp); + if (m_run.getC_BPartner_Location_ID() != 0) + singleOrder.setC_BPartner_Location_ID(m_run.getC_BPartner_Location_ID()); + singleOrder.setDateOrdered(m_DateOrdered); + singleOrder.setDatePromised(p_DatePromised); + if (!singleOrder.save()) + { + log.log(Level.SEVERE, "Order not saved"); + return false; + } + m_counter++; + } + } + + int lastC_BPartner_ID = 0; + int lastC_BPartner_Location_ID = 0; + MDDOrder order = null; + MWarehouse m_source = null; + MLocator m_locator= null ; + MWarehouse m_target= null; + MLocator m_locator_to= null; + MWarehouse[] ws = null; + + MOrgInfo oi_source = MOrgInfo.get(getCtx(), m_run.getAD_Org_ID()); + m_source = MWarehouse.get(getCtx(), oi_source.getM_Warehouse_ID()); + if(m_source == null) + throw new AdempiereException("Do not exist Defautl Warehouse Source"); + + m_locator = MLocator.getDefault(m_source); + + //get the warehouse in transit + ws = MWarehouse.getInTransitForOrg(getCtx(), m_source.getAD_Org_ID()); + + if(ws==null) + throw new AdempiereException("Warehouse Intransit do not found"); + + // For all lines + for (int i = 0; i < m_details.length; i++) + { + MDistributionRunDetail detail = m_details[i]; + + // Create Order Header + if (m_run.isCreateSingleOrder()) + order = singleOrder; + // New Business Partner + else if (lastC_BPartner_ID != detail.getC_BPartner_ID() + || lastC_BPartner_Location_ID != detail.getC_BPartner_Location_ID()) + { + // finish order + order = null; + } + lastC_BPartner_ID = detail.getC_BPartner_ID(); + lastC_BPartner_Location_ID = detail.getC_BPartner_Location_ID(); + + // New Order + if (order == null) + { + bp = new MBPartner (getCtx(), detail.getC_BPartner_ID(), get_TrxName()); + if (!p_IsTest) + { + order = new MDDOrder (getCtx(), 0, get_TrxName()); + //order.setC_DocTypeTarget_ID(m_docType.getC_DocType_ID()); + order.setAD_Org_ID(bp.getAD_OrgBP_ID_Int()); + order.setC_DocType_ID(m_docType.getC_DocType_ID()); + order.setIsSOTrx(m_docType.isSOTrx()); + + MOrgInfo oi_target = MOrgInfo.get(getCtx(), bp.getAD_OrgBP_ID_Int()); + m_target = MWarehouse.get(getCtx(), oi_target.getM_Warehouse_ID()); + if(m_target==null) + throw new AdempiereException("Do not exist Default Warehouse Target"); + + m_locator_to = MLocator.getDefault(m_target); + + if (m_locator == null || m_locator_to == null) + { + throw new AdempiereException("Do not exist default Locator for Warehouses"); + } + + + // Counter Doc + if (counter && bp.getAD_OrgBP_ID_Int() > 0) + { + log.fine("Counter - From_BPOrg=" + bp.getAD_OrgBP_ID_Int() + + "-" + bp + ", To_BP=" + runBPartner); + order.setAD_Org_ID(bp.getAD_OrgBP_ID_Int()); + if (ws[0].getM_Warehouse_ID() > 0) + order.setM_Warehouse_ID(ws[0].getM_Warehouse_ID()); + order.setBPartner(runBPartner); + } + else // normal + { + log.fine("From_Org=" + runAD_Org_ID + + ", To_BP=" + bp); + order.setAD_Org_ID(bp.getAD_OrgBP_ID_Int()); + order.setBPartner(bp); + if (detail.getC_BPartner_Location_ID() != 0) + order.setC_BPartner_Location_ID(detail.getC_BPartner_Location_ID()); + } + order.setDateOrdered(m_DateOrdered); + order.setDatePromised(p_DatePromised); + order.setIsInDispute(false); + order.setIsInTransit(false); + if (!order.save()) + { + log.log(Level.SEVERE, "Order not saved"); + return false; + } + } + } + + // Line + if (product == null || product.getM_Product_ID() != detail.getM_Product_ID()) + product = MProduct.get (getCtx(), detail.getM_Product_ID()); + if (p_IsTest) + { + addLog(0,null, detail.getActualAllocation(), + bp.getName() + " - " + product.getName()); + continue; + } + + // Create Order Line + MDDOrderLine line = new MDDOrderLine(order); + if (counter && bp.getAD_OrgBP_ID_Int() > 0) + ; // don't overwrite counter doc + /*else // normal - optionally overwrite + { + line.setC_BPartner_ID(detail.getC_BPartner_ID()); + if (detail.getC_BPartner_Location_ID() != 0) + line.setC_BPartner_Location_ID(detail.getC_BPartner_Location_ID()); + }*/ + // + line.setAD_Org_ID(bp.getAD_OrgBP_ID_Int()); + line.setM_Locator_ID(m_locator.getM_Locator_ID()); + line.setM_LocatorTo_ID(m_locator_to.getM_Locator_ID()); + line.setIsInvoiced(false); + line.setProduct(product); + line.setQty(detail.getActualAllocation()); + line.setPickedQty(detail.getActualAllocation()); + line.setQtyEntered(detail.getActualAllocation()); + line.setConfirmedQty(detail.getActualAllocation()); + //line.setQty(detail.getActualAllocation()); + //line.setPrice(); + if (!line.save()) + { + log.log(Level.SEVERE, "OrderLine not saved"); + return false; + } + addLog(0,null, detail.getActualAllocation(), order.getDocumentNo() + + ": " + bp.getName() + " - " + product.getName()); + } + // finish order + order = null; + return true; + } + } // DistributionRun diff --git a/base/src/org/eevolution/process/DistributionRunOrders.java b/base/src/org/eevolution/process/DistributionRunOrders.java new file mode 100644 index 0000000000..243db670fe --- /dev/null +++ b/base/src/org/eevolution/process/DistributionRunOrders.java @@ -0,0 +1,300 @@ +/****************************************************************************** + * 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.eevolution.process; + +import java.math.BigDecimal; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Timestamp; +import java.util.logging.Level; + +import org.compiere.apps.ProcessCtl; +import org.compiere.model.MDistributionRun; +import org.compiere.model.MDistributionRunLine; +import org.compiere.model.MDocType; +import org.compiere.model.MMessage; +import org.compiere.model.MNote; +import org.compiere.model.MPInstance; +import org.compiere.model.MPInstancePara; +import org.compiere.model.MProcess; +import org.compiere.model.MProcessPara; +import org.compiere.model.MRequisition; +import org.compiere.model.MRequisitionLine; +import org.compiere.model.MStorage; +import org.compiere.model.MWarehouse; +import org.compiere.model.X_ASP_Process; +import org.compiere.model.X_ASP_Process_Para; +import org.compiere.process.ProcessInfo; +import org.compiere.process.ProcessInfoParameter; +import org.compiere.process.SvrProcess; +import org.compiere.util.ASyncProcess; +import org.compiere.util.CLogger; +import org.compiere.util.DB; +import org.compiere.util.Env; +import org.compiere.util.KeyNamePair; +import org.compiere.util.Msg; +import org.compiere.util.TimeUtil; +import org.compiere.util.Trx; +import org.eevolution.model.MPPMRP; +import org.eevolution.model.MPPOrder; + +/** + * MRPUpdate + * + * @author Victor Perez, e-Evolution, S.C. + */ +public class DistributionRunOrders extends SvrProcess +{ + /** The Run to execute */ + + private int p_M_DistributionList_ID = 0; + + + /** Date Promised */ + private Timestamp p_DatePromised = null; + /** Organization */ + private int p_AD_Org_ID = 0; + /** Is Only Test */ + private String p_IsTest = "N"; + /** Warehouse */ + private int p_M_Warehouse_ID = 0; + /** Create Ordered DO Yes Create No Update */ + private String p_CreateDO = "N"; + + private MDistributionRun m_run = null; + private int m_M_DistributionRun_ID = 0; + + + /** + * Prepare - e.g., get Parameters. + */ + protected void prepare() + { + ProcessInfoParameter[] para = getParameter(); + + for (int i = 0; i < para.length; i++) + { + String name = para[i].getParameterName(); + + if (para[i].getParameter() == null) + ; + else if (name.equals("AD_Org_ID")) + { + p_AD_Org_ID = ((BigDecimal)para[i].getParameter()).intValue(); + + } + else if (name.equals("M_Warehouse_ID")) + { + p_M_Warehouse_ID = ((BigDecimal)para[i].getParameter()).intValue(); + } + else if (name.equals("M_DistributionList_ID")) + { + p_M_DistributionList_ID = ((BigDecimal)para[i].getParameter()).intValue(); + } + else if (name.equals("DatePromised")) + p_DatePromised = (Timestamp)para[i].getParameter(); + else if (name.equals("CreateDO")) + p_CreateDO = (String)para[i].getParameter(); + else if (name.equals("IsTest")) + p_IsTest = (String)para[i].getParameter(); + else + log.log(Level.SEVERE,"prepare - Unknown Parameter: " + name); + } + + } // prepare + + + /** + * doIT - run process + */ + protected String doIt() throws Exception + { + /*if(p_M_Warehouse_ID==0) + { + MWarehouse[] ws = MWarehouse.getForOrg(getCtx(), p_AD_Org_ID); + for(MWarehouse w : ws) + { + if(!deleteRecord(m_AD_Client_ID,p_AD_Org_ID,p_S_Resource_ID,w.getM_Warehouse_ID())) + throw new Exception(Msg.getMsg(getCtx(), "ProcessFailed"),CLogger.retrieveException()); + if(!createRecord(m_AD_Client_ID,p_AD_Org_ID,p_S_Resource_ID,w.getM_Warehouse_ID())) + throw new Exception(Msg.getMsg(getCtx(), "ProcessFailed"),CLogger.retrieveException()); + } + } + else + { + if(!deleteRecord(m_AD_Client_ID,p_AD_Org_ID,p_S_Resource_ID,p_M_Warehouse_ID)) + throw new Exception(Msg.getMsg(getCtx(), "ProcessFailed"),CLogger.retrieveException()); + if(!createRecord(m_AD_Client_ID,p_AD_Org_ID,p_S_Resource_ID,p_M_Warehouse_ID)) + throw new Exception(Msg.getMsg(getCtx(), "ProcessFailed"),CLogger.retrieveException()); + }*/ + + if(!generateDistribution()) + throw new Exception(Msg.getMsg(getCtx(), "ProcessFailed"),CLogger.retrieveException()); + if(!executeDistribution()) + throw new Exception(Msg.getMsg(getCtx(), "ProcessFailed"),CLogger.retrieveException()); + + return Msg.getMsg(getCtx(), "ProcessOK"); + } + + //Create Distribution Run Line + public boolean generateDistribution() + { + m_run = new MDistributionRun(this.getCtx(), 0 , this.get_TrxName()); + m_run.setName("Generate from DRP " + p_DatePromised); + //m_run.setDescription("Generate from DRP"); + m_run.save(); + + StringBuffer sql = new StringBuffer("SELECT M_Product_ID , SUM (QtyOrdered) AS TotalQty, l.M_Warehouse_ID FROM DD_OrderLine ol INNER JOIN M_Locator l ON (l.M_Locator_ID=ol.M_Locator_ID) INNER JOIN DD_Order o ON (o.DD_Order_ID=ol.DD_Order_ID) "); + sql.append(" WHERE o.DocStatus IN ('DR','IN') AND ol.DatePromised BETWEEN ? AND ? AND l.M_Warehouse_ID=? GROUP BY M_Product_ID, l.M_Warehouse_ID"); + + + PreparedStatement pstmt = null; + ResultSet rs = null; + Timestamp today = new Timestamp (System.currentTimeMillis()); + try + { + pstmt = DB.prepareStatement (sql.toString(),get_TrxName()); + pstmt.setTimestamp(1, today); + pstmt.setTimestamp(2, p_DatePromised); + pstmt.setInt(3, p_M_Warehouse_ID); + + rs = pstmt.executeQuery(); + int line = 10; + while (rs.next()) + { + int M_Product_ID = rs.getInt("M_Product_ID"); + BigDecimal QtyAvailable = MStorage.getQtyAvailable(p_M_Warehouse_ID,0 , M_Product_ID , 0, get_TrxName()); + BigDecimal QtyOrdered = rs.getBigDecimal("TotalQty"); + + MDistributionRunLine m_runLine = new MDistributionRunLine(getCtx(),0 ,get_TrxName()); + m_runLine.setM_DistributionRun_ID(m_run.getM_DistributionRun_ID()); + m_runLine.setAD_Org_ID(p_AD_Org_ID); + m_runLine.setM_DistributionList_ID(p_M_DistributionList_ID); + m_runLine.setLine(line); + m_runLine.setM_Product_ID(M_Product_ID); + m_runLine.setDescription(Msg.getMsg(getCtx(), "QtyAvailable") +" : " + QtyAvailable + " " +Msg.getMsg(getCtx(), "QtyOrdered") + " : " + QtyOrdered); + if(QtyOrdered.compareTo(QtyAvailable) > 0) + { + QtyOrdered = QtyAvailable; + } + m_runLine.setTotalQty(QtyOrdered); + m_runLine.save(); + line += 10; + } + } + catch (Exception e) + { + log.log(Level.SEVERE,"doIt - " + sql, e); + return false; + } + finally + { + DB.close(rs, pstmt); + rs = null; + pstmt = null; + } + + return true; + } + + public boolean executeDistribution() throws Exception + { + + int M_DocType_ID = 0; + MDocType[] doc = MDocType.getOfDocBaseType(getCtx(), MDocType.DOCBASETYPE_DistributionOrder); + + if (doc==null || doc.length == 0) { + log.severe ("Not found default document type for docbasetype " + MDocType.DOCBASETYPE_DistributionOrder); + throw new Exception(Msg.getMsg(getCtx(), "SequenceDocNotFound"),CLogger.retrieveException()); + } + else + M_DocType_ID = doc[0].getC_DocType_ID(); + + String trxName = Trx.createTrxName("Run Distribution to DRP"); + Trx trx = Trx.get(trxName, true); //trx needs to be committed too + + //Prepare Process + int AD_Process_ID = 271; + + + AD_Process_ID = MProcess.getProcess_ID("M_DistributionRun Create",get_TrxName()); + + MPInstance instance = new MPInstance(Env.getCtx(), AD_Process_ID, 0); + if (!instance.save()) + { + throw new Exception(Msg.getMsg(getCtx(), "ProcessNoInstance"),CLogger.retrieveException()); + } + + //call process + ProcessInfo pi = new ProcessInfo ("CreateDistributionFromDRP", AD_Process_ID); + pi.setAD_PInstance_ID (instance.getAD_PInstance_ID()); + pi.setRecord_ID(m_run.getM_DistributionRun_ID()); + // Add Parameter - Selection=Y + MPInstancePara ip = new MPInstancePara(instance, 10); + ip.setParameter("C_DocType_ID", M_DocType_ID ); + if (!ip.save()) + { + String msg = "No Parameter added"; // not translated + throw new Exception(msg,CLogger.retrieveException()); + } + + // Add Parameter - DatePromised + ip = new MPInstancePara(instance, 20); + ip.setParameter("DatePromised", ""); + ip.setP_Date(p_DatePromised); + if (!ip.save()) + { + String msg = "No Parameter added"; // not translated + throw new Exception(msg,CLogger.retrieveException()); + } + + // Add Parameter - M_Warehouse_ID + ip = new MPInstancePara(instance, 30); + ip.setParameter("M_Warehouse_ID",p_M_Warehouse_ID); + if (!ip.save()) + { + String msg = "No Parameter added"; // not translated + throw new Exception(msg,CLogger.retrieveException()); + } + + // Add Parameter - CreateDO + ip = new MPInstancePara(instance, 40); + ip.setParameter("CreateDO",p_CreateDO); + if (!ip.save()) + { + String msg = "No Parameter added"; // not translated + throw new Exception(msg,CLogger.retrieveException()); + } + + // Add Parameter - IsTest=Y + ip = new MPInstancePara(instance, 50); + ip.setParameter("IsTest",p_IsTest); + if (!ip.save()) + { + String msg = "No Parameter added"; // not translated + throw new Exception(msg,CLogger.retrieveException()); + } + + + // Execute Process + MProcess worker = new MProcess(getCtx(),AD_Process_ID,get_TrxName()); + worker.processIt(pi, Trx.get(get_TrxName(), true)); + //ProcessCtl worker = new ProcessCtl(this, 0 , pi, trx); + //worker.start(); // complete tasks in unlockUI / generateShipments_complete + return true; + } +} diff --git a/migration/351a-trunk/244_FR2030865DistributionRunDO.sql b/migration/351a-trunk/244_FR2030865DistributionRunDO.sql new file mode 100644 index 0000000000..6a5404bd0e --- /dev/null +++ b/migration/351a-trunk/244_FR2030865DistributionRunDO.sql @@ -0,0 +1,115 @@ +-- Jul 28, 2008 8:27:38 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process (AD_Client_ID,AD_Org_ID,AD_Process_ID,AccessLevel,Classname,Created,CreatedBy,Description,EntityType,Help,IsActive,IsBetaFunctionality,IsDirectPrint,IsReport,Name,ShowHelp,Statistic_Count,Statistic_Seconds,Updated,UpdatedBy,Value,WorkflowValue) VALUES (0,0,53150,'1','org.eevolution.process.DistributionRunOrders',TO_DATE('2008-07-28 20:27:26','YYYY-MM-DD HH24:MI:SS'),0,'Create Distribution Run Orders based on Distribution List and redistribute the quantity into Distribution Plan line items','EE01','Please note that due to rounding, the total quantity of the order(s) is likely to be higher then the quantity entered.','Y','N','N','N','Distribution Run Orders','Y',0,0,TO_DATE('2008-07-28 20:27:26','YYYY-MM-DD HH24:MI:SS'),0,'M_DistributionRun Orders',NULL) +; + +-- Jul 28, 2008 8:27:38 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Trl (AD_Language,AD_Process_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Process_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Process t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_ID=53150 AND EXISTS (SELECT * FROM AD_Process_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Process_ID!=t.AD_Process_ID) +; + +-- Jul 28, 2008 8:27:39 PM CDT +-- Distribution Run Orders +UPDATE AD_Reference SET Description='Date mm/dd/yyyy', EntityType='D', Help=NULL, IsActive='Y', Name='Date', ValidationType='D',Updated=TO_DATE('2008-07-28 20:27:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Reference_ID=15 +; + +-- Jul 28, 2008 8:27:39 PM CDT +-- Distribution Run Orders +UPDATE AD_Reference_Trl SET IsTranslated='N' WHERE AD_Reference_ID=15 +; + +-- Jul 28, 2008 8:27:41 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para (AD_Client_ID,AD_Element_ID,AD_Org_ID,AD_Process_ID,AD_Process_Para_ID,AD_Reference_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsCentrallyMaintained,IsMandatory,IsRange,Name,SeqNo,Updated,UpdatedBy) VALUES (0,269,0,53150,53218,15,'DatePromised',TO_DATE('2008-07-28 20:27:40','YYYY-MM-DD HH24:MI:SS'),0,'Date Promised','EE01',8,'Date Promised','Y','Y','N','N','Date Promised',25,TO_DATE('2008-07-28 20:27:40','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Jul 28, 2008 8:27:41 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=53218 AND EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Process_Para_ID!=t.AD_Process_Para_ID) +; + +-- Jul 28, 2008 8:27:41 PM CDT +-- Distribution Run Orders +UPDATE AD_Reference SET Description='CheckBox', EntityType='D', Help=NULL, IsActive='Y', Name='Yes-No', ValidationType='D',Updated=TO_DATE('2008-07-28 20:27:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Reference_ID=20 +; + +-- Jul 28, 2008 8:27:41 PM CDT +-- Distribution Run Orders +UPDATE AD_Reference_Trl SET IsTranslated='N' WHERE AD_Reference_ID=20 +; + +-- Jul 28, 2008 8:27:42 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para (AD_Client_ID,AD_Element_ID,AD_Org_ID,AD_Process_ID,AD_Process_Para_ID,AD_Reference_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsCentrallyMaintained,IsMandatory,IsRange,Name,SeqNo,Updated,UpdatedBy) VALUES (0,1000022,0,53150,53219,20,'CreateDO',TO_DATE('2008-07-28 20:27:41','YYYY-MM-DD HH24:MI:SS'),0,'Create Distribution Order','EE01',1,'Create Distribution Order','Y','Y','N','N','Create Distribution Order',50,TO_DATE('2008-07-28 20:27:41','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Jul 28, 2008 8:27:42 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=53219 AND EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Process_Para_ID!=t.AD_Process_Para_ID) +; + +-- Jul 28, 2008 8:27:43 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para (AD_Client_ID,AD_Element_ID,AD_Org_ID,AD_Process_ID,AD_Process_Para_ID,AD_Reference_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsCentrallyMaintained,IsMandatory,IsRange,Name,SeqNo,Updated,UpdatedBy) VALUES (0,2153,0,53150,53220,20,'IsTest',TO_DATE('2008-07-28 20:27:42','YYYY-MM-DD HH24:MI:SS'),0,'Test','EE01',1,'Execute in Test Mode','Y','Y','N','N','Test',40,TO_DATE('2008-07-28 20:27:42','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Jul 28, 2008 8:27:43 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=53220 AND EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Process_Para_ID!=t.AD_Process_Para_ID) +; + +-- Jul 28, 2008 8:27:43 PM CDT +-- Distribution Run Orders +UPDATE AD_Reference SET Description='Direct Table Access', EntityType='D', Help=NULL, IsActive='Y', Name='Table Direct', ValidationType='D',Updated=TO_DATE('2008-07-28 20:27:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Reference_ID=19 +; + +-- Jul 28, 2008 8:27:43 PM CDT +-- Distribution Run Orders +UPDATE AD_Reference_Trl SET IsTranslated='N' WHERE AD_Reference_ID=19 +; + +-- Jul 28, 2008 8:27:44 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para (AD_Client_ID,AD_Element_ID,AD_Org_ID,AD_Process_ID,AD_Process_Para_ID,AD_Reference_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsCentrallyMaintained,IsMandatory,IsRange,Name,SeqNo,Updated,UpdatedBy) VALUES (0,2408,0,53150,53221,19,'M_DistributionList_ID',TO_DATE('2008-07-28 20:27:43','YYYY-MM-DD HH24:MI:SS'),0,'Distribution List','EE01',10,'Distribution Lists allow to distribute products to a selected list of partners','Y','N','Y','N','Distribution List',30,TO_DATE('2008-07-28 20:27:43','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Jul 28, 2008 8:27:44 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=53221 AND EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Process_Para_ID!=t.AD_Process_Para_ID) +; + +-- Jul 28, 2008 8:27:45 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para (AD_Client_ID,AD_Element_ID,AD_Org_ID,AD_Process_ID,AD_Process_Para_ID,AD_Reference_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsCentrallyMaintained,IsMandatory,IsRange,Name,SeqNo,Updated,UpdatedBy) VALUES (0,459,0,53150,53222,19,'M_Warehouse_ID',TO_DATE('2008-07-28 20:27:44','YYYY-MM-DD HH24:MI:SS'),0,'Storage Warehouse and Service Point','EE01',10,'The Warehouse identifies a unique Warehouse where products are stored or Services are provided.','Y','Y','Y','N','Warehouse',20,TO_DATE('2008-07-28 20:27:44','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Jul 28, 2008 8:27:45 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=53222 AND EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Process_Para_ID!=t.AD_Process_Para_ID) +; + +-- Jul 28, 2008 8:27:46 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para (AD_Client_ID,AD_Element_ID,AD_Org_ID,AD_Process_ID,AD_Process_Para_ID,AD_Reference_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsCentrallyMaintained,IsMandatory,IsRange,Name,SeqNo,Updated,UpdatedBy) VALUES (0,113,0,53150,53223,19,'AD_Org_ID',TO_DATE('2008-07-28 20:27:45','YYYY-MM-DD HH24:MI:SS'),0,'Organization','EE01',10,'Organizational entity within client','Y','Y','Y','N','Organization',10,TO_DATE('2008-07-28 20:27:45','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Jul 28, 2008 8:27:46 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=53223 AND EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Process_Para_ID!=t.AD_Process_Para_ID) +; + +-- Jul 28, 2008 8:27:48 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Menu (AD_Client_ID,AD_Menu_ID,AD_Org_ID,AD_Process_ID,Action,Created,CreatedBy,Description,EntityType,IsActive,IsReadOnly,IsSOTrx,IsSummary,Name,Updated,UpdatedBy) VALUES (0,53184,0,53150,'P',TO_DATE('2008-07-28 20:27:47','YYYY-MM-DD HH24:MI:SS'),0,'Create Distribution Run Orders based on Distribution List and redistribute the quantity into Distribution Plan line items','EE01','Y','N','N','N','Distribution Run Orders',TO_DATE('2008-07-28 20:27:47','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Jul 28, 2008 8:27:48 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Menu_Trl (AD_Language,AD_Menu_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Menu_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Menu t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Menu_ID=53184 AND EXISTS (SELECT * FROM AD_Menu_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Menu_ID!=t.AD_Menu_ID) +; + +-- Jul 28, 2008 8:27:48 PM CDT +-- Distribution Run Orders +Insert INTO AD_TREENODEMM(AD_Client_ID, AD_Org_ID, CreatedBy, UpdatedBy, Parent_ID, SeqNo, AD_Tree_ID, Node_ID)VALUES(0, 0, 0, 0, 53066,7, 10, 53184) +; + diff --git a/migration/351a-trunk/postgresql/244_FR2030865DistributionRunDO.sql b/migration/351a-trunk/postgresql/244_FR2030865DistributionRunDO.sql new file mode 100644 index 0000000000..a3efc9c2e0 --- /dev/null +++ b/migration/351a-trunk/postgresql/244_FR2030865DistributionRunDO.sql @@ -0,0 +1,115 @@ +-- Jul 28, 2008 8:27:38 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process (AD_Client_ID,AD_Org_ID,AD_Process_ID,AccessLevel,Classname,Created,CreatedBy,Description,EntityType,Help,IsActive,IsBetaFunctionality,IsDirectPrint,IsReport,Name,ShowHelp,Statistic_Count,Statistic_Seconds,Updated,UpdatedBy,Value,WorkflowValue) VALUES (0,0,53150,'1','org.eevolution.process.DistributionRunOrders',TO_TIMESTAMP('2008-07-28 20:27:26','YYYY-MM-DD HH24:MI:SS'),0,'Create Distribution Run Orders based on Distribution List and redistribute the quantity into Distribution Plan line items','EE01','Please note that due to rounding, the total quantity of the order(s) is likely to be higher then the quantity entered.','Y','N','N','N','Distribution Run Orders','Y',0,0,TO_TIMESTAMP('2008-07-28 20:27:26','YYYY-MM-DD HH24:MI:SS'),0,'M_DistributionRun Orders',NULL) +; + +-- Jul 28, 2008 8:27:38 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Trl (AD_Language,AD_Process_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Process_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Process t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_ID=53150 AND EXISTS (SELECT * FROM AD_Process_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Process_ID!=t.AD_Process_ID) +; + +-- Jul 28, 2008 8:27:39 PM CDT +-- Distribution Run Orders +UPDATE AD_Reference SET Description='Date mm/dd/yyyy', EntityType='D', Help=NULL, IsActive='Y', Name='Date', ValidationType='D',Updated=TO_TIMESTAMP('2008-07-28 20:27:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Reference_ID=15 +; + +-- Jul 28, 2008 8:27:39 PM CDT +-- Distribution Run Orders +UPDATE AD_Reference_Trl SET IsTranslated='N' WHERE AD_Reference_ID=15 +; + +-- Jul 28, 2008 8:27:41 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para (AD_Client_ID,AD_Element_ID,AD_Org_ID,AD_Process_ID,AD_Process_Para_ID,AD_Reference_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsCentrallyMaintained,IsMandatory,IsRange,Name,SeqNo,Updated,UpdatedBy) VALUES (0,269,0,53150,53218,15,'DatePromised',TO_TIMESTAMP('2008-07-28 20:27:40','YYYY-MM-DD HH24:MI:SS'),0,'Date Promised','EE01',8,'Date Promised','Y','Y','N','N','Date Promised',25,TO_TIMESTAMP('2008-07-28 20:27:40','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Jul 28, 2008 8:27:41 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=53218 AND EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Process_Para_ID!=t.AD_Process_Para_ID) +; + +-- Jul 28, 2008 8:27:41 PM CDT +-- Distribution Run Orders +UPDATE AD_Reference SET Description='CheckBox', EntityType='D', Help=NULL, IsActive='Y', Name='Yes-No', ValidationType='D',Updated=TO_TIMESTAMP('2008-07-28 20:27:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Reference_ID=20 +; + +-- Jul 28, 2008 8:27:41 PM CDT +-- Distribution Run Orders +UPDATE AD_Reference_Trl SET IsTranslated='N' WHERE AD_Reference_ID=20 +; + +-- Jul 28, 2008 8:27:42 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para (AD_Client_ID,AD_Element_ID,AD_Org_ID,AD_Process_ID,AD_Process_Para_ID,AD_Reference_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsCentrallyMaintained,IsMandatory,IsRange,Name,SeqNo,Updated,UpdatedBy) VALUES (0,1000022,0,53150,53219,20,'CreateDO',TO_TIMESTAMP('2008-07-28 20:27:41','YYYY-MM-DD HH24:MI:SS'),0,'Create Distribution Order','EE01',1,'Create Distribution Order','Y','Y','N','N','Create Distribution Order',50,TO_TIMESTAMP('2008-07-28 20:27:41','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Jul 28, 2008 8:27:42 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=53219 AND EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Process_Para_ID!=t.AD_Process_Para_ID) +; + +-- Jul 28, 2008 8:27:43 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para (AD_Client_ID,AD_Element_ID,AD_Org_ID,AD_Process_ID,AD_Process_Para_ID,AD_Reference_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsCentrallyMaintained,IsMandatory,IsRange,Name,SeqNo,Updated,UpdatedBy) VALUES (0,2153,0,53150,53220,20,'IsTest',TO_TIMESTAMP('2008-07-28 20:27:42','YYYY-MM-DD HH24:MI:SS'),0,'Test','EE01',1,'Execute in Test Mode','Y','Y','N','N','Test',40,TO_TIMESTAMP('2008-07-28 20:27:42','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Jul 28, 2008 8:27:43 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=53220 AND EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Process_Para_ID!=t.AD_Process_Para_ID) +; + +-- Jul 28, 2008 8:27:43 PM CDT +-- Distribution Run Orders +UPDATE AD_Reference SET Description='Direct Table Access', EntityType='D', Help=NULL, IsActive='Y', Name='Table Direct', ValidationType='D',Updated=TO_TIMESTAMP('2008-07-28 20:27:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Reference_ID=19 +; + +-- Jul 28, 2008 8:27:43 PM CDT +-- Distribution Run Orders +UPDATE AD_Reference_Trl SET IsTranslated='N' WHERE AD_Reference_ID=19 +; + +-- Jul 28, 2008 8:27:44 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para (AD_Client_ID,AD_Element_ID,AD_Org_ID,AD_Process_ID,AD_Process_Para_ID,AD_Reference_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsCentrallyMaintained,IsMandatory,IsRange,Name,SeqNo,Updated,UpdatedBy) VALUES (0,2408,0,53150,53221,19,'M_DistributionList_ID',TO_TIMESTAMP('2008-07-28 20:27:43','YYYY-MM-DD HH24:MI:SS'),0,'Distribution List','EE01',10,'Distribution Lists allow to distribute products to a selected list of partners','Y','N','Y','N','Distribution List',30,TO_TIMESTAMP('2008-07-28 20:27:43','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Jul 28, 2008 8:27:44 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=53221 AND EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Process_Para_ID!=t.AD_Process_Para_ID) +; + +-- Jul 28, 2008 8:27:45 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para (AD_Client_ID,AD_Element_ID,AD_Org_ID,AD_Process_ID,AD_Process_Para_ID,AD_Reference_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsCentrallyMaintained,IsMandatory,IsRange,Name,SeqNo,Updated,UpdatedBy) VALUES (0,459,0,53150,53222,19,'M_Warehouse_ID',TO_TIMESTAMP('2008-07-28 20:27:44','YYYY-MM-DD HH24:MI:SS'),0,'Storage Warehouse and Service Point','EE01',10,'The Warehouse identifies a unique Warehouse where products are stored or Services are provided.','Y','Y','Y','N','Warehouse',20,TO_TIMESTAMP('2008-07-28 20:27:44','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Jul 28, 2008 8:27:45 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=53222 AND EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Process_Para_ID!=t.AD_Process_Para_ID) +; + +-- Jul 28, 2008 8:27:46 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para (AD_Client_ID,AD_Element_ID,AD_Org_ID,AD_Process_ID,AD_Process_Para_ID,AD_Reference_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsCentrallyMaintained,IsMandatory,IsRange,Name,SeqNo,Updated,UpdatedBy) VALUES (0,113,0,53150,53223,19,'AD_Org_ID',TO_TIMESTAMP('2008-07-28 20:27:45','YYYY-MM-DD HH24:MI:SS'),0,'Organization','EE01',10,'Organizational entity within client','Y','Y','Y','N','Organization',10,TO_TIMESTAMP('2008-07-28 20:27:45','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Jul 28, 2008 8:27:46 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=53223 AND EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Process_Para_ID!=t.AD_Process_Para_ID) +; + +-- Jul 28, 2008 8:27:48 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Menu (AD_Client_ID,AD_Menu_ID,AD_Org_ID,AD_Process_ID,"action",Created,CreatedBy,Description,EntityType,IsActive,IsReadOnly,IsSOTrx,IsSummary,Name,Updated,UpdatedBy) VALUES (0,53184,0,53150,'P',TO_TIMESTAMP('2008-07-28 20:27:47','YYYY-MM-DD HH24:MI:SS'),0,'Create Distribution Run Orders based on Distribution List and redistribute the quantity into Distribution Plan line items','EE01','Y','N','N','N','Distribution Run Orders',TO_TIMESTAMP('2008-07-28 20:27:47','YYYY-MM-DD HH24:MI:SS'),0) +; + +-- Jul 28, 2008 8:27:48 PM CDT +-- Distribution Run Orders +INSERT INTO AD_Menu_Trl (AD_Language,AD_Menu_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Menu_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Menu t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Menu_ID=53184 AND EXISTS (SELECT * FROM AD_Menu_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Menu_ID!=t.AD_Menu_ID) +; + +-- Jul 28, 2008 8:27:48 PM CDT +-- Distribution Run Orders +Insert INTO AD_TREENODEMM(AD_Client_ID, AD_Org_ID, CreatedBy, UpdatedBy, Parent_ID, SeqNo, AD_Tree_ID, Node_ID)VALUES(0, 0, 0, 0, 53066,7, 10, 53184) +; +