IDEMPIERE-3047 Cost Adjustment propagate wrong cost amount to Organization accounting schema denoted in different currency
This commit is contained in:
parent
d0ef43655e
commit
f1acc8b633
|
@ -328,7 +328,7 @@ public class Doc_Inventory extends Doc
|
|||
{
|
||||
costDetailAmt = MConversionRate.convert (getCtx(),
|
||||
costDetailAmt, getC_Currency_ID(), as.getC_Currency_ID(),
|
||||
getDateAcct(), 0, getAD_Client_ID(), getAD_Org_ID());
|
||||
getDateAcct(), 0, getAD_Client_ID(), getAD_Org_ID(), true);
|
||||
}
|
||||
// Cost Detail
|
||||
if (!MCostDetail.createInventory(as, line.getAD_Org_ID(),
|
||||
|
|
|
@ -104,6 +104,27 @@ public class MConversionRate extends X_C_Conversion_Rate
|
|||
BigDecimal Amt, int CurFrom_ID, int CurTo_ID,
|
||||
Timestamp ConvDate, int C_ConversionType_ID,
|
||||
int AD_Client_ID, int AD_Org_ID)
|
||||
{
|
||||
return convert(ctx,Amt, CurFrom_ID,CurTo_ID, ConvDate, C_ConversionType_ID, AD_Client_ID, AD_Org_ID, false);
|
||||
} // convert
|
||||
|
||||
/**
|
||||
* Convert an amount
|
||||
* @param ctx context
|
||||
* @param CurFrom_ID The C_Currency_ID FROM
|
||||
* @param CurTo_ID The C_Currency_ID TO
|
||||
* @param ConvDate conversion date - if null - use current date
|
||||
* @param C_ConversionType_ID conversion rate type - if 0 - use Default
|
||||
* @param Amt amount to be converted
|
||||
* @param AD_Client_ID client
|
||||
* @param AD_Org_ID organization
|
||||
* @param use for costing
|
||||
* @return converted amount or null if no rate
|
||||
*/
|
||||
public static BigDecimal convert (Properties ctx,
|
||||
BigDecimal Amt, int CurFrom_ID, int CurTo_ID,
|
||||
Timestamp ConvDate, int C_ConversionType_ID,
|
||||
int AD_Client_ID, int AD_Org_ID, boolean isCosting)
|
||||
{
|
||||
if (Amt == null)
|
||||
throw new IllegalArgumentException("Required parameter missing - Amt");
|
||||
|
@ -118,13 +139,15 @@ public class MConversionRate extends X_C_Conversion_Rate
|
|||
|
||||
// Get Amount in Currency Precision
|
||||
retValue = retValue.multiply(Amt);
|
||||
int stdPrecision = MCurrency.getStdPrecision(ctx, CurTo_ID);
|
||||
int stdPrecision = isCosting ? MCurrency.getCostingPrecision(ctx, CurTo_ID): MCurrency.getStdPrecision(ctx, CurTo_ID);
|
||||
|
||||
if (retValue.scale() > stdPrecision)
|
||||
retValue = retValue.setScale(stdPrecision, BigDecimal.ROUND_HALF_UP);
|
||||
|
||||
return retValue;
|
||||
} // convert
|
||||
|
||||
|
||||
/**
|
||||
* Sets system spot conversion rate for a single day.
|
||||
* Checks for overlaps of spot rate is made. If an overlap is found, the overlapping
|
||||
|
|
|
@ -183,6 +183,17 @@ public class MCurrency extends X_C_Currency
|
|||
return msgreturn.toString();
|
||||
} // toString
|
||||
|
||||
/**
|
||||
* Get Costing Precision.
|
||||
* @param ctx Context
|
||||
* @param C_Currency_ID currency
|
||||
* @return Costing Precision
|
||||
*/
|
||||
public static int getCostingPrecision(Properties ctx, int C_Currency_ID) {
|
||||
MCurrency c = get(ctx, C_Currency_ID);
|
||||
return c.getCostingPrecision();
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
|
|
Loading…
Reference in New Issue