From e6602e1d880b05bb21d8db78d25ee72f7bf2288e Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 19 Jan 2018 17:56:06 +0000 Subject: [PATCH] Bug 18736: (follow-up) - Fix SQL and uncomment db update --- C4/Acquisition.pm | 2 +- C4/Budgets.pm | 2 +- installer/data/mysql/atomicupdate/bug18736_add_rounding_syspref.perl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 6b774e5..94e15a2 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2013,7 +2013,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 ("ROUND($round_string,2)"); } + if ( $rounding_pref eq "nearest_cent" ) { return ("CEIL($round_string*100)/100"); } else { return ("$round_string"); } } diff --git a/C4/Budgets.pm b/C4/Budgets.pm index 04a8f3a..6ff6007 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 "ROUND($to_round,2)"; } + if ($rounding_pref eq 'nearest_cent') { return "CEIL($to_round*100)/100"; } else { return "$to_round"; } } diff --git a/installer/data/mysql/atomicupdate/bug18736_add_rounding_syspref.perl b/installer/data/mysql/atomicupdate/bug18736_add_rounding_syspref.perl index 0f3c77f..717e56f 100644 --- a/installer/data/mysql/atomicupdate/bug18736_add_rounding_syspref.perl +++ b/installer/data/mysql/atomicupdate/bug18736_add_rounding_syspref.perl @@ -1,6 +1,6 @@ $DBversion = 'XXX'; # will be replaced by the RM if( CheckVersion( $DBversion ) ) { - # $dbh->do( "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OrderPriceRounding',NULL,'Local preference for rounding orders before calculations to ensure correct calculations','|nearest_cent','Choice')" ); + $dbh->do( "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OrderPriceRounding',NULL,'Local preference for rounding orders before calculations to ensure correct calculations','|nearest_cent','Choice')" ); SetVersion( $DBversion ); print "Upgrade to $DBversion done (Bug 18736 - Add syspref to control order rounding)\n"; -- 2.1.4