Fix rounding issue with GST and discounts (#1437)

This commit is contained in:
FrancescoUK
2017-12-09 17:08:05 +00:00
parent a25a87ec60
commit ad1e63fa3a

View File

@@ -505,7 +505,7 @@ class Sale_lib
$sales_total = $this->get_total();
$amount_due = bcsub($sales_total, $payment_total);
$precision = totals_decimals();
$rounded_due = bccomp(round($amount_due, $precision, PHP_ROUND_HALF_EVEN), 0, $precision);
$rounded_due = bccomp(round($amount_due, $precision, PHP_ROUND_HALF_UP), 0, $precision);
// take care of rounding error introduced by round tripping payment amount to the browser
return $rounded_due == 0 ? 0 : $amount_due;
}
@@ -1197,7 +1197,7 @@ class Sale_lib
$total = bcmul($quantity, $price);
$discount_fraction = bcdiv($discount_percentage, 100);
return bcmul($total, $discount_fraction);
return round(bcmul($total, $discount_fraction), totals_decimals(), PHP_ROUND_HALF_UP);
}
public function get_item_tax($quantity, $price, $discount_percentage, $tax_percentage)