<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
+ | CiviCRM version 5 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2018 |
+--------------------------------------------------------------------+
return 2;
}
+ /**
+ * Subtract currencies using integers instead of floats, to preserve precision
+ *
+ * @return float
+ * Result of subtracting $rightOp from $leftOp to the precision of $currency
+ */
+ public static function subtractCurrencies($leftOp, $rightOp, $currency) {
+ if (is_numeric($leftOp) && is_numeric($rightOp)) {
+ $precision = pow(10, self::getCurrencyPrecision($currency));
+ return (($leftOp * $precision) - ($rightOp * $precision)) / $precision;
+ }
+ }
+
}