@@ -, +, @@ for prices --- Koha/Number/Price.pm | 8 ++------ t/Number/Price.t | 7 +++---- 2 files changed, 5 insertions(+), 10 deletions(-) --- a/Koha/Number/Price.pm +++ a/Koha/Number/Price.pm @@ -86,11 +86,10 @@ sub _format_params { my ( $self, $params ) = @_; my $with_symbol = $params->{with_symbol} || 0; my $p_cs_precedes = $params->{p_cs_precedes}; - my $p_sep_by_space = $params->{p_sep_by_space}; my $currency = Koha::Acquisition::Currencies->get_active; my $currency_format = C4::Context->preference("CurrencyFormat"); - my $int_curr_symbol = q||; + my $int_curr_symbol = $with_symbol ? $currency->symbol : q||; my %format_params = ( decimal_fill => '2', decimal_point => '.', @@ -101,8 +100,6 @@ sub _format_params { ); if ( $currency_format eq 'FR' ) { - # FIXME This test should be done for all currencies - $int_curr_symbol = $currency->symbol if $with_symbol; %format_params = ( decimal_fill => '2', decimal_point => ',', @@ -114,7 +111,6 @@ sub _format_params { } if ( $currency_format eq 'CH' ) { - $int_curr_symbol = $currency->symbol if $with_symbol; %format_params = ( decimal_fill => '2', decimal_point => '.', @@ -127,7 +123,7 @@ sub _format_params { $format_params{p_cs_precedes} = $p_cs_precedes if defined $p_cs_precedes; - $format_params{p_sep_by_space} = ( $int_curr_symbol and defined $p_sep_by_space ) ? $p_sep_by_space : 0; + $format_params{p_sep_by_space} = $currency->p_sep_by_space ? 1 : 0; return \%format_params; } --- a/t/Number/Price.t +++ a/t/Number/Price.t @@ -35,15 +35,14 @@ is( Koha::Number::Price->new(1234567890)->format( $format ), is( Koha::Number::Price->new(100000000000000)->format, '100000000000000', 'Numbers too big are not formatted'); -# FIXME This should be display symbol, but it was the case before the creation of this module is( Koha::Number::Price->new->format( { %$format, with_symbol => 1 } ), - '0.00', 'US: format 0 with symbol' ); + '$0.00', 'US: format 0 with symbol' ); is( Koha::Number::Price->new(3)->format( { %$format, with_symbol => 1 } ), - '3.00', 'US: format 3 with symbol' ); + '$3.00', 'US: format 3 with symbol' ); is( Koha::Number::Price->new(1234567890) ->format( { %$format, with_symbol => 1 }, 'US: format 1234567890 with symbol' ), - '1,234,567,890.00' + '$1,234,567,890.00' ); is( Koha::Number::Price->new->unformat, '0', 'US: unformat 0' ); --