Implementation the Manufacturing Cost Engine

https://sourceforge.net/tracker2/?func=detail&aid=2615593&group_id=176962&atid=934929
Remove dependences with Libero
This commit is contained in:
vpj-cd 2009-02-19 09:06:00 +00:00
parent d566a0f109
commit 1ea0cc1da5
1 changed files with 0 additions and 84 deletions

View File

@ -50,90 +50,6 @@ import org.compiere.util.Trx;
public class MCost extends X_M_Cost public class MCost extends X_M_Cost
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**
* Get the the Total Cost for Cost Type and Cost Element Type
* @param product Product
* @param as Account Schema
* @param AD_Org_ID Organization ID
* @param M_AttributeSetInstance_ID Attribute Set Instance ID
* @param M_CostType_ID cost type
* @param CostElementType Cost Element Type
* @param Qty Quantity
* @return Total Costs for Cost Type and Cost Element Type
*/
public static BigDecimal getCostByCostType (MProduct product, MAcctSchema as,
int AD_Org_ID, int M_AttributeSetInstance_ID,
int M_CostType_ID, String CostElementType,
BigDecimal Qty)
{
Collection<MCost> costs = getByCostType(product, as, M_CostType_ID, AD_Org_ID, M_AttributeSetInstance_ID,
CostElementType);
BigDecimal m_cost = Env.ZERO;
for(MCost cost : costs)
{
m_cost = cost.getCurrentCostPrice().add(cost.getCurrentCostPriceLL());
}
return m_cost.multiply(Qty);
} // get
/**
* Get MCosts for Cost Type and Cost Element Type.
* NOTE: It uses Product's trxName.
* @param product Product
* @param as Account Schema
* @param AD_Org_ID Organization ID
* @param M_AttributeSetInstance_ID Attribute Set Instance ID
* @param CostElementType Cost Element Type or null
* @return Get MCost Collection for Cost Type and Cost Element Type
*/
public static Collection<MCost> getByCostType (MProduct product, MAcctSchema as,
int M_CostType_ID, int AD_Org_ID, int M_AttributeSetInstance_ID, String CostElementType)
{
//Set the Costing Level
String CostingLevel = product.getCostingLevel(as);
if (MAcctSchema.COSTINGLEVEL_Client.equals(CostingLevel))
{
AD_Org_ID = 0;
M_AttributeSetInstance_ID = 0;
}
else if (MAcctSchema.COSTINGLEVEL_Organization.equals(CostingLevel))
{
M_AttributeSetInstance_ID = 0;
}
else if (MAcctSchema.COSTINGLEVEL_BatchLot.equals(CostingLevel))
{
AD_Org_ID = 0;
}
String whereClause = "AD_Client_ID=? AND AD_Org_ID=?"
+ " AND "+COLUMNNAME_M_Product_ID+"=?"
+ " AND "+COLUMNNAME_M_AttributeSetInstance_ID+"=?"
+ " AND "+COLUMNNAME_C_AcctSchema_ID+"=?"
+ " AND "+COLUMNNAME_M_CostType_ID+"=?";
List<Object> params = new ArrayList<Object>();
params.add(product.getAD_Client_ID());
params.add(AD_Org_ID);
params.add(product.getM_Product_ID());
params.add(M_AttributeSetInstance_ID);
params.add(as.getC_AcctSchema_ID());
params.add(M_CostType_ID);
if(CostElementType != null)
{
whereClause += " AND EXISTS (SELECT 1 FROM M_CostElement ce"
+" WHERE ce.M_CostElement_ID=M_Cost.M_CostElement_ID "
+" AND ce.CostElementType=?"
+")";
params.add(CostElementType);
}
return new Query(product.getCtx(), MCost.Table_Name, whereClause, product.get_TrxName())
.setParameters(params)
.setOnlyActiveRecords(true)
.list();
} // get
/** /**
* Retrieve/Calculate Current Cost Price * Retrieve/Calculate Current Cost Price