FR [ 2797806 ] new method MPriceList.getDefault(ctx, isSO, Currency)
This commit is contained in:
parent
509489323a
commit
9355459b27
|
@ -99,6 +99,53 @@ public class MPriceList extends X_M_PriceList
|
||||||
return retValue;
|
return retValue;
|
||||||
} // getDefault
|
} // getDefault
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Default Price List for Client (cached) with given currency
|
||||||
|
* @param ctx context
|
||||||
|
* @param IsSOPriceList SO or PO
|
||||||
|
* @param ISOCurrency
|
||||||
|
* @return PriceList or null
|
||||||
|
*/
|
||||||
|
public static MPriceList getDefault(Properties ctx, boolean IsSOPriceList, String ISOCurrency)
|
||||||
|
{
|
||||||
|
int AD_Client_ID = Env.getAD_Client_ID(ctx);
|
||||||
|
MCurrency currency = MCurrency.get(ctx, ISOCurrency);
|
||||||
|
// If currency is null, return the default without looking at currency
|
||||||
|
if (currency==null) return(getDefault(ctx, IsSOPriceList));
|
||||||
|
|
||||||
|
int M_Currency_ID = currency.get_ID();
|
||||||
|
|
||||||
|
MPriceList retValue = null;
|
||||||
|
// Search for it in cache
|
||||||
|
Iterator<MPriceList> it = s_cache.values().iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
retValue = it.next();
|
||||||
|
if (retValue.isDefault()
|
||||||
|
&& retValue.getAD_Client_ID() == AD_Client_ID
|
||||||
|
&& retValue.isSOPriceList() == IsSOPriceList
|
||||||
|
&& retValue.getC_Currency_ID()==M_Currency_ID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return retValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get from DB
|
||||||
|
final String whereClause = "AD_Client_ID=? AND IsDefault=? AND IsSOPriceList=? AND C_Currency_ID=?";
|
||||||
|
retValue = new Query(ctx, Table_Name, whereClause, null)
|
||||||
|
.setParameters(new Object[]{AD_Client_ID, "Y", IsSOPriceList ? "Y" : "N", Integer.valueOf(M_Currency_ID)})
|
||||||
|
.setOrderBy("M_PriceList_ID")
|
||||||
|
.first();
|
||||||
|
|
||||||
|
// Return value
|
||||||
|
if (retValue != null)
|
||||||
|
{
|
||||||
|
s_cache.put(retValue.get_ID(), retValue);
|
||||||
|
}
|
||||||
|
return retValue;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Standard Currency Precision
|
* Get Standard Currency Precision
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
|
|
Loading…
Reference in New Issue