IDEMPIERE-190 Average Costing: make sure amt and qty argument for the setWeightedAverage method is of the same sight

This commit is contained in:
Heng Sin Low 2012-03-09 10:29:00 +08:00
parent f2f9da5add
commit 3ec5707657
1 changed files with 5 additions and 0 deletions

View File

@ -1453,6 +1453,11 @@ public class MCost extends X_M_Cost
*/
public void setWeightedAverage (BigDecimal amt, BigDecimal qty)
{
//amount must follow the sign of qty
if (amt.signum() != 0 && amt.signum() != qty.signum())
{
amt = amt.multiply(new BigDecimal(-1.00d));
}
BigDecimal oldSum = getCurrentCostPrice().multiply(getCurrentQty());
BigDecimal newSum = amt; // is total already
BigDecimal sumAmt = oldSum.add(newSum);