From 456b48285caa966c1cdde43c38e42addc7dcbda8 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 30 Jan 2018 15:41:15 +0000 Subject: [PATCH] Bug 18736 (follow-up) Use CAST instead of CEIL for appropriate rounding --- C4/Acquisition.pm | 2 +- C4/Budgets.pm | 2 +- t/db_dependent/Budgets.t | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index cd35764..de67ba0 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2011,7 +2011,7 @@ returns the correct SQL routine based on OrderPriceRounding system preference. sub _get_rounding_sql { my $round_string = @_; my $rounding_pref = C4::Context->preference('OrderPriceRounding'); - if ( $rounding_pref eq "nearest_cent" ) { return ("CEIL($round_string*100)/100"); } + if ( $rounding_pref eq "nearest_cent" ) { return ("CAST($round_string*100 AS INTEGER)/100"); } else { return ("$round_string"); } } diff --git a/C4/Budgets.pm b/C4/Budgets.pm index 6ff6007..87b6968 100644 --- a/C4/Budgets.pm +++ b/C4/Budgets.pm @@ -1292,7 +1292,7 @@ returns the correct SQL routine based on OrderPriceRounding system preference. sub _get_rounding_sql { my $to_round = shift; my $rounding_pref = C4::Context->preference('OrderPriceRounding'); - if ($rounding_pref eq 'nearest_cent') { return "CEIL($to_round*100)/100"; } + if ($rounding_pref eq 'nearest_cent') { return "CAST($to_round*100 AS INTEGER)/100"; } else { return "$to_round"; } } diff --git a/t/db_dependent/Budgets.t b/t/db_dependent/Budgets.t index 348431a..6b9e285 100755 --- a/t/db_dependent/Budgets.t +++ b/t/db_dependent/Budgets.t @@ -852,7 +852,7 @@ subtest 'GetBudgetSpent GetBudgetOrdered tests' => sub { t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); $spent_ordered = GetBudgetOrdered( $spent_order->{budget_id} ); - is($spent_ordered,'78.80',"We expect the ordered amount to be equal to the estimated price rounded times quantity"); + is($spent_ordered,'78.8000',"We expect the ordered amount to be equal to the estimated price rounded times quantity"); #Okay, now we can receive the order, giving the price as the user would -- 2.1.4