Skip to content

Commit

Permalink
Merge pull request #18206 from chamilwijesooriya/issue-1959
Browse files Browse the repository at this point in the history
dev/core#1959 Brick\Math\Exception\RoundingNecessaryException
  • Loading branch information
seamuslee001 authored Aug 21, 2020
2 parents 5fbba0e + f1b7204 commit 482e99a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions CRM/Utils/Money.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ public static function getCurrencyPrecision($currency = NULL) {
*/
public static function subtractCurrencies($leftOp, $rightOp, $currency) {
if (is_numeric($leftOp) && is_numeric($rightOp)) {
$money = Money::of($leftOp, $currency, new DefaultContext(), RoundingMode::CEILING);
return $money->minus($rightOp)->getAmount()->toFloat();
$leftMoney = Money::of($leftOp, $currency, new DefaultContext(), RoundingMode::CEILING);
$rightMoney = Money::of($rightOp, $currency, new DefaultContext(), RoundingMode::CEILING);
return $leftMoney->minus($rightMoney)->getAmount()->toFloat();
}
}

Expand Down

0 comments on commit 482e99a

Please sign in to comment.