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

(-)a/C4/Acquisition.pm (-1 / +1 lines)
Lines 2013-2019 sub get_rounding_sql { Link Here
2013
    my ( $round_string ) = @_;
2013
    my ( $round_string ) = @_;
2014
    my $rounding_pref = C4::Context->preference('OrderPriceRounding') // q{};
2014
    my $rounding_pref = C4::Context->preference('OrderPriceRounding') // q{};
2015
    if ( $rounding_pref eq "nearest_cent"  ) {
2015
    if ( $rounding_pref eq "nearest_cent"  ) {
2016
        return "CAST($round_string*100 AS UNSIGNED)/100";
2016
        return "CAST($round_string*100 AS SIGNED)/100";
2017
    }
2017
    }
2018
    return $round_string;
2018
    return $round_string;
2019
}
2019
}
(-)a/t/Number/Price.t (-2 / +15 lines)
Lines 1-6 Link Here
1
use Modern::Perl;
1
use Modern::Perl;
2
2
3
use Test::More tests => 33;
3
use Test::More tests => 34;
4
4
5
use Test::MockModule;
5
use Test::MockModule;
6
use t::lib::Mocks;
6
use t::lib::Mocks;
Lines 134-136 is( Koha::Number::Price->new->unformat, '0', 'CHF: unformat 0' ); Link Here
134
is( Koha::Number::Price->new(3)->unformat, '3', 'CHF: unformat 3' );
134
is( Koha::Number::Price->new(3)->unformat, '3', 'CHF: unformat 3' );
135
is( Koha::Number::Price->new(1234567890)->unformat,
135
is( Koha::Number::Price->new(1234567890)->unformat,
136
    '1234567890', 'CHF: unformat 1234567890' );
136
    '1234567890', 'CHF: unformat 1234567890' );
137
- 
137
138
subtest 'Changes for format' => sub { # See also bug 18736
139
    plan tests => 3;
140
141
    t::lib::Mocks::mock_preference( 'CurrencyFormat', 'US' );
142
143
    is( Koha::Number::Price->new(-2.125)->format, "-2.13", "Check negative value" );
144
    my $large_number = 2**53; # MAX_INT
145
    my $price = Koha::Number::Price->new($large_number);
146
    is( $price->format, $price->value, 'Format '.$price->value.' returns value' );
147
    like( Koha::Number::Price->new( 2**53/100 )->format,
148
        qr/\d\.\d{2}$/, 'This price still seems to be formatted' );
149
        # Note that the comparison with MAX_INT is already subject to rounding
150
};

Return to bug 18736