MCost :
* more helper methods (use trxName) * removed some deprecated helper methods introduced by libero integration
This commit is contained in:
parent
a666180945
commit
12817efb90
|
@ -79,12 +79,13 @@ public class MCost extends X_M_Cost
|
||||||
} // get
|
} // get
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get MCosts for Cost Type and Cost Element Type
|
* Get MCosts for Cost Type and Cost Element Type.
|
||||||
|
* NOTE: It uses Product's trxName.
|
||||||
* @param product Product
|
* @param product Product
|
||||||
* @param as Account Schema
|
* @param as Account Schema
|
||||||
* @param AD_Org_ID Organization ID
|
* @param AD_Org_ID Organization ID
|
||||||
* @param M_AttributeSetInstance_ID Attribute Set Instance ID
|
* @param M_AttributeSetInstance_ID Attribute Set Instance ID
|
||||||
* @param CostElementType Cost Element Type
|
* @param CostElementType Cost Element Type or null
|
||||||
* @return Get MCost Collection for Cost Type and Cost Element Type
|
* @return Get MCost Collection for Cost Type and Cost Element Type
|
||||||
*/
|
*/
|
||||||
public static Collection<MCost> getByCostType (MProduct product, MAcctSchema as,
|
public static Collection<MCost> getByCostType (MProduct product, MAcctSchema as,
|
||||||
|
@ -110,9 +111,7 @@ public class MCost extends X_M_Cost
|
||||||
+ " AND "+COLUMNNAME_M_Product_ID+"=?"
|
+ " AND "+COLUMNNAME_M_Product_ID+"=?"
|
||||||
+ " AND "+COLUMNNAME_M_AttributeSetInstance_ID+"=?"
|
+ " AND "+COLUMNNAME_M_AttributeSetInstance_ID+"=?"
|
||||||
+ " AND "+COLUMNNAME_C_AcctSchema_ID+"=?"
|
+ " AND "+COLUMNNAME_C_AcctSchema_ID+"=?"
|
||||||
+ " AND "+COLUMNNAME_M_CostType_ID+"=?"
|
+ " AND "+COLUMNNAME_M_CostType_ID+"=?";
|
||||||
+ " AND EXISTS (SELECT 1 FROM M_CostElement ce "
|
|
||||||
+ " WHERE ce.M_CostElement_ID=M_Cost.M_CostElement_ID ";
|
|
||||||
|
|
||||||
List<Object> params = new ArrayList<Object>();
|
List<Object> params = new ArrayList<Object>();
|
||||||
params.add(product.getAD_Client_ID());
|
params.add(product.getAD_Client_ID());
|
||||||
|
@ -123,35 +122,19 @@ public class MCost extends X_M_Cost
|
||||||
params.add(M_CostType_ID);
|
params.add(M_CostType_ID);
|
||||||
if(CostElementType != null)
|
if(CostElementType != null)
|
||||||
{
|
{
|
||||||
whereClause += "AND ce.CostElementType=?";
|
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);
|
params.add(CostElementType);
|
||||||
}
|
}
|
||||||
|
|
||||||
whereClause += ")";
|
|
||||||
|
|
||||||
return new Query(product.getCtx(), MCost.Table_Name, whereClause, product.get_TrxName())
|
return new Query(product.getCtx(), MCost.Table_Name, whereClause, product.get_TrxName())
|
||||||
.setParameters(params)
|
.setParameters(params)
|
||||||
.setOnlyActiveRecords(true)
|
.setOnlyActiveRecords(true)
|
||||||
.list();
|
.list();
|
||||||
} // get
|
} // get
|
||||||
|
|
||||||
/**
|
|
||||||
* Get MCosts for for Cost Type
|
|
||||||
* @param product Product
|
|
||||||
* @param as Account Schema
|
|
||||||
* @param M_CostType_ID Cost Type
|
|
||||||
* @param AD_Org_ID Organization ID
|
|
||||||
* @param M_AttributeSetInstance_ID Attribute Set Instance ID
|
|
||||||
* @param CostElementType Cost Element Type
|
|
||||||
* @return Get MCost Collection for Cost Type
|
|
||||||
*/
|
|
||||||
public static Collection<MCost> getByCostType (MProduct product, MAcctSchema as, int M_CostType_ID ,
|
|
||||||
int AD_Org_ID, int M_AttributeSetInstance_ID)
|
|
||||||
{
|
|
||||||
return getByCostType (product, as, M_CostType_ID,
|
|
||||||
AD_Org_ID, M_AttributeSetInstance_ID, null);
|
|
||||||
} // get
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve/Calculate Current Cost Price
|
* Retrieve/Calculate Current Cost Price
|
||||||
* @param product product
|
* @param product product
|
||||||
|
@ -1395,20 +1378,22 @@ public class MCost extends X_M_Cost
|
||||||
} // get
|
} // get
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Costs
|
* Get Cost Record
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
* @param AD_Client_ID client
|
* @param AD_Client_ID client
|
||||||
* @param AD_Org_ID org
|
* @param AD_Org_ID org
|
||||||
* @param M_Product_ID product
|
* @param M_Product_ID product
|
||||||
* @param M_CostType_ID cost type
|
* @param M_CostType_ID cost type
|
||||||
* @param C_AcctSchema_ID as
|
* @param C_AcctSchema_ID as
|
||||||
* @param M_CostElement_ID cost element
|
* @param M_CostElement_ID cost element
|
||||||
* @param M_AttributeSetInstance_ID asi
|
* @param M_AttributeSetInstance_ID asi
|
||||||
* @return cost or null
|
* @param trxName transaction name
|
||||||
|
* @return cost or null
|
||||||
*/
|
*/
|
||||||
public static MCost get (Properties ctx, int AD_Client_ID, int AD_Org_ID, int M_Product_ID,
|
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,
|
int M_CostType_ID, int C_AcctSchema_ID, int M_CostElement_ID,
|
||||||
int M_AttributeSetInstance_ID)
|
int M_AttributeSetInstance_ID,
|
||||||
|
String trxName)
|
||||||
{
|
{
|
||||||
final String whereClause = "AD_Client_ID=? AND AD_Org_ID=?"
|
final String whereClause = "AD_Client_ID=? AND AD_Org_ID=?"
|
||||||
+" AND "+COLUMNNAME_M_Product_ID+"=?"
|
+" AND "+COLUMNNAME_M_Product_ID+"=?"
|
||||||
|
@ -1419,41 +1404,22 @@ public class MCost extends X_M_Cost
|
||||||
final Object[] params = new Object[]{AD_Client_ID, AD_Org_ID, M_Product_ID,
|
final Object[] params = new Object[]{AD_Client_ID, AD_Org_ID, M_Product_ID,
|
||||||
M_CostType_ID, C_AcctSchema_ID,
|
M_CostType_ID, C_AcctSchema_ID,
|
||||||
M_CostElement_ID, M_AttributeSetInstance_ID};
|
M_CostElement_ID, M_AttributeSetInstance_ID};
|
||||||
return new Query(ctx, Table_Name, whereClause, null)
|
return new Query(ctx, Table_Name, whereClause, trxName)
|
||||||
.setOnlyActiveRecords(true)
|
.setOnlyActiveRecords(true)
|
||||||
.setParameters(params)
|
.setParameters(params)
|
||||||
.first();
|
.firstOnly();
|
||||||
} // get
|
} // get
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
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,
|
||||||
* Get Costs Record for a Cost Type
|
int M_AttributeSetInstance_ID)
|
||||||
* @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)
|
|
||||||
{
|
{
|
||||||
|
return get(ctx, AD_Client_ID, AD_Org_ID,
|
||||||
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=?";
|
M_Product_ID, M_CostType_ID, C_AcctSchema_ID, M_CostElement_ID,
|
||||||
Query query = MTable.get(ctx, MCost.Table_ID)
|
M_AttributeSetInstance_ID,
|
||||||
.createQuery(whereClause, trxName);
|
null); // trxName
|
||||||
query.setParameters(new Object[]{AD_Client_ID, AD_Org_ID, M_Product_ID, C_AcctSchema_ID, M_CostType_ID, M_CostElement_ID});
|
|
||||||
query.setOnlyActiveRecords(true);
|
|
||||||
List<MCost> list = query.list();
|
|
||||||
for (MCost cost : list)
|
|
||||||
{
|
|
||||||
return cost;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static CLogger s_log = CLogger.getCLogger (MCost.class);
|
private static CLogger s_log = CLogger.getCLogger (MCost.class);
|
||||||
|
|
Loading…
Reference in New Issue