dev/core#1959 Brick\Math\Exception\RoundingNecessaryException
authorChamil Wijesooriya <chamil@millertech.co.uk>
Thu, 20 Aug 2020 15:15:56 +0000 (16:15 +0100)
committerSeamus Lee <seamuslee001@gmail.com>
Fri, 21 Aug 2020 01:33:12 +0000 (11:33 +1000)
CRM/Utils/Money.php

index f5fb16244e43c2a67a4b736ffea615d7f35b2d12..9da7a98fe9abcc4bca197eba8e9ae21f9fc9c433 100644 (file)
@@ -139,8 +139,9 @@ class CRM_Utils_Money {
    */
   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();
     }
   }