View | Details | Raw Unified | Return to bug 15770
Collapse All | Expand All

(-)a/Koha/Number/Price.pm (+5 lines)
Lines 41-46 sub format { Link Here
41
41
42
    my $format_params = $self->_format_params( $params );
42
    my $format_params = $self->_format_params( $params );
43
43
44
    # To avoid the system to crash, we will not format big number
45
    # We divide per 100 because we want to keep the default DECIMAL_DIGITS (2)
46
    # error - round() overflow. Try smaller precision or use Math::BigFloat
47
    return $self->value if $self->value > Number::Format::MAX_INT/100;
48
44
    return Number::Format->new(%$format_params)->format_price($self->value);
49
    return Number::Format->new(%$format_params)->format_price($self->value);
45
}
50
}
46
51
(-)a/t/Number/Price.t (-2 / +3 lines)
Lines 1-6 Link Here
1
use Modern::Perl;
1
use Modern::Perl;
2
2
3
use Test::More tests => 30;
3
use Test::More tests => 31;
4
4
5
use Test::MockModule;
5
use Test::MockModule;
6
use t::lib::Mocks;
6
use t::lib::Mocks;
Lines 33-38 is( Koha::Number::Price->new(3)->format( $format ), '3.00', 'US: format 3' ); Link Here
33
is( Koha::Number::Price->new(1234567890)->format( $format ),
33
is( Koha::Number::Price->new(1234567890)->format( $format ),
34
    '1,234,567,890.00', 'US: format 1234567890' );
34
    '1,234,567,890.00', 'US: format 1234567890' );
35
35
36
is( Koha::Number::Price->new(100000000000000)->format, '100000000000000', 'Numbers too big are not formatted');
37
36
# FIXME This should be display symbol, but it was the case before the creation of this module
38
# FIXME This should be display symbol, but it was the case before the creation of this module
37
is( Koha::Number::Price->new->format( { %$format, with_symbol => 1 } ),
39
is( Koha::Number::Price->new->format( { %$format, with_symbol => 1 } ),
38
    '0.00', 'US: format 0 with symbol' );
40
    '0.00', 'US: format 0 with symbol' );
39
- 

Return to bug 15770