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

(-)a/Koha/Number/Price.pm (-6 / +2 lines)
Lines 86-96 sub _format_params { Link Here
86
    my ( $self, $params ) = @_;
86
    my ( $self, $params ) = @_;
87
    my $with_symbol = $params->{with_symbol} || 0;
87
    my $with_symbol = $params->{with_symbol} || 0;
88
    my $p_cs_precedes = $params->{p_cs_precedes};
88
    my $p_cs_precedes = $params->{p_cs_precedes};
89
    my $p_sep_by_space = $params->{p_sep_by_space};
90
    my $currency        = Koha::Acquisition::Currencies->get_active;
89
    my $currency        = Koha::Acquisition::Currencies->get_active;
91
    my $currency_format = C4::Context->preference("CurrencyFormat");
90
    my $currency_format = C4::Context->preference("CurrencyFormat");
92
91
93
    my $int_curr_symbol = q||;
92
    my $int_curr_symbol = $with_symbol ? $currency->symbol : q||;
94
    my %format_params = (
93
    my %format_params = (
95
        decimal_fill      => '2',
94
        decimal_fill      => '2',
96
        decimal_point     => '.',
95
        decimal_point     => '.',
Lines 101-108 sub _format_params { Link Here
101
    );
100
    );
102
101
103
    if ( $currency_format eq 'FR' ) {
102
    if ( $currency_format eq 'FR' ) {
104
        # FIXME This test should be done for all currencies
105
        $int_curr_symbol = $currency->symbol if $with_symbol;
106
        %format_params = (
103
        %format_params = (
107
            decimal_fill      => '2',
104
            decimal_fill      => '2',
108
            decimal_point     => ',',
105
            decimal_point     => ',',
Lines 114-120 sub _format_params { Link Here
114
    }
111
    }
115
112
116
    if ( $currency_format eq 'CH' ) {
113
    if ( $currency_format eq 'CH' ) {
117
        $int_curr_symbol = $currency->symbol if $with_symbol;
118
        %format_params = (
114
        %format_params = (
119
            decimal_fill      => '2',
115
            decimal_fill      => '2',
120
            decimal_point     => '.',
116
            decimal_point     => '.',
Lines 127-133 sub _format_params { Link Here
127
123
128
124
129
    $format_params{p_cs_precedes}  = $p_cs_precedes  if defined $p_cs_precedes;
125
    $format_params{p_cs_precedes}  = $p_cs_precedes  if defined $p_cs_precedes;
130
    $format_params{p_sep_by_space} = ( $int_curr_symbol and defined $p_sep_by_space ) ? $p_sep_by_space : 0;
126
    $format_params{p_sep_by_space} = $currency->p_sep_by_space ? 1 : 0;
131
127
132
    return \%format_params;
128
    return \%format_params;
133
}
129
}
(-)a/t/Number/Price.t (-5 / +3 lines)
Lines 35-49 is( Koha::Number::Price->new(1234567890)->format( $format ), Link Here
35
35
36
is( Koha::Number::Price->new(100000000000000)->format, '100000000000000', 'Numbers too big are not formatted');
36
is( Koha::Number::Price->new(100000000000000)->format, '100000000000000', 'Numbers too big are not formatted');
37
37
38
# FIXME This should be display symbol, but it was the case before the creation of this module
39
is( Koha::Number::Price->new->format( { %$format, with_symbol => 1 } ),
38
is( Koha::Number::Price->new->format( { %$format, with_symbol => 1 } ),
40
    '0.00', 'US: format 0 with symbol' );
39
    '$0.00', 'US: format 0 with symbol' );
41
is( Koha::Number::Price->new(3)->format( { %$format, with_symbol => 1 } ),
40
is( Koha::Number::Price->new(3)->format( { %$format, with_symbol => 1 } ),
42
    '3.00', 'US: format 3 with symbol' );
41
    '$3.00', 'US: format 3 with symbol' );
43
is(
42
is(
44
    Koha::Number::Price->new(1234567890)
43
    Koha::Number::Price->new(1234567890)
45
      ->format( { %$format, with_symbol => 1 }, 'US: format 1234567890 with symbol' ),
44
      ->format( { %$format, with_symbol => 1 }, 'US: format 1234567890 with symbol' ),
46
    '1,234,567,890.00'
45
    '$1,234,567,890.00'
47
);
46
);
48
47
49
is( Koha::Number::Price->new->unformat,    '0', 'US: unformat 0' );
48
is( Koha::Number::Price->new->unformat,    '0', 'US: unformat 0' );
50
- 

Return to bug 4078