Bugzilla – Attachment 162700 Details for
Bug 36049
Rounding prices sometimes leads to incorrect results
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36049: Fix price rounding
Bug-36049-Fix-price-rounding.patch (text/plain), 1.70 KB, created by
Victor Grousset/tuxayo
on 2024-03-03 02:05:59 UTC
(
hide
)
Description:
Bug 36049: Fix price rounding
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2024-03-03 02:05:59 UTC
Size:
1.70 KB
patch
obsolete
>From dcbcdc6c83cd9dffa3cd501e09cb7d324259f3bf Mon Sep 17 00:00:00 2001 >From: Raphael Straub <raphael.straub@kit.edu> >Date: Thu, 8 Feb 2024 14:17:56 +0000 >Subject: [PATCH] Bug 36049: Fix price rounding > >This patch only fixes price rounding by using Math::BigFloat. > >To test: >1) Create an order line in acquisitions with vendor price 18.90 and a > discount of 5 %. >2) Verify that the total (tax excl.) in the order table on the basket > page is 17.95. >3) Apply the patch. >4) Reload the basket page. >5) Verify that the total (tax excl.) in the order table on the basket > page now is 17.96, which is correct. >6) Run: prove t/Number/Price.t > >Sponsored-by: Karlsruhe Institute of Technology (KIT) >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/Number/Price.pm | 8 ++------ > 1 file changed, 2 insertions(+), 6 deletions(-) > >diff --git a/Koha/Number/Price.pm b/Koha/Number/Price.pm >index e9a6aa748e..a0f847d495 100644 >--- a/Koha/Number/Price.pm >+++ b/Koha/Number/Price.pm >@@ -19,6 +19,7 @@ package Koha::Number::Price; > > use Modern::Perl; > >+use Math::BigFloat; > use Number::Format; > use C4::Context; > use Koha::Acquisition::Currencies; >@@ -83,12 +84,7 @@ sub round { > > my $format_params = $self->_format_params; > >- # To avoid the system to crash, we will not format big number >- # We divide per 100 because we want to keep the default DECIMAL_DIGITS (2) >- # error - round() overflow. Try smaller precision or use Math::BigFloat >- return $self->value if $self->value > Number::Format::MAX_INT/100; >- >- return Number::Format->new(%$format_params)->round($self->value); >+ return Number::Format->new(%$format_params)->round( Math::BigFloat->new( $self->value ) )->bdstr(); > } > > sub _format_params { >-- >2.44.0
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 36049
:
161918
|
161951
|
162699
|
162700
|
162701
|
171598
|
171599