Bugzilla – Attachment 74340 Details for
Bug 18736
Problems in order calculations (rounding errors)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18736: (follow-up) Use CAST instead of CEIL for appropriate rounding
Bug-18736-follow-up-Use-CAST-instead-of-CEIL-for-a.patch (text/plain), 2.24 KB, created by
Nick Clemens (kidclamp)
on 2018-04-17 14:42:58 UTC
(
hide
)
Description:
Bug 18736: (follow-up) Use CAST instead of CEIL for appropriate rounding
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2018-04-17 14:42:58 UTC
Size:
2.24 KB
patch
obsolete
>From bb5ca631f1cef55edcdc130e22f6b98fc4e36689 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >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 0f07633..d450728 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 ("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
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18736
:
64061
|
64065
|
70187
|
70188
|
70189
|
70768
|
71062
|
71063
|
71627
|
71628
|
71629
|
71630
|
71631
|
71632
|
74335
|
74336
|
74337
|
74338
|
74339
|
74340
|
74341
|
74342
|
74370
|
74371
|
74374
|
74397
|
74398
|
74422
|
74427
|
74438
|
76979
|
76980
|
76981
|
76982
|
76983
|
76984
|
76985
|
76986
|
76987
|
76988
|
76989
|
76990
|
76991
|
77614
|
77615
|
77616
|
77617
|
77618
|
78101
|
78120
|
78981
|
78982
|
78983
|
78984
|
78985
|
78986
|
78987
|
78988
|
79087
|
79088
|
79089
|
79090
|
79091
|
79092
|
79093
|
79094
|
79098
|
79099
|
79100
|
79101
|
79102
|
79103
|
79104
|
79105
|
79187
|
79223
|
79562
|
79563
|
82967
|
82968
|
82969
|
82970
|
82971
|
82972
|
82973
|
82974
|
82975
|
82976
|
82977
|
83212
|
83213
|
83214
|
83973
|
83974
|
83975
|
83976
|
83977
|
83978
|
83979
|
83980
|
83981
|
83982
|
83983
|
83984
|
83985
|
86646
|
86647
|
86648
|
86649
|
86650
|
86651
|
86652
|
86653
|
86654
|
86655
|
86656
|
86657
|
86658