1003628 Incorrect Landed Cost Allocation calculation. Fixed issue with currency conversion and rounding.
This commit is contained in:
parent
f4ab371718
commit
bbdb201465
|
@ -852,16 +852,7 @@ public class Doc_Invoice extends Doc
|
||||||
if (X_M_Cost.COSTINGMETHOD_AverageInvoice.equals(costingMethod) || X_M_Cost.COSTINGMETHOD_AveragePO.equals(costingMethod))
|
if (X_M_Cost.COSTINGMETHOD_AverageInvoice.equals(costingMethod) || X_M_Cost.COSTINGMETHOD_AveragePO.equals(costingMethod))
|
||||||
{
|
{
|
||||||
|
|
||||||
// Convert to AcctCurrency
|
|
||||||
BigDecimal allocationAmt = lca.getAmt();
|
BigDecimal allocationAmt = lca.getAmt();
|
||||||
if (getC_Currency_ID() != as.getC_Currency_ID())
|
|
||||||
allocationAmt = MConversionRate.convert(getCtx(), allocationAmt,
|
|
||||||
getC_Currency_ID(), as.getC_Currency_ID(),
|
|
||||||
getDateAcct(), getC_ConversionType_ID(),
|
|
||||||
getAD_Client_ID(), getAD_Org_ID());
|
|
||||||
if (allocationAmt.scale() > as.getCostingPrecision())
|
|
||||||
allocationAmt = allocationAmt.setScale(as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP);
|
|
||||||
|
|
||||||
BigDecimal estimatedAmt = BigDecimal.ZERO;
|
BigDecimal estimatedAmt = BigDecimal.ZERO;
|
||||||
if (lca.getM_InOutLine_ID() > 0)
|
if (lca.getM_InOutLine_ID() > 0)
|
||||||
{
|
{
|
||||||
|
@ -921,11 +912,20 @@ public class Doc_Invoice extends Doc
|
||||||
boolean zeroQty = false;
|
boolean zeroQty = false;
|
||||||
try {
|
try {
|
||||||
savepoint = trx.setSavepoint(null);
|
savepoint = trx.setSavepoint(null);
|
||||||
|
BigDecimal costDetailAmt = costAdjustmentAmt;
|
||||||
|
//convert to accounting schema currency
|
||||||
|
if (getC_Currency_ID() != as.getC_Currency_ID())
|
||||||
|
costDetailAmt = MConversionRate.convert(getCtx(), costDetailAmt,
|
||||||
|
getC_Currency_ID(), as.getC_Currency_ID(),
|
||||||
|
getDateAcct(), getC_ConversionType_ID(),
|
||||||
|
getAD_Client_ID(), getAD_Org_ID());
|
||||||
|
if (costDetailAmt.scale() > as.getCostingPrecision())
|
||||||
|
costDetailAmt = costDetailAmt.setScale(as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP);
|
||||||
|
|
||||||
if (!MCostDetail.createInvoice(as, lca.getAD_Org_ID(),
|
if (!MCostDetail.createInvoice(as, lca.getAD_Org_ID(),
|
||||||
lca.getM_Product_ID(), lca.getM_AttributeSetInstance_ID(),
|
lca.getM_Product_ID(), lca.getM_AttributeSetInstance_ID(),
|
||||||
C_InvoiceLine_ID, lca.getM_CostElement_ID(),
|
C_InvoiceLine_ID, lca.getM_CostElement_ID(),
|
||||||
costAdjustmentAmt, lca.getQty(),
|
costDetailAmt, lca.getQty(),
|
||||||
desc, getTrxName())) {
|
desc, getTrxName())) {
|
||||||
throw new RuntimeException("Failed to create cost detail record.");
|
throw new RuntimeException("Failed to create cost detail record.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1096,9 +1096,9 @@ public class MInvoiceLine extends X_C_InvoiceLine
|
||||||
// end MZ
|
// end MZ
|
||||||
if (base.signum() != 0)
|
if (base.signum() != 0)
|
||||||
{
|
{
|
||||||
BigDecimal result = getLineNetAmt().multiply(base);
|
double result = getLineNetAmt().multiply(base).doubleValue();
|
||||||
result = result.divide(total, BigDecimal.ROUND_HALF_UP);
|
result /= total.doubleValue();
|
||||||
lca.setAmt(result.doubleValue(), getPrecision());
|
lca.setAmt(result, getPrecision());
|
||||||
}
|
}
|
||||||
if (!lca.save()){
|
if (!lca.save()){
|
||||||
msgreturn = new StringBuilder("Cannot save line Allocation = ").append(lca);
|
msgreturn = new StringBuilder("Cannot save line Allocation = ").append(lca);
|
||||||
|
@ -1221,9 +1221,9 @@ public class MInvoiceLine extends X_C_InvoiceLine
|
||||||
// end MZ
|
// end MZ
|
||||||
if (base.signum() != 0)
|
if (base.signum() != 0)
|
||||||
{
|
{
|
||||||
BigDecimal result = getLineNetAmt().multiply(base);
|
double result = getLineNetAmt().multiply(base).doubleValue();
|
||||||
result = result.divide(total, BigDecimal.ROUND_HALF_UP);
|
result /= total.doubleValue();
|
||||||
lca.setAmt(result.doubleValue(), getPrecision());
|
lca.setAmt(result, getPrecision());
|
||||||
}
|
}
|
||||||
if (!lca.save()){
|
if (!lca.save()){
|
||||||
msgreturn = new StringBuilder("Cannot save line Allocation = ").append(lca);
|
msgreturn = new StringBuilder("Cannot save line Allocation = ").append(lca);
|
||||||
|
|
Loading…
Reference in New Issue