From 4be3c8f433ffb18b6c19822effbe3c52c668d912 Mon Sep 17 00:00:00 2001 From: jekkos Date: Sun, 17 Jul 2016 14:51:55 +0200 Subject: [PATCH] Revert "Check if payments cover total using currency decimals configuration" This reverts commit 9a7061e9c5b0611ed2450d1f12e20c37ab7ea6e5. --- application/controllers/Sales.php | 3 ++- application/helpers/locale_helper.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/application/controllers/Sales.php b/application/controllers/Sales.php index 40e0c9bd0..4b59bc7b2 100644 --- a/application/controllers/Sales.php +++ b/application/controllers/Sales.php @@ -533,7 +533,8 @@ class Sales extends Secure_Controller private function _payments_cover_total() { - return !bccomp($this->sale_lib->get_amount_due(), 0, $this->config->item('currency_decimals')); + // Changed the conditional to account for floating point rounding + return ($this->sale_lib->get_amount_due() <= 1e-6); } private function _load_customer_data($customer_id, &$data, $totals = FALSE) diff --git a/application/helpers/locale_helper.php b/application/helpers/locale_helper.php index 096dfec84..d39a4fb0a 100644 --- a/application/helpers/locale_helper.php +++ b/application/helpers/locale_helper.php @@ -24,7 +24,7 @@ function totals_decimals() return $config->item('currency_decimals') ? $config->item('currency_decimals') : 0; } -function to_currency($number) +function to_currency($number, $escape = FALSE) { return to_decimals($number, 'currency_decimals', \NumberFormatter::CURRENCY); }