Bug 18736: (follow-up) Fix missing rounding and bad formatting
[srvgit] / Koha / Number / Price.pm
index 64c9dfe..7b0b826 100644 (file)
@@ -19,7 +19,7 @@ package Koha::Number::Price;
 
 use Modern::Perl;
 
-use Number::Format qw( format_price );
+use Number::Format;
 use C4::Context;
 use Koha::Acquisition::Currencies;
 
@@ -84,6 +84,11 @@ 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);
 }