Bug 36049: Fix price rounding
This patch only fixes price rounding by using Math::BigFloat. To test: 0) Enable syspref OrderPriceRounding 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> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> (cherry picked from commit56091d9660) Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> (cherry picked from commita322d170ed) Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
e9eb0e9f32
commit
af0d3b1352
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue