[ 1983672 ] Manufacturing: Don't use PO set/get methods
http://sourceforge.net/tracker/?func=detail&atid=879332&aid=1983672&group_id=176962
This commit is contained in:
parent
ae96e05f85
commit
eb83609f3a
|
@ -123,6 +123,19 @@ public interface I_M_Cost
|
|||
*/
|
||||
public BigDecimal getCurrentCostPrice();
|
||||
|
||||
/** Column name CurrentCostPriceLL */
|
||||
public static final String COLUMNNAME_CurrentCostPriceLL = "CurrentCostPriceLL";
|
||||
|
||||
/** Set Current Cost Price Low Level.
|
||||
* The low level cost is using to accumulation the cost for low level in a bill of material or formula.
|
||||
*/
|
||||
public void setCurrentCostPriceLL (BigDecimal CurrentCostPriceLL);
|
||||
|
||||
/** Get Current Cost Price Low Level.
|
||||
* The low level cost is using to accumulation the cost for low level in a bill of material or formula.
|
||||
*/
|
||||
public BigDecimal getCurrentCostPriceLL();
|
||||
|
||||
/** Column name CurrentQty */
|
||||
public static final String COLUMNNAME_CurrentQty = "CurrentQty";
|
||||
|
||||
|
|
|
@ -1367,11 +1367,69 @@ public class MCost extends X_M_Cost
|
|||
}
|
||||
return retValue;
|
||||
} // get
|
||||
|
||||
/**
|
||||
* Get Costs Record for a Cost Type
|
||||
* @param ctx context
|
||||
* @param AD_Client_ID client
|
||||
* @param AD_Org_ID org
|
||||
* @param M_Product_ID product
|
||||
* @param M_CostType_ID cost type
|
||||
* @param C_AcctSchema_ID as
|
||||
* @param TrxName transaction name
|
||||
* @return array costs
|
||||
*/
|
||||
public static MCost[] getCosts(Properties ctx , int AD_Client_ID, int AD_Org_ID , int M_Product_ID, int M_CostType_ID ,int C_AcctSchema_ID ,String trxName)
|
||||
{
|
||||
|
||||
String whereClause = "AD_Client_ID = ? AND AD_Org_ID AND M_Product_ID=? AND C_Acctschema_ID = ? AND M_CostType_ID = ? ";
|
||||
Query query = MTable.get(ctx, MCost.Table_ID)
|
||||
.createQuery(whereClause, trxName);
|
||||
query.setParameters(new Object[]{AD_Client_ID});
|
||||
query.setParameters(new Object[]{AD_Org_ID});
|
||||
query.setParameters(new Object[]{M_Product_ID});
|
||||
query.setParameters(new Object[]{M_CostType_ID});
|
||||
query.setParameters(new Object[]{C_AcctSchema_ID});
|
||||
List<MCost> list = query.list();
|
||||
MCost[] retValue = new MCost[list.size()];
|
||||
list.toArray(retValue);
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Costs Record for a Cost Type
|
||||
* @param ctx context
|
||||
* @param AD_Client_ID client
|
||||
* @param AD_Org_ID org
|
||||
* @param M_Product_ID product
|
||||
* @param M_CostType_ID cost type
|
||||
* @param C_AcctSchema_ID as
|
||||
* @param TrxName transaction name
|
||||
* @return array costs
|
||||
*/
|
||||
public static MCost get(Properties ctx , int AD_Client_ID, int AD_Org_ID , int M_Product_ID, int M_CostType_ID ,int C_AcctSchema_ID , int M_CostElement_ID ,String trxName)
|
||||
{
|
||||
|
||||
String whereClause = "AD_Client_ID = ? AND AD_Org_ID AND M_Product_ID=? AND C_Acctschema_ID = ? AND M_CostType_ID = ? AND M_CostElement_ID=?";
|
||||
Query query = MTable.get(ctx, MCost.Table_ID)
|
||||
.createQuery(whereClause, trxName);
|
||||
query.setParameters(new Object[]{AD_Client_ID});
|
||||
query.setParameters(new Object[]{AD_Org_ID});
|
||||
query.setParameters(new Object[]{M_Product_ID});
|
||||
query.setParameters(new Object[]{M_CostType_ID});
|
||||
query.setParameters(new Object[]{M_CostElement_ID});
|
||||
List<MCost> list = query.list();
|
||||
for (MCost cost : list)
|
||||
{
|
||||
return cost;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/** Logger */
|
||||
private static CLogger s_log = CLogger.getCLogger (MCost.class);
|
||||
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Standard Constructor
|
||||
|
|
|
@ -240,6 +240,26 @@ public class MCostElement extends X_M_CostElement
|
|||
s_cache.put (key, retValue);
|
||||
return retValue;
|
||||
} // get
|
||||
|
||||
|
||||
/**
|
||||
* Get Costs Record for a Cost Type
|
||||
* @param ctx context
|
||||
* @param AD_Client_ID client
|
||||
* @param AD_Org_ID org
|
||||
* @return array costs
|
||||
**/
|
||||
public static MCostElement[] getElements (Properties ctx , int AD_Client_ID, int AD_Org_ID, String trxName)
|
||||
{
|
||||
String whereClause = "AD_Client_ID = ? AND AD_Org_ID AND M_Product_ID=? AND C_Acctschema_ID = ? AND M_CostType_ID = ? AND M_CostElement_ID=?";
|
||||
Query query = MTable.get(ctx, MCostElement.Table_ID).createQuery(whereClause, trxName);
|
||||
query.setParameters(new Object[]{AD_Client_ID});
|
||||
query.setParameters(new Object[]{AD_Org_ID});
|
||||
List<MCost> list = query.list();
|
||||
MCostElement[] retValue = new MCostElement[list.size()];
|
||||
list.toArray(retValue);
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/** Cache */
|
||||
private static CCache<Integer,MCostElement> s_cache = new CCache<Integer,MCostElement>("M_CostElement", 20);
|
||||
|
|
|
@ -217,6 +217,26 @@ public class X_M_Cost extends PO implements I_M_Cost, I_Persistent
|
|||
return bd;
|
||||
}
|
||||
|
||||
/** Set Current Cost Price Low Level.
|
||||
@param CurrentCostPriceLL
|
||||
The low level cost is using to accumulation the cost for low level in a bill of material or formula.
|
||||
*/
|
||||
public void setCurrentCostPriceLL (BigDecimal CurrentCostPriceLL)
|
||||
{
|
||||
set_ValueNoCheck (COLUMNNAME_CurrentCostPriceLL, CurrentCostPriceLL);
|
||||
}
|
||||
|
||||
/** Get Current Cost Price Low Level.
|
||||
@return The low level cost is using to accumulation the cost for low level in a bill of material or formula.
|
||||
*/
|
||||
public BigDecimal getCurrentCostPriceLL ()
|
||||
{
|
||||
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_CurrentCostPriceLL);
|
||||
if (bd == null)
|
||||
return Env.ZERO;
|
||||
return bd;
|
||||
}
|
||||
|
||||
/** Set Current Quantity.
|
||||
@param CurrentQty
|
||||
Current Quantity
|
||||
|
|
|
@ -1,190 +0,0 @@
|
|||
/******************************************************************************
|
||||
* 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.model;
|
||||
|
||||
import java.sql.*;
|
||||
import java.math.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
|
||||
import org.compiere.*;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Product Cost Model
|
||||
*
|
||||
* @author Victor Perez www.e-evolution.com
|
||||
* @version $Id: MCost.java,v 1.19 2005/12/20 04:21:02 vpj-cd Exp $
|
||||
*/
|
||||
public class MCost extends org.compiere.model.MCost
|
||||
{
|
||||
|
||||
|
||||
/** Logger */
|
||||
private static CLogger s_log = CLogger.getCLogger (MCost.class);
|
||||
static MCost[] m_lines = null;
|
||||
|
||||
/**************************************************************************
|
||||
* Standard Constructor
|
||||
* @param ctx context
|
||||
* @param ignored multi-key
|
||||
* @param trxName trx
|
||||
*/
|
||||
public MCost (Properties ctx, int ignored, String trxName)
|
||||
{
|
||||
super (ctx, ignored, trxName);
|
||||
} // MCost
|
||||
|
||||
/**
|
||||
* Load Constructor
|
||||
* @param ctx context
|
||||
* @param rs result set
|
||||
* @param trxName trx
|
||||
*/
|
||||
public MCost (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super (ctx, rs, trxName);
|
||||
} // MCost
|
||||
|
||||
/**
|
||||
* Parent Constructor
|
||||
* @param product Product
|
||||
* @param M_AttributeSetInstance_ID asi
|
||||
* @param as Acct Schema
|
||||
* @param AD_Org_ID org
|
||||
* @param M_CostElement_ID cost element
|
||||
*/
|
||||
public MCost (MProduct product, int M_AttributeSetInstance_ID,
|
||||
MAcctSchema as, int AD_Org_ID, int M_CostElement_ID)
|
||||
{
|
||||
super(product,M_AttributeSetInstance_ID, as, AD_Org_ID,M_CostElement_ID);
|
||||
} // MCost
|
||||
|
||||
/**
|
||||
* Get Element Cost
|
||||
* @return lines
|
||||
*/
|
||||
public static MCost[] getElements (int M_Product_ID, int C_AcctSchema_ID, int M_CostType_ID)
|
||||
{
|
||||
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
|
||||
String sql = "SELECT * FROM M_Cost WHERE AD_Client_ID = ? AND M_Product_ID=? AND C_Acctschema_ID = ? AND M_CostType_ID = ? ";
|
||||
PreparedStatement pstmt = null;
|
||||
try
|
||||
{
|
||||
int AD_Client_ID = Integer.parseInt(Env.getContext(Env.getCtx(), "#AD_Client_ID"));
|
||||
pstmt = DB.prepareStatement(sql);
|
||||
pstmt.setInt(1, AD_Client_ID);
|
||||
pstmt.setInt(2, M_Product_ID);
|
||||
pstmt.setInt(3, C_AcctSchema_ID);
|
||||
pstmt.setInt(4, M_CostType_ID);
|
||||
//pstmt.setInt(5, M_Warehouse_ID);
|
||||
//pstmt.setInt(6, S_Resource_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
list.add(new MCost(Env.getCtx(), rs,"M_Cost"));
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (SQLException ex)
|
||||
{
|
||||
//log.error("getLines", ex);
|
||||
s_log.fine("getLines" + ex);
|
||||
//System.out.println("getLines" + ex);
|
||||
}
|
||||
try
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException ex1)
|
||||
{
|
||||
}
|
||||
pstmt = null;
|
||||
//
|
||||
m_lines = new MCost[list.size()];
|
||||
list.toArray(m_lines);
|
||||
return m_lines;
|
||||
} // getMInOutLines
|
||||
|
||||
/**
|
||||
* Get Element Cost
|
||||
* @return lines
|
||||
*/
|
||||
public boolean getElement(int M_Product_ID, int C_AcctSchema_ID, int M_CostType_ID , int M_CostElement_ID)
|
||||
{
|
||||
//if (m_lines != null && !requery)
|
||||
//return m_lines;
|
||||
//ArrayList list = new ArrayList();
|
||||
MCost pc = null;
|
||||
String sql = "SELECT * FROM M_Cost WHERE AD_Client_ID =? AND M_Product_ID=? AND ( C_Acctschema_ID = ? AND M_Costtype_ID = ? AND M_CostElement_ID = ? )";
|
||||
PreparedStatement pstmt = null;
|
||||
try
|
||||
{
|
||||
int AD_Client_ID = Integer.parseInt(Env.getContext(Env.getCtx(), "#AD_Client_ID"));
|
||||
pstmt = DB.prepareStatement(sql);
|
||||
pstmt.setInt(1, AD_Client_ID);
|
||||
pstmt.setInt(2, M_Product_ID);
|
||||
pstmt.setInt(3, C_AcctSchema_ID);
|
||||
pstmt.setInt(4, M_CostType_ID);
|
||||
pstmt.setInt(5, M_CostElement_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//pc = new MMPCProductCosting(getCtx(), rs);
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (SQLException ex)
|
||||
{
|
||||
log.log(Level.SEVERE,"getLines", ex);
|
||||
}
|
||||
try
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException ex1)
|
||||
{
|
||||
}
|
||||
pstmt = null;
|
||||
return false;
|
||||
} // getMInOutLines
|
||||
|
||||
|
||||
/**
|
||||
* Before Save
|
||||
* @param newRecord new
|
||||
* @return true if can be saved
|
||||
*/
|
||||
protected boolean beforeSave (boolean newRecord)
|
||||
{
|
||||
boolean result = super.beforeSave(newRecord);
|
||||
//setCumulatedAmt(getCumulatedAmt().add(getCurrentCostPriceLL()));
|
||||
setCumulatedAmt(getCumulatedAmt().add(getCurrentCostPrice()));
|
||||
return result;
|
||||
}
|
||||
|
||||
} // MCost
|
|
@ -1,108 +0,0 @@
|
|||
/******************************************************************************
|
||||
* 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.model;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Cost Element Model
|
||||
* @author Victor Perez www.e-evolution.com
|
||||
* @version $Id: MCostElement.java,v 1.10 2005/11/28 03:35:24 vpj-cd Exp $
|
||||
*/
|
||||
public class MCostElement extends org.compiere.model.MCostElement
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Get active Material Cost Element for client
|
||||
* @param po parent
|
||||
* @return cost element array
|
||||
*/
|
||||
public static MCostElement[] getCostElements (int AD_Org_ID)
|
||||
{
|
||||
ArrayList<MCostElement> list = new ArrayList<MCostElement>();
|
||||
String sql = "SELECT * FROM M_CostElement "
|
||||
+ "WHERE "
|
||||
+ " IsActive='Y' AND AD_Org_ID=?";
|
||||
PreparedStatement pstmt = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
pstmt.setInt (1, AD_Org_ID);
|
||||
ResultSet rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
list.add(new MCostElement (Env.getCtx(), rs, null));
|
||||
rs.close ();
|
||||
pstmt.close ();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
s_log.log (Level.SEVERE, sql, e);
|
||||
}
|
||||
try
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close ();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
pstmt = null;
|
||||
}
|
||||
//
|
||||
MCostElement[] retValue = new MCostElement[list.size ()];
|
||||
list.toArray (retValue);
|
||||
return retValue;
|
||||
} // getMaterialCostElement
|
||||
|
||||
|
||||
|
||||
|
||||
/** Cache */
|
||||
private static CCache<Integer,MCostElement> s_cache = new CCache<Integer,MCostElement>("M_CostElement", 20);
|
||||
|
||||
/** Logger */
|
||||
private static CLogger s_log = CLogger.getCLogger (MCostElement.class);
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Standard Constructor
|
||||
* @param ctx context
|
||||
* @param M_CostElement_ID id
|
||||
* @param trxName trx
|
||||
*/
|
||||
public MCostElement (Properties ctx, int M_CostElement_ID, String trxName)
|
||||
{
|
||||
super (ctx, M_CostElement_ID, trxName);
|
||||
} // MCostElement
|
||||
|
||||
/**
|
||||
* Load Constructor
|
||||
* @param ctx context
|
||||
* @param rs result set
|
||||
* @param trxName trx
|
||||
*/
|
||||
public MCostElement (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super (ctx, rs, trxName);
|
||||
} // MCostElement
|
||||
|
||||
} // MCostElement
|
|
@ -1308,110 +1308,60 @@ public class MPPOrder extends X_PP_Order implements DocAction {
|
|||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Implicit Approval
|
||||
if (!isApproved())
|
||||
approveIt();
|
||||
log.info("completeIt - " + toString());
|
||||
StringBuffer info = new StringBuffer();
|
||||
|
||||
/*
|
||||
// Create SO Shipment - Force Shipment
|
||||
MInOut shipment = null;
|
||||
if (MDocType.DOCSUBTYPESO_OnCreditOrder.equals(DocSubTypeSO) // (W)illCall(I)nvoice
|
||||
|| MDocType.DOCSUBTYPESO_WarehouseOrder.equals(DocSubTypeSO) // (W)illCall(P)ickup
|
||||
|| MDocType.DOCSUBTYPESO_POSOrder.equals(DocSubTypeSO)) // (W)alkIn(R)eceipt
|
||||
{
|
||||
if (!DELIVERYRULE_Force.equals(getDeliveryRule()))
|
||||
setDeliveryRule(DELIVERYRULE_Force);
|
||||
//
|
||||
shipment = createShipment (dt);
|
||||
if (shipment == null)
|
||||
return DocAction.STATUS_Invalid;
|
||||
info.append("@M_InOut_ID@: ").append(shipment.getDocumentNo());
|
||||
String msg = shipment.getProcessMsg();
|
||||
if (msg != null && msg.length() > 0)
|
||||
info.append("(").append(msg).append(")");
|
||||
} // Shipment
|
||||
|
||||
|
||||
// Create SO Invoice - Always invoice complete Order
|
||||
if ( MDocType.DOCSUBTYPESO_POSOrder.equals(DocSubTypeSO)
|
||||
|| MDocType.DOCSUBTYPESO_OnCreditOrder.equals(DocSubTypeSO) )
|
||||
{
|
||||
MInvoice invoice = createInvoice (dt, shipment);
|
||||
if (invoice == null)
|
||||
return DocAction.STATUS_Invalid;
|
||||
info.append(" - @C_Invoice_ID@: ").append(invoice.getDocumentNo());
|
||||
String msg = invoice.getProcessMsg();
|
||||
if (msg != null && msg.length() > 0)
|
||||
info.append("(").append(msg).append(")");
|
||||
} // Invoice
|
||||
|
||||
// Counter Documents
|
||||
PP_Order_Plan counter = createCounterDoc();
|
||||
if (counter != null)
|
||||
info.append(" - @CounterDoc@: @Order@=").append(counter.getDocumentNo());
|
||||
*/
|
||||
//
|
||||
|
||||
|
||||
int C_AcctSchema_ID = Env.getContextAsInt(getCtx(),"$C_AcctSchema_ID");
|
||||
log.info("AcctSchema_ID" + C_AcctSchema_ID);
|
||||
MAcctSchema C_AcctSchema = new MAcctSchema(getCtx(),C_AcctSchema_ID,get_TrxName());
|
||||
log.info("Cost_Group_ID" + C_AcctSchema.getM_CostType_ID());
|
||||
|
||||
MCost[] cost = MCost.getElements(getM_Product_ID(),C_AcctSchema_ID,C_AcctSchema.getM_CostType_ID());
|
||||
log.info("MCost" + cost.toString());
|
||||
|
||||
if (cost != null)
|
||||
{
|
||||
log.info("Elements Total" + cost.length);
|
||||
|
||||
for (int j = 0 ; j < cost.length ; j ++)
|
||||
{
|
||||
MPPOrderCost PP_Order_Cost = new MPPOrderCost (getCtx(), 0,"PP_Order_Cost");
|
||||
PP_Order_Cost.setPP_Order_ID(getPP_Order_ID());
|
||||
|
||||
PP_Order_Cost.setC_AcctSchema_ID(cost[j].getC_AcctSchema_ID());
|
||||
PP_Order_Cost.setCumulatedAmt(cost[j].getCumulatedAmt());
|
||||
PP_Order_Cost.setCumulatedQty(cost[j].getCumulatedQty());
|
||||
PP_Order_Cost.setCurrentCostPriceLL(cost[j].getCurrentCostPrice());
|
||||
PP_Order_Cost.setCurrentCostPrice(cost[j].getCurrentCostPrice());
|
||||
PP_Order_Cost.setM_Product_ID(getM_Product_ID());
|
||||
PP_Order_Cost.setM_AttributeSetInstance_ID(cost[j].getM_AttributeSetInstance_ID());
|
||||
PP_Order_Cost.setM_CostElement_ID(cost[j].getM_CostElement_ID());
|
||||
PP_Order_Cost.save(get_TrxName());
|
||||
}
|
||||
MCost[] costs = MCost.getCosts(getCtx() , getAD_Client_ID(), getAD_Org_ID() , getM_Product_ID() , C_AcctSchema.getM_CostType_ID() , C_AcctSchema_ID , get_TrxName());
|
||||
if (costs != null)
|
||||
{
|
||||
for (MCost cost : costs)
|
||||
{
|
||||
MPPOrderCost PP_Order_Cost = new MPPOrderCost (getCtx(), 0, get_TrxName());
|
||||
PP_Order_Cost.setPP_Order_ID(getPP_Order_ID());
|
||||
PP_Order_Cost.setC_AcctSchema_ID(cost.getC_AcctSchema_ID());
|
||||
PP_Order_Cost.setCumulatedAmt(cost.getCumulatedAmt());
|
||||
PP_Order_Cost.setCumulatedQty(cost.getCumulatedQty());
|
||||
PP_Order_Cost.setCurrentCostPriceLL(cost.getCurrentCostPriceLL());
|
||||
PP_Order_Cost.setCurrentCostPrice(cost.getCurrentCostPrice());
|
||||
PP_Order_Cost.setM_Product_ID(getM_Product_ID());
|
||||
PP_Order_Cost.setM_AttributeSetInstance_ID(cost.getM_AttributeSetInstance_ID());
|
||||
PP_Order_Cost.setM_CostElement_ID(cost.getM_CostElement_ID());
|
||||
PP_Order_Cost.save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MPPOrderBOMLine[] lines = getLines(getPP_Order_ID());
|
||||
log.info("MPPOrderBOMLine[]" + lines.toString());
|
||||
|
||||
for (int i = 0 ; i < lines.length ; i++ )
|
||||
for ( MPPOrderBOMLine line : lines)
|
||||
{
|
||||
cost = MCost.getElements(lines[i].getM_Product_ID(), C_AcctSchema_ID , C_AcctSchema.getM_CostType_ID());
|
||||
log.info("Elements Total" + cost.length);
|
||||
if (cost != null)
|
||||
{
|
||||
|
||||
for (int j = 0 ; j < cost.length ; j ++)
|
||||
{
|
||||
MPPOrderCost PP_Order_Cost = new MPPOrderCost (getCtx(), 0,"PP_Order_Cost");
|
||||
PP_Order_Cost.setPP_Order_ID(getPP_Order_ID());
|
||||
PP_Order_Cost.setC_AcctSchema_ID(cost[j].getC_AcctSchema_ID());
|
||||
PP_Order_Cost.setCumulatedAmt(cost[j].getCumulatedAmt());
|
||||
PP_Order_Cost.setCumulatedQty(cost[j].getCumulatedQty());
|
||||
PP_Order_Cost.setCurrentCostPriceLL(cost[j].getCurrentCostPrice());
|
||||
PP_Order_Cost.setCurrentCostPrice(cost[j].getCurrentCostPrice());
|
||||
PP_Order_Cost.setM_Product_ID(getM_Product_ID());
|
||||
PP_Order_Cost.setM_AttributeSetInstance_ID(cost[j].getM_AttributeSetInstance_ID());
|
||||
PP_Order_Cost.setM_CostElement_ID(cost[j].getM_CostElement_ID());
|
||||
PP_Order_Cost.save(get_TrxName());
|
||||
}
|
||||
}
|
||||
costs = MCost.getCosts(getCtx() , getAD_Client_ID(), getAD_Org_ID() , line.getM_Product_ID() , C_AcctSchema.getM_CostType_ID() , C_AcctSchema_ID , get_TrxName());
|
||||
if (costs != null)
|
||||
{
|
||||
for (MCost cost : costs)
|
||||
{
|
||||
MPPOrderCost PP_Order_Cost = new MPPOrderCost (getCtx(), 0, get_TrxName());
|
||||
PP_Order_Cost.setPP_Order_ID(getPP_Order_ID());
|
||||
PP_Order_Cost.setC_AcctSchema_ID(cost.getC_AcctSchema_ID());
|
||||
PP_Order_Cost.setCumulatedAmt(cost.getCumulatedAmt());
|
||||
PP_Order_Cost.setCumulatedQty(cost.getCumulatedQty());
|
||||
PP_Order_Cost.setCurrentCostPriceLL(cost.getCurrentCostPriceLL());
|
||||
PP_Order_Cost.setCurrentCostPrice(cost.getCurrentCostPrice());
|
||||
PP_Order_Cost.setM_Product_ID(getM_Product_ID());
|
||||
PP_Order_Cost.setM_AttributeSetInstance_ID(cost.getM_AttributeSetInstance_ID());
|
||||
PP_Order_Cost.setM_CostElement_ID(cost.getM_CostElement_ID());
|
||||
PP_Order_Cost.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE);
|
||||
|
|
|
@ -63,7 +63,7 @@ public class MPPOrderCost extends X_PP_Order_Cost
|
|||
setCumulatedAmt(m_cost.getCumulatedAmt());
|
||||
setCumulatedQty(m_cost.getCumulatedQty());
|
||||
setCurrentCostPrice(m_cost.getCurrentCostPrice());
|
||||
setCurrentCostPriceLL(m_cost.getCurrentCostPrice());
|
||||
setCurrentCostPriceLL(m_cost.getCurrentCostPriceLL());
|
||||
setM_Product_ID(m_cost.getM_Product_ID());
|
||||
setM_CostElement_ID(m_cost.getM_CostElement_ID());
|
||||
setM_AttributeSetInstance_ID(m_cost.getM_AttributeSetInstance_ID());
|
||||
|
|
|
@ -128,20 +128,20 @@ public class CopyPriceToStandard extends SvrProcess
|
|||
else
|
||||
price = rs.getBigDecimal(3);
|
||||
|
||||
org.eevolution.model.MCost[] cost = org.eevolution.model.MCost.getElements( M_Product_ID , p_C_AcctSchema_ID , p_M_CostType_ID);
|
||||
if (cost != null)
|
||||
{
|
||||
for (int e = 0 ; e < cost.length ; e ++ )
|
||||
{
|
||||
MCostElement element = new MCostElement(getCtx(), p_M_CostElement_ID,null);
|
||||
if (element.getCostElementType().equals(element.COSTELEMENTTYPE_Material))
|
||||
{
|
||||
cost[0].setFutureCostPrice(price);
|
||||
cost[0].save(get_TrxName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
MCost[] costs = MCost.getCosts(getCtx() , getAD_Client_ID(), p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID , get_TrxName());
|
||||
if (costs != null)
|
||||
{
|
||||
for (MCost cost : costs)
|
||||
{
|
||||
MCostElement element = new MCostElement(getCtx(), p_M_CostElement_ID, get_TrxName());
|
||||
if (element.getCostElementType().equals(element.COSTELEMENTTYPE_Material))
|
||||
{
|
||||
cost.setFutureCostPrice(price);
|
||||
cost.save();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
|
|
|
@ -20,31 +20,28 @@ import java.util.logging.*;
|
|||
import java.math.*;
|
||||
import java.sql.*;
|
||||
|
||||
|
||||
|
||||
//import org.compiere.model.*;
|
||||
import org.compiere.util.*;
|
||||
import org.compiere.model.MCost;
|
||||
import org.compiere.model.MCostElement;
|
||||
import org.compiere.process.*;
|
||||
//import compiere.model.*;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Re-Open Order Process (from Closed to Completed)
|
||||
* Create Cost Element
|
||||
*
|
||||
* @author Victor P<EFBFBD>rez, e-Evolution, S.C.
|
||||
* @author victor.perez@e-evolution.com, e-Evolution, S.C.
|
||||
* @version $Id: CreateCostElement.java,v 1.1 2004/06/22 05:24:03 vpj-cd Exp $
|
||||
*/
|
||||
public class CreateCostElement extends SvrProcess
|
||||
{
|
||||
/** */
|
||||
private int p_AD_Org_ID = 0;
|
||||
private int p_AD_Org_ID = 0;
|
||||
private int p_C_AcctSchema_ID = 0;
|
||||
private int p_M_CostType_ID = 0;
|
||||
private int p_M_Product_ID = 0;
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Prepare - e.g., get Parameters.
|
||||
*/
|
||||
protected void prepare()
|
||||
|
@ -60,71 +57,63 @@ public class CreateCostElement extends SvrProcess
|
|||
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("C_AcctSchema_ID"))
|
||||
{
|
||||
}
|
||||
else if (name.equals("C_AcctSchema_ID"))
|
||||
{
|
||||
p_C_AcctSchema_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||
|
||||
}
|
||||
else if (name.equals("M_CostType_ID"))
|
||||
{
|
||||
}
|
||||
else if (name.equals("M_CostType_ID"))
|
||||
{
|
||||
p_M_CostType_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||
|
||||
}
|
||||
else if (name.equals("M_Product_ID"))
|
||||
{
|
||||
}
|
||||
else if (name.equals("M_Product_ID"))
|
||||
{
|
||||
p_M_Product_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
log.log(Level.SEVERE,"prepare - Unknown Parameter: " + name);
|
||||
}
|
||||
} // prepare
|
||||
|
||||
protected String doIt() throws Exception
|
||||
{
|
||||
|
||||
int AD_Client_ID = getAD_Client_ID();
|
||||
String sql = "SELECT p.M_Product_ID FROM M_Product p where AD_Client_ID=" +AD_Client_ID;
|
||||
if (p_M_Product_ID!=0)
|
||||
sql = sql + " and p.M_Product_ID =" +p_M_Product_ID;
|
||||
boolean existe = false;
|
||||
org.eevolution.model.MCostElement[] ce = org.eevolution.model.MCostElement.getCostElements(p_AD_Org_ID);
|
||||
|
||||
String sql = "SELECT M_Product_ID FROM M_Product p WHERE AD_Client_ID=" +getAD_Client_ID();
|
||||
if (p_M_Product_ID != 0)
|
||||
sql = sql + " and p.M_Product_ID =" +p_M_Product_ID;
|
||||
|
||||
MCostElement[] elements = MCostElement.getElements(getCtx(), getAD_Client_ID(), p_AD_Org_ID, get_TrxName());
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement (sql, get_TrxName());
|
||||
|
||||
int m_M_CostElement_ID = 0 ;
|
||||
|
||||
ResultSet rs = pstmt.executeQuery ();
|
||||
while (rs.next())
|
||||
{
|
||||
int m_M_Product_ID = rs.getInt(1);
|
||||
|
||||
for (int j = 0 ; j < ce.length ; j ++)
|
||||
{
|
||||
|
||||
m_M_CostElement_ID = ce[j].getM_CostElement_ID();
|
||||
org.eevolution.model.MCost pc = new org.eevolution.model.MCost(getCtx(),0,null);
|
||||
|
||||
if (!pc.getElement(m_M_Product_ID , p_C_AcctSchema_ID , p_M_CostType_ID , m_M_CostElement_ID ) ) // && !existe)
|
||||
{
|
||||
log.info("Create Cost Element for Product" +m_M_Product_ID);
|
||||
pc.setM_Product_ID(m_M_Product_ID);
|
||||
pc.setC_AcctSchema_ID(p_C_AcctSchema_ID);
|
||||
pc.setM_CostType_ID(p_M_CostType_ID);
|
||||
pc.setM_CostElement_ID(m_M_CostElement_ID);
|
||||
pc.save(get_TrxName());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
ResultSet rs = pstmt.executeQuery ();
|
||||
while (rs.next())
|
||||
{
|
||||
int m_M_Product_ID = rs.getInt(1);
|
||||
|
||||
MCost[] costs = MCost.getCosts(getCtx(), getAD_Client_ID(), p_AD_Org_ID, m_M_Product_ID, p_M_CostType_ID, p_C_AcctSchema_ID, get_TrxName());
|
||||
|
||||
if (costs == null)
|
||||
{
|
||||
for(MCostElement element : elements)
|
||||
{
|
||||
MCost cost = new MCost(getCtx(), 0 ,get_TrxName());
|
||||
cost.setM_Product_ID(m_M_Product_ID);
|
||||
cost.setAD_Org_ID(p_AD_Org_ID);
|
||||
cost.setC_AcctSchema_ID(p_C_AcctSchema_ID);
|
||||
cost.setM_CostType_ID(p_M_CostType_ID);
|
||||
cost.setM_CostElement_ID(element.getM_CostElement_ID());
|
||||
cost.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
|
@ -107,25 +107,22 @@ public class RollupBillOfMaterial extends SvrProcess
|
|||
protected String doIt() throws Exception
|
||||
{
|
||||
|
||||
int lowlevel = MPPMRP.getMaxLowLevel();
|
||||
int Level = lowlevel;
|
||||
//System.out.println("Low Level >>>>>>>>>>>>>>>>"+lowlevel);
|
||||
|
||||
// Calculate Rollup for all levels
|
||||
for (int index = lowlevel ; index >= 0 ; index--)
|
||||
{
|
||||
|
||||
StringBuffer sql = new StringBuffer ("SELECT p.M_Product_ID FROM M_Product p WHERE p.ProductType = '" + MProduct.PRODUCTTYPE_Item + "' AND AD_Client_ID = ? AND p.LowLevel = " + index);
|
||||
|
||||
if (p_M_Product_ID != 0)
|
||||
{
|
||||
sql.append(" AND p.M_Product_ID = " + p_M_Product_ID);
|
||||
}
|
||||
if (p_M_Product_Category_ID != 0)
|
||||
{
|
||||
sql.append(" AND p.M_Product_Category_ID = " + p_M_Product_Category_ID);
|
||||
}
|
||||
//System.out.print("sql :" + sql.toString());
|
||||
int lowlevel = MPPMRP.getMaxLowLevel();
|
||||
// Calculate Rollup for all levels
|
||||
for (int index = lowlevel ; index >= 0 ; index--)
|
||||
{
|
||||
|
||||
StringBuffer sql = new StringBuffer ("SELECT p.M_Product_ID FROM M_Product p WHERE p.ProductType = '" + MProduct.PRODUCTTYPE_Item + "' AND AD_Client_ID = ? AND p.LowLevel = " + index);
|
||||
|
||||
if (p_M_Product_ID != 0)
|
||||
{
|
||||
sql.append(" AND p.M_Product_ID = " + p_M_Product_ID);
|
||||
}
|
||||
if (p_M_Product_Category_ID != 0)
|
||||
{
|
||||
sql.append(" AND p.M_Product_Category_ID = " + p_M_Product_Category_ID);
|
||||
}
|
||||
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
try
|
||||
|
@ -145,75 +142,71 @@ public class RollupBillOfMaterial extends SvrProcess
|
|||
sqlw.append(" AND p.M_Warehouse_ID = " + p_M_Warehouse_ID);
|
||||
} */
|
||||
|
||||
//System.out.print("sql :" + sqlw.toString());
|
||||
log.info("Rollup Bill of Material sql :" + sql.toString());
|
||||
|
||||
PreparedStatement pstmtw = null;
|
||||
pstmtw = DB.prepareStatement (sqlw.toString());
|
||||
pstmtw = DB.prepareStatement (sqlw.toString(),get_TrxName());
|
||||
ResultSet rsw = pstmtw.executeQuery ();
|
||||
int M_Warehouse_ID=0;
|
||||
while (rsw.next())
|
||||
{
|
||||
M_Warehouse_ID = rsw.getInt(1);
|
||||
//System.out.println("WAREHOUSE ************" +M_Warehouse_ID);
|
||||
org.eevolution.model.MCost[] pc = org.eevolution.model.MCost.getElements( M_Product_ID , p_C_AcctSchema_ID , p_M_CostType_ID);
|
||||
//System.out.println("M_Product_ID" + M_Product_ID + "p_C_AcctSchema_ID" + p_C_AcctSchema_ID + "p_PP_Cost_Group_ID" + p_PP_Cost_Group_ID + "p_M_Warehouse_ID" + M_Warehouse_ID + "p_S_Resource_ID" + p_S_Resource_ID);
|
||||
MProduct product = new MProduct(getCtx(), M_Product_ID ,null);
|
||||
System.out.println("--------------------------Product" + product.getValue() + "-" + product.getName());
|
||||
M_Warehouse_ID = rsw.getInt(1);
|
||||
MCost[] costs = MCost.getCosts(getCtx(),getAD_Client_ID(), p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID , get_TrxName());
|
||||
MProduct product = new MProduct(getCtx(), M_Product_ID ,get_TrxName());
|
||||
log.info("Product Search Key-Name:" + product.getValue() + "-" + product.getName());
|
||||
|
||||
if (pc != null)
|
||||
if (costs != null)
|
||||
{
|
||||
for (int e = 0 ; e < pc.length ; e ++ )
|
||||
for (MCost cost : costs )
|
||||
{
|
||||
|
||||
MCostElement element = new MCostElement(getCtx(), pc[e].getM_CostElement_ID(),null);
|
||||
MCostElement element = new MCostElement(getCtx(), cost.getM_CostElement_ID(),get_TrxName());
|
||||
// check if element cost is of type Labor
|
||||
System.out.println("Exist Elemet " + e);
|
||||
//System.out.println("M_Product_ID" + M_Product_ID + "p_C_AcctSchema_ID" + p_C_AcctSchema_ID + "p_PP_Cost_Group_ID" + p_PP_Cost_Group_ID + "p_M_Warehouse_ID" + M_Warehouse_ID + "p_S_Resource_ID" + p_S_Resource_ID);
|
||||
//System.out.println("Material" +element.PP_ELEMENTTYPE_Material);
|
||||
log.info("Element Cost:"+ element.getName());
|
||||
if (element.getCostElementType().equals(element.COSTELEMENTTYPE_Material))
|
||||
{
|
||||
|
||||
BigDecimal Material = getCostLL(element.COSTELEMENTTYPE_Material , p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID);
|
||||
System.out.println("Material" + Material);
|
||||
if (pc[e].getCurrentCostPrice().compareTo(Env.ZERO)==0)
|
||||
BigDecimal Material = getCurrentCostPriceLL(element.COSTELEMENTTYPE_Material , p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID);
|
||||
log.info("Material Cost Low Level:" + Material);
|
||||
if (cost.getCurrentCostPrice().compareTo(Env.ZERO)==0)
|
||||
{
|
||||
//pc[e].setCostLLAmt(Material);
|
||||
pc[e].save(get_TrxName());
|
||||
cost.setCurrentCostPriceLL(Material);
|
||||
cost.save();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (element.getCostElementType().equals(element.COSTELEMENTTYPE_Resource))
|
||||
{
|
||||
BigDecimal Labor = getCostLL(element.COSTELEMENTTYPE_Resource, p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID);
|
||||
System.out.println("Labor" + Labor);
|
||||
//pc[e].setCostLLAmt(Labor);
|
||||
pc[e].save(get_TrxName());
|
||||
BigDecimal Labor = getCurrentCostPriceLL(element.COSTELEMENTTYPE_Resource, p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID);
|
||||
log.info("Labor Cost Low Level:" + Labor);
|
||||
cost.setCurrentCostPriceLL(Labor);
|
||||
cost.save();
|
||||
continue;
|
||||
}
|
||||
if (element.getCostElementType().equals(element.COSTELEMENTTYPE_BurdenMOverhead))
|
||||
{
|
||||
BigDecimal Burder = getCostLL(element.COSTELEMENTTYPE_BurdenMOverhead , p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID);
|
||||
System.out.println("Burder" + Burder);
|
||||
//pc[e].setCostLLAmt(Burder);
|
||||
pc[e].save(get_TrxName());
|
||||
continue;
|
||||
BigDecimal Burder = getCurrentCostPriceLL(element.COSTELEMENTTYPE_BurdenMOverhead , p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID);
|
||||
log.info("Burden Cost Low Level:" + Burder);
|
||||
cost.setCurrentCostPriceLL(Burder);
|
||||
cost.save();
|
||||
continue;
|
||||
}
|
||||
if (element.getCostElementType().equals(element.COSTELEMENTTYPE_Overhead))
|
||||
{
|
||||
BigDecimal Overhead = getCostLL(element.COSTELEMENTTYPE_Overhead , p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID);
|
||||
System.out.println("Overhead" + Overhead);
|
||||
//pc[e].setCostLLAmt(Overhead);
|
||||
pc[e].save(get_TrxName());
|
||||
BigDecimal Overhead = getCurrentCostPriceLL(element.COSTELEMENTTYPE_Overhead , p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID);
|
||||
log.info("Overhead Cost Low Level:" + Overhead);
|
||||
cost.setCurrentCostPriceLL(Overhead);
|
||||
cost.save();
|
||||
continue;
|
||||
}
|
||||
if (element.getCostElementType().equals(element.COSTELEMENTTYPE_OutsideProcessing))
|
||||
{
|
||||
BigDecimal Subcontract = getCostLL(element.COSTELEMENTTYPE_OutsideProcessing , p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID);
|
||||
System.out.println("Subcontract" + Subcontract);
|
||||
//pc[e].setCostLLAmt(Subcontract);
|
||||
pc[e].save(get_TrxName());
|
||||
continue;
|
||||
BigDecimal Subcontract = getCurrentCostPriceLL(element.COSTELEMENTTYPE_OutsideProcessing , p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID);
|
||||
log.info("Subcontract Cost Low Level:" + Subcontract);
|
||||
cost.setCurrentCostPriceLL(Subcontract);
|
||||
cost.save();
|
||||
continue;
|
||||
}
|
||||
/*if (element.getCostElementType().equals(element.PP_ELEMENTTYPE_Distribution))
|
||||
{
|
||||
|
@ -236,70 +229,63 @@ public class RollupBillOfMaterial extends SvrProcess
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//log.log(Level.SEVERE,"doIt - " + sql, e);
|
||||
return null;
|
||||
log.log(Level.SEVERE,"doIt - " + sql, e);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return "ok";
|
||||
}
|
||||
|
||||
|
||||
|
||||
private BigDecimal getCostLL(String CostElementType , int AD_Org_ID , int M_Product_ID , int M_CostType_ID , int C_AcctSchema_ID)
|
||||
/** get Current Cost Price Low Level
|
||||
* @param CostElementType Cost Element Type (Material,Labor,Overhead,Burden)
|
||||
* @param AD_Org_ID Organization
|
||||
* @param M_Product_ID Product
|
||||
* @param M_CostType_ID Cost Type
|
||||
* @param C_AcctSchema_ID Account Schema
|
||||
* @return CurrentCostPriceLL Sum Current Cost Price Level Low for this Cost Element Type
|
||||
*/
|
||||
private BigDecimal getCurrentCostPriceLL(String CostElementType , int AD_Org_ID , int M_Product_ID , int M_CostType_ID , int C_AcctSchema_ID)
|
||||
{
|
||||
System.out.println("getcostLL ***** " +CostElementType );
|
||||
BigDecimal cost = Env.ZERO;
|
||||
BigDecimal total = Env.ZERO;
|
||||
log.info("getCurrentCostPriceLL.ElementType"+CostElementType);
|
||||
BigDecimal totalcost = Env.ZERO;
|
||||
|
||||
MPPProductBOM bom = new MPPProductBOM(getCtx(), getPP_Product_BOM_ID(AD_Org_ID , M_Product_ID , CostElementType),null);
|
||||
MPPProductBOM bom = new MPPProductBOM(getCtx(), getPP_Product_BOM_ID(AD_Org_ID , M_Product_ID , CostElementType),get_TrxName());
|
||||
MPPProductBOMLine[] bomlines = bom.getLines();
|
||||
|
||||
System.out.println("no. de materias primas **********+ " +bomlines.length);
|
||||
for (int i = 0 ; i < bomlines.length ; i ++ )
|
||||
|
||||
for (MPPProductBOMLine bomline : bomlines)
|
||||
{
|
||||
MPPProductBOMLine bomline = bomlines[i];
|
||||
|
||||
//int m_S_Resource_ID = ;
|
||||
// get the rate for this resource
|
||||
org.eevolution.model.MCost[] pc = org.eevolution.model.MCost.getElements( M_Product_ID , p_C_AcctSchema_ID , p_M_CostType_ID);
|
||||
System.out.println("Producto de la linea ************* " +bomline.getM_Product_ID());
|
||||
|
||||
for (int e = 0 ; e < pc.length ; e ++ )
|
||||
MCost[] costs = MCost.getCosts(getCtx() , getAD_Client_ID(), p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID , get_TrxName());
|
||||
for (MCost cost : costs)
|
||||
{
|
||||
MCostElement element = new MCostElement(getCtx(), pc[e].getM_CostElement_ID(),null);
|
||||
MCostElement element = new MCostElement(getCtx(), cost.getM_CostElement_ID(), get_TrxName());
|
||||
// check if element cost is of type Labor
|
||||
if (element.getCostElementType().equals(CostElementType))
|
||||
{
|
||||
//cost = cost.add(pc[e].getCostTLAmt()).add(pc[e].getCostLLAmt());
|
||||
|
||||
BigDecimal QtyPercentage = bomline.getQtyBatch().divide(new BigDecimal(100),8,BigDecimal.ROUND_UP);
|
||||
BigDecimal QtyBOM = bomline.getQtyBOM();
|
||||
BigDecimal Scrap = bomline.getScrap();
|
||||
Scrap = Scrap.divide(new BigDecimal(100),4,BigDecimal.ROUND_UP); //convert to decimal
|
||||
BigDecimal QtyTotal = Env.ZERO;
|
||||
|
||||
//System.out.println("elementos pc[e] " +pc[e].getM_Product_ID() +" cost ll "+pc[e].getCostLLAmt() +" cost tl " +pc[e].getCostTLAmt());
|
||||
System.out.println("cost:" + cost + "QtyPercentage:" + QtyPercentage + "QtyBOM" + QtyBOM) ;
|
||||
|
||||
|
||||
if (bomline.isQtyPercentage())
|
||||
{
|
||||
QtyTotal = QtyPercentage.divide( Env.ONE.subtract(Scrap) , 4 ,BigDecimal.ROUND_HALF_UP );
|
||||
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
QtyTotal = QtyBOM.divide( Env.ONE.subtract(Scrap) , 4 ,BigDecimal.ROUND_HALF_UP );
|
||||
|
||||
}
|
||||
|
||||
totalcost = totalcost.add(cost.multiply(QtyTotal));
|
||||
|
||||
System.out.println("Cost Total" + totalcost);
|
||||
totalcost = totalcost.add(cost.getCurrentCostPriceLL().multiply(QtyTotal));
|
||||
log.info("Cost Element:"+element.getName() + "Total Cost Element:" + totalcost + "QtyPercentage:" + QtyPercentage + "QtyBOM" + QtyBOM) ;
|
||||
}
|
||||
cost =Env.ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,7 +294,7 @@ public class RollupBillOfMaterial extends SvrProcess
|
|||
MPPProductPlanning pps = MPPProductPlanning.getDemandSupplyResource(getCtx(), AD_Org_ID , M_Product_ID, get_TrxName());
|
||||
if (pps != null)
|
||||
{
|
||||
int Yield = pps.getYield();
|
||||
int Yield = pps.getYield();
|
||||
if(Yield != 0)
|
||||
{
|
||||
BigDecimal DecimalYield = new BigDecimal(Yield/100);
|
||||
|
|
|
@ -26,31 +26,22 @@ import org.compiere.model.*;
|
|||
import org.compiere.wf.*;
|
||||
import org.compiere.util.*;
|
||||
import org.compiere.process.*;
|
||||
//import compiere.model.*;
|
||||
import org.eevolution.model.MPPProductPlanning;
|
||||
import org.eevolution.model.QueryDB;
|
||||
|
||||
/**
|
||||
* Rollup of Rouning
|
||||
*
|
||||
* RollUp of Cost Manufacturing Workflow
|
||||
* This process calculate the Labor, Overhead, Burden Cost
|
||||
* @author Victor Perez, e-Evolution, S.C.
|
||||
* @version $Id: RollupWorkflow.java,v 1.1 2004/06/22 05:24:03 vpj-cd Exp $
|
||||
*/
|
||||
public class RollupWorkflow extends SvrProcess
|
||||
{
|
||||
/** */
|
||||
|
||||
|
||||
private int p_AD_Org_ID = 0;
|
||||
private int p_AD_Org_ID = 0;
|
||||
private int p_C_AcctSchema_ID = 0;
|
||||
//private int p_M_Warehouse_ID = 0;
|
||||
//private int p_S_Resource_ID = 0;
|
||||
private int p_M_Product_ID = 0;
|
||||
private int p_M_CostType_ID = 0;
|
||||
private int p_M_Product_Category_ID = 0;
|
||||
|
||||
//private String p_ElementType = "";
|
||||
|
||||
|
||||
private int p_M_CostType_ID = 0;
|
||||
|
||||
/**
|
||||
* Prepare - e.g., get Parameters.
|
||||
|
@ -58,9 +49,6 @@ public class RollupWorkflow extends SvrProcess
|
|||
protected void prepare()
|
||||
{
|
||||
ProcessInfoParameter[] para = getParameter();
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < para.length; i++)
|
||||
{
|
||||
String name = para[i].getParameterName();
|
||||
|
@ -68,60 +56,34 @@ public class RollupWorkflow extends SvrProcess
|
|||
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_Product_ID"))
|
||||
{
|
||||
{
|
||||
p_AD_Org_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||
}
|
||||
else if (name.equals("M_Product_ID"))
|
||||
{
|
||||
p_M_Product_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||
|
||||
}
|
||||
/*else if (name.equals("S_Resource_ID"))
|
||||
{
|
||||
p_S_Resource_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||
|
||||
}
|
||||
else if (name.equals("PP_Cost_Group_ID"))
|
||||
{
|
||||
|
||||
p_PP_Cost_Group_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||
}*/
|
||||
else if (name.equals("M_CostType_ID"))
|
||||
{
|
||||
|
||||
p_M_CostType_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||
}
|
||||
//else if (name.equals("ElementType"))
|
||||
//{
|
||||
// p_ElementType = (String)para[i].getParameter();
|
||||
//
|
||||
//}
|
||||
else if (name.equals("C_AcctSchema_ID"))
|
||||
{
|
||||
}
|
||||
else if (name.equals("M_CostType_ID"))
|
||||
{
|
||||
p_M_CostType_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||
}
|
||||
else if (name.equals("C_AcctSchema_ID"))
|
||||
{
|
||||
p_C_AcctSchema_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||
|
||||
}
|
||||
/*else if (name.equals("M_Produc_Category_ID"))
|
||||
{
|
||||
p_M_Product_Category_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||
|
||||
}*/
|
||||
else
|
||||
}
|
||||
else
|
||||
log.log(Level.SEVERE,"prepare - Unknown Parameter: " + name);
|
||||
}
|
||||
} // prepare
|
||||
|
||||
|
||||
/**
|
||||
* Perform process.
|
||||
* @return Message (text with variables)
|
||||
* @throws Exception if not successful
|
||||
*/
|
||||
protected String doIt() throws Exception
|
||||
{
|
||||
|
||||
int AD_Client_ID =getAD_Client_ID(); //Integer.parseInt(Env.getContext(Env.getCtx(), "#AD_Client_ID"));
|
||||
|
||||
StringBuffer sql = new StringBuffer ("SELECT p.M_Product_ID FROM M_Product p WHERE p.ProductType = '" + MProduct.PRODUCTTYPE_Item + "' AND");
|
||||
|
||||
|
@ -129,7 +91,7 @@ public class RollupWorkflow extends SvrProcess
|
|||
{
|
||||
sql.append(" p.M_Product_ID = " + p_M_Product_ID + " AND ");
|
||||
}
|
||||
sql.append(" p.AD_Client_ID = " + AD_Client_ID);
|
||||
sql.append(" p.AD_Client_ID = " + getAD_Client_ID());
|
||||
sql.append(" ORDER BY p.LowLevel");
|
||||
|
||||
|
||||
|
@ -137,37 +99,36 @@ public class RollupWorkflow extends SvrProcess
|
|||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
|
||||
ResultSet rs = pstmt.executeQuery ();
|
||||
while (rs.next())
|
||||
{
|
||||
//System.out.println("Exist Product" );
|
||||
int M_Product_ID = rs.getInt("M_Product_ID");
|
||||
org.eevolution.model.MCost[] pc = org.eevolution.model.MCost.getElements( M_Product_ID , p_C_AcctSchema_ID , p_M_CostType_ID);
|
||||
for (int e = 0 ; e < pc.length ; e ++ )
|
||||
{
|
||||
MCostElement element = new MCostElement(getCtx(), pc[e].getM_CostElement_ID(),null);
|
||||
// check if element cost is of type Labor
|
||||
if (element.getCostElementType().equals(element.COSTELEMENTTYPE_Resource))
|
||||
{
|
||||
BigDecimal Labor = getCost(element.COSTELEMENTTYPE_Resource , p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID);
|
||||
log.info("Labor : " + Labor);
|
||||
pc[e].setCurrentCostPrice(Labor);
|
||||
pc[e].save(get_TrxName());
|
||||
continue;
|
||||
}
|
||||
if (element.getCostElementType().equals(element.COSTELEMENTTYPE_BurdenMOverhead))
|
||||
{
|
||||
BigDecimal Burden = getCost(element.COSTELEMENTTYPE_BurdenMOverhead, p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID);
|
||||
log.info("Burden : " + Burden);
|
||||
pc[e].setCurrentCostPrice(Burden);
|
||||
pc[e].save(get_TrxName());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
ResultSet rs = pstmt.executeQuery ();
|
||||
while (rs.next())
|
||||
{
|
||||
int M_Product_ID = rs.getInt("M_Product_ID");
|
||||
MCost[] costs = MCost.getCosts(getCtx() , getAD_Client_ID(), p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID , get_TrxName());
|
||||
for (MCost cost : costs )
|
||||
{
|
||||
MCostElement element = new MCostElement(getCtx(), cost.getM_CostElement_ID(), get_TrxName());
|
||||
// check if element cost is of type Labor
|
||||
if (element.getCostElementType().equals(element.COSTELEMENTTYPE_Resource))
|
||||
{
|
||||
BigDecimal Labor = getCost(element.COSTELEMENTTYPE_Resource , p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID);
|
||||
log.info("Labor : " + Labor);
|
||||
cost.setCurrentCostPrice(Labor);
|
||||
cost.save();
|
||||
continue;
|
||||
}
|
||||
if (element.getCostElementType().equals(element.COSTELEMENTTYPE_BurdenMOverhead))
|
||||
{
|
||||
BigDecimal Burden = getCost(element.COSTELEMENTTYPE_BurdenMOverhead, p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID);
|
||||
log.info("Burden : " + Burden);
|
||||
cost.setCurrentCostPrice(Burden);
|
||||
cost.save(get_TrxName());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -181,41 +142,43 @@ public class RollupWorkflow extends SvrProcess
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Calculate Cost
|
||||
* @param CostElementType Cost Element Type (Labor and Overhead.)
|
||||
* @param AD_Org_ID Organization
|
||||
* @param M_Product_ID Product
|
||||
* @param M_CostType_ID Cost Type
|
||||
* @param C_AcctSchema_ID Account Schema
|
||||
* @return Cost for this Element
|
||||
* @throws Exception if not successful
|
||||
*/
|
||||
private BigDecimal getCost(String CostElementType , int AD_Org_ID , int M_Product_ID , int M_CostType_ID , int C_AcctSchema_ID)
|
||||
{
|
||||
|
||||
BigDecimal totalcost = Env.ZERO;
|
||||
{
|
||||
BigDecimal cost = Env.ZERO;
|
||||
|
||||
int AD_Workflow_ID = getAD_Workflow_ID(AD_Org_ID , M_Product_ID);
|
||||
//System.out.println(".................................................................................AD_Workflow_ID=" + AD_Workflow_ID);
|
||||
if (AD_Workflow_ID != 0)
|
||||
{
|
||||
//System.out.println("................................................................................Exist AD_Workflow_ID=" + AD_Workflow_ID);
|
||||
MWorkflow Workflow = new MWorkflow(getCtx(),AD_Workflow_ID,null);
|
||||
MWorkflow Workflow = new MWorkflow(getCtx(),AD_Workflow_ID,get_TrxName());
|
||||
MWFNode[] nodes = Workflow.getNodes(false,getAD_Client_ID());
|
||||
|
||||
for (int i = 0 ; i < nodes.length ; i ++ )
|
||||
{
|
||||
MWFNode node = (MWFNode) nodes[i];
|
||||
for (MWFNode node : nodes )
|
||||
{
|
||||
BigDecimal rate = getRate(CostElementType, node.getS_Resource_ID(), AD_Org_ID , C_AcctSchema_ID , M_CostType_ID);
|
||||
String sql = "SELECT CASE WHEN ow.DurationUnit = 's' THEN 1 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration ) WHEN ow.DurationUnit = 'm' THEN 60 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration) WHEN ow.DurationUnit = 'h' THEN 3600 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration) WHEN ow.DurationUnit = 'Y' THEN 31536000 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration) WHEN ow.DurationUnit = 'M' THEN 2592000 * ( (onode.SetupTime/ow.QtyBatchSize) + onode.Duration ) WHEN ow.DurationUnit = 'D' THEN 86400 * ((onode.SetupTime/ow.QtyBatchSize) + onode.Duration) END AS load FROM AD_WF_Node onode INNER JOIN AD_Workflow ow ON (ow.AD_Workflow_ID = onode.AD_Workflow_ID) WHERE onode.AD_WF_Node_ID = ? AND onode.AD_Client_ID = ?" ;
|
||||
int seconds = DB.getSQLValue(null,sql,node.getAD_WF_Node_ID(),node.getAD_Client_ID());
|
||||
int C_UOM_ID = DB.getSQLValue(null,"SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? " , node.getS_Resource_ID());
|
||||
MUOM oum = new MUOM(getCtx(),C_UOM_ID,null);
|
||||
int seconds = DB.getSQLValue(get_TrxName(),sql,node.getAD_WF_Node_ID(),node.getAD_Client_ID());
|
||||
int C_UOM_ID = DB.getSQLValue(get_TrxName(),"SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? " , node.getS_Resource_ID());
|
||||
MUOM oum = new MUOM(getCtx(),C_UOM_ID,get_TrxName());
|
||||
if (oum.isHour())
|
||||
{
|
||||
|
||||
BigDecimal time = new BigDecimal(seconds);
|
||||
cost = cost.add(time.multiply(rate).divide(new BigDecimal(3600),BigDecimal.ROUND_HALF_UP,6));
|
||||
System.out.println("Yes isHour" + seconds);
|
||||
//System.out.println("seconds/3600"+ seconds/3600);
|
||||
//System.out.println("time.multiply(rate)"+ time.multiply(rate));
|
||||
System.out.println("Cost" + cost);
|
||||
log.info("Yes isHour" + seconds);
|
||||
log.info("seconds/3600"+ seconds/3600);
|
||||
log.info("time.multiply(rate)"+ time.multiply(rate));
|
||||
log.info("Cost" + cost);
|
||||
}
|
||||
//totalcost.add(cost);
|
||||
//System.out.println("Node" + node.getName() + " PP_ElementType"+ PP_ElementType +" Duration=" + node.getDuration() + " rate:" + rate + " Cost:" + cost);
|
||||
log.info("Node" + node.getName() + " CostElementType"+ CostElementType +" Duration=" + node.getDuration() + " rate:" + rate + " Cost:" + cost);
|
||||
}
|
||||
return cost;
|
||||
|
@ -225,83 +188,93 @@ public class RollupWorkflow extends SvrProcess
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* get Rate for this Resource
|
||||
* @param CostElementType Cost Element Type (Labor and Overhead.)
|
||||
* @param S_Resource_ID Respurce
|
||||
* @param AD_Org_ID Organization
|
||||
* @param C_AcctSchema_ID Account Schema
|
||||
* @param M_CostType_ID Cost Type
|
||||
* @return Rate for Resource
|
||||
* @throws Exception if not successful
|
||||
*/
|
||||
private BigDecimal getRate(String CostElementType , int S_Resource_ID , int AD_Org_ID , int C_AcctSchema_ID ,int M_CostType_ID)
|
||||
{
|
||||
int M_Product_ID = getM_Product_ID(S_Resource_ID);
|
||||
|
||||
//System.out.println("...................................................................RATE:Org :" + AD_Org_ID + " S_ResourceProduct_ID:" + S_Resource_ID + " C_AcctSchema_ID :" + C_AcctSchema_ID+ " M_Warehouse_ID:" + M_Warehouse_ID + " PLAN:" + S_ResourcePlant_ID);
|
||||
|
||||
// get the rate for this resource public static MPPProductCosting[] getElements (int M_Product_ID, int C_AcctSchema_ID, int PP_Cost_Group_ID , int M_Warehouse_ID, int S_Resource_ID , boolean requery)
|
||||
|
||||
org.eevolution.model.MCost[] pc = org.eevolution.model.MCost.getElements(M_Product_ID , C_AcctSchema_ID , M_CostType_ID);
|
||||
if (pc != null)
|
||||
{
|
||||
//System.out.println("............." + "MPPProductCosting[].size=" + pc.length);
|
||||
BigDecimal rate = Env.ZERO;
|
||||
|
||||
for (int e = 0 ; e < pc.length ; e ++ )
|
||||
{
|
||||
MCostElement element = new MCostElement(getCtx(), pc[e].getM_CostElement_ID(),null);
|
||||
// check if element cost is of type Labor
|
||||
if (element.getCostElementType().equals(CostElementType))
|
||||
{
|
||||
rate = rate.add(pc[e].getCurrentCostPrice());
|
||||
log.info("Org" + AD_Org_ID + "S_Resource" + S_Resource_ID + "C_AcctSchema_ID " + C_AcctSchema_ID);
|
||||
//System.out.println("Org" + AD_Org_ID + "S_Resource" + S_Resource_ID + "C_AcctSchema_ID " + C_AcctSchema_ID+ "M_Warehouse_ID" + M_Warehouse_ID + "PLAN" + S_ResourcePlant_ID);
|
||||
log.info("Element rate=" + CostElementType + "rate:" + rate);
|
||||
//System.out.println("Element rate=" + PP_ElementType + "rate:" + rate);
|
||||
}
|
||||
}
|
||||
return rate;
|
||||
}
|
||||
return Env.ZERO;
|
||||
int M_Product_ID = getM_Product_ID(S_Resource_ID);
|
||||
MCost[] costs = MCost.getCosts(getCtx() , getAD_Client_ID(), p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID , get_TrxName());
|
||||
if (costs != null)
|
||||
{
|
||||
BigDecimal rate = Env.ZERO;
|
||||
|
||||
for (MCost cost: costs)
|
||||
{
|
||||
MCostElement element = new MCostElement(getCtx(), cost .getM_CostElement_ID(), get_TrxName());
|
||||
// check if element cost is of type Labor
|
||||
if (element.getCostElementType().equals(CostElementType))
|
||||
{
|
||||
rate = rate.add(cost.getCurrentCostPrice());
|
||||
log.info("Org" + AD_Org_ID + "S_Resource" + S_Resource_ID + "C_AcctSchema_ID " + C_AcctSchema_ID);
|
||||
log.info("Element rate=" + CostElementType + "rate:" + rate);
|
||||
}
|
||||
}
|
||||
return rate;
|
||||
}
|
||||
return Env.ZERO;
|
||||
}
|
||||
|
||||
/**
|
||||
* get Product of Resource
|
||||
* @param S_Resource_ID Resource
|
||||
* @return Product ID
|
||||
**/
|
||||
private int getM_Product_ID(int S_Resource_ID)
|
||||
{
|
||||
QueryDB query = new QueryDB("org.compiere.model.X_M_Product");
|
||||
String filter = "S_Resource_ID = " + S_Resource_ID;
|
||||
java.util.List results = query.execute(filter);
|
||||
Iterator select = results.iterator();
|
||||
while (select.hasNext())
|
||||
{
|
||||
X_M_Product M_Product = (X_M_Product) select.next();
|
||||
return M_Product.getM_Product_ID();
|
||||
}
|
||||
|
||||
return 0;
|
||||
String whereClause = "S_Resource_ID = ?";
|
||||
Query query = MTable.get(getCtx(), MProduct.Table_ID)
|
||||
.createQuery(whereClause, get_TrxName());
|
||||
query.setParameters(new Object[]{S_Resource_ID});
|
||||
|
||||
List<MProduct> products = query.list();
|
||||
for(MProduct product : products)
|
||||
{
|
||||
return product.getM_Product_ID();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get Manufacturing Workflow
|
||||
* @param AD_Org Organization ID
|
||||
* @param M_Product_ID Product ID
|
||||
* @return Workflow ID
|
||||
**/
|
||||
private int getAD_Workflow_ID(int AD_Org_ID , int M_Product_ID)
|
||||
{
|
||||
|
||||
MPPProductPlanning pp = MPPProductPlanning.get(getCtx(), AD_Org_ID , M_Product_ID, null);
|
||||
MPPProductPlanning pp = MPPProductPlanning.get(getCtx(), AD_Org_ID , M_Product_ID, get_TrxName());
|
||||
MProduct M_Product = new MProduct(getCtx(), M_Product_ID,null);
|
||||
|
||||
int AD_Workflow_ID = 0;
|
||||
|
||||
if ( pp == null )
|
||||
{
|
||||
//System.out.println("pp.getAD_Workflow_ID() ............. " + pp.getAD_Workflow_ID());
|
||||
QueryDB query = new QueryDB("org.compiere.model.X_AD_Workflow");
|
||||
String filter = "Name = '" + M_Product.getName() + "'";
|
||||
java.util.List results = query.execute(filter);
|
||||
Iterator select = results.iterator();
|
||||
while (select.hasNext())
|
||||
{
|
||||
X_AD_Workflow AD_Workflow = (X_AD_Workflow) select.next();
|
||||
return AD_Workflow.getAD_Workflow_ID();
|
||||
}
|
||||
String whereClause = "Name=?";
|
||||
Query query = MTable.get(getCtx(), MWorkflow.Table_ID)
|
||||
.createQuery(whereClause, get_TrxName());
|
||||
query.setParameters(new Object[]{M_Product.getName()});
|
||||
|
||||
List<MWorkflow> workflows = query.list();
|
||||
for (MWorkflow workflow : workflows)
|
||||
{
|
||||
return workflow.getAD_Workflow_ID();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AD_Workflow_ID = pp.getAD_Workflow_ID();
|
||||
}
|
||||
|
||||
//System.out.println("Product" + pp.getM_Product_ID() + "Workflow" + pp.getAD_Workflow_ID());
|
||||
|
||||
return AD_Workflow_ID;
|
||||
|
||||
}
|
||||
|
||||
} // OrderOpen
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
-- 04-jun-2008 23:12:26 CDT
|
||||
-- Fix Libero
|
||||
INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,Help,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,Updated,UpdatedBy) VALUES (0,56076,56266,0,701,TO_DATE('2008-06-04 23:11:54','YYYY-MM-DD HH24:MI:SS'),0,'The low level cost is using to accumulation the cost for low level in a bill of material or formula.',22,'EE01','The low level cost is using to accumulation the cost for low level in a bill of material or formula.','Y','Y','Y','N','N','N','N','N','Current Cost Price Low Level',TO_DATE('2008-06-04 23:11:54','YYYY-MM-DD HH24:MI:SS'),0)
|
||||
;
|
||||
|
||||
-- 04-jun-2008 23:12:26 CDT
|
||||
-- Fix Libero
|
||||
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_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_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=56266 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID)
|
||||
;
|
||||
|
||||
-- 04-jun-2008 23:14:30 CDT
|
||||
-- Fix Libero
|
||||
UPDATE AD_Field SET SeqNo=130,IsDisplayed='Y' WHERE AD_Field_ID=56266
|
||||
;
|
||||
|
||||
-- 04-jun-2008 23:14:30 CDT
|
||||
-- Fix Libero
|
||||
UPDATE AD_Field SET SeqNo=140,IsDisplayed='Y' WHERE AD_Field_ID=11352
|
||||
;
|
||||
|
||||
-- 04-jun-2008 23:14:30 CDT
|
||||
-- Fix Libero
|
||||
UPDATE AD_Field SET SeqNo=150,IsDisplayed='Y' WHERE AD_Field_ID=12318
|
||||
;
|
||||
|
||||
-- 04-jun-2008 23:14:30 CDT
|
||||
-- Fix Libero
|
||||
UPDATE AD_Field SET SeqNo=160,IsDisplayed='Y' WHERE AD_Field_ID=12175
|
||||
;
|
||||
|
||||
-- 04-jun-2008 23:14:30 CDT
|
||||
-- Fix Libero
|
||||
UPDATE AD_Field SET SeqNo=170,IsDisplayed='Y' WHERE AD_Field_ID=12176
|
||||
;
|
||||
|
||||
-- 04-jun-2008 23:14:30 CDT
|
||||
-- Fix Libero
|
||||
UPDATE AD_Field SET SeqNo=180,IsDisplayed='Y' WHERE AD_Field_ID=12319
|
||||
;
|
||||
|
||||
-- 04-jun-2008 23:14:39 CDT
|
||||
-- Fix Libero
|
||||
UPDATE AD_Field SET IsSameLine='Y',Updated=TO_DATE('2008-06-04 23:14:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=11352
|
||||
;
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
-- 04-jun-2008 23:12:26 CDT
|
||||
-- Fix Libero
|
||||
INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,Help,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,Updated,UpdatedBy) VALUES (0,56076,56266,0,701,TO_TIMESTAMP('2008-06-04 23:11:54','YYYY-MM-DD HH24:MI:SS'),0,'The low level cost is using to accumulation the cost for low level in a bill of material or formula.',22,'EE01','The low level cost is using to accumulation the cost for low level in a bill of material or formula.','Y','Y','Y','N','N','N','N','N','Current Cost Price Low Level',TO_TIMESTAMP('2008-06-04 23:11:54','YYYY-MM-DD HH24:MI:SS'),0)
|
||||
;
|
||||
|
||||
-- 04-jun-2008 23:12:26 CDT
|
||||
-- Fix Libero
|
||||
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_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_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=56266 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID)
|
||||
;
|
||||
|
||||
-- 04-jun-2008 23:14:30 CDT
|
||||
-- Fix Libero
|
||||
UPDATE AD_Field SET SeqNo=130,IsDisplayed='Y' WHERE AD_Field_ID=56266
|
||||
;
|
||||
|
||||
-- 04-jun-2008 23:14:30 CDT
|
||||
-- Fix Libero
|
||||
UPDATE AD_Field SET SeqNo=140,IsDisplayed='Y' WHERE AD_Field_ID=11352
|
||||
;
|
||||
|
||||
-- 04-jun-2008 23:14:30 CDT
|
||||
-- Fix Libero
|
||||
UPDATE AD_Field SET SeqNo=150,IsDisplayed='Y' WHERE AD_Field_ID=12318
|
||||
;
|
||||
|
||||
-- 04-jun-2008 23:14:30 CDT
|
||||
-- Fix Libero
|
||||
UPDATE AD_Field SET SeqNo=160,IsDisplayed='Y' WHERE AD_Field_ID=12175
|
||||
;
|
||||
|
||||
-- 04-jun-2008 23:14:30 CDT
|
||||
-- Fix Libero
|
||||
UPDATE AD_Field SET SeqNo=170,IsDisplayed='Y' WHERE AD_Field_ID=12176
|
||||
;
|
||||
|
||||
-- 04-jun-2008 23:14:30 CDT
|
||||
-- Fix Libero
|
||||
UPDATE AD_Field SET SeqNo=180,IsDisplayed='Y' WHERE AD_Field_ID=12319
|
||||
;
|
||||
|
||||
-- 04-jun-2008 23:14:39 CDT
|
||||
-- Fix Libero
|
||||
UPDATE AD_Field SET IsSameLine='Y',Updated=TO_TIMESTAMP('2008-06-04 23:14:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=11352
|
||||
;
|
||||
|
Loading…
Reference in New Issue