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 => '.',
);
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 => ',',
}
if ( $currency_format eq 'CH' ) {
- $int_curr_symbol = $currency->symbol if $with_symbol;
%format_params = (
decimal_fill => '2',
decimal_point => '.',
$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;
}
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' );