From 894d0c09a6de8bd288cc34df7a098bb4d0a39398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20V=C3=A9ron?= Date: Sun, 11 Oct 2015 01:25:19 +0200 Subject: [PATCH] Bug 4078 - Display active currency symbol on currency output and input Display active currency using international formatting patterns and active currency symbol withplugin price. To test: - Apply patch - Make sure that you have defined an active currency in Home > Administration > Currency & Exchange rates - Search for Syspref 'Currency Format' - Select a formatting pattern from the drop down list - Go to a page that uses Price formatting and verify that currency symbol displays wheere price formatting is applied (git grep '| $Price') (Amended patch to remove example opac-user.tt. To test with OPAC see bug 15374) Signed-off-by: Aleisha --- Koha/Number/Price.pm | 71 ++++++++++++++++---- .../en/modules/admin/preferences/acquisitions.pref | 19 +++++- 2 files changed, 73 insertions(+), 17 deletions(-) diff --git a/Koha/Number/Price.pm b/Koha/Number/Price.pm index 2d563f9..1ff3c8b 100644 --- a/Koha/Number/Price.pm +++ b/Koha/Number/Price.pm @@ -79,7 +79,7 @@ sub round { sub _format_params { my ( $self, $params ) = @_; - my $with_symbol = $params->{with_symbol} || 0; + my $with_symbol = $params->{with_symbol}; my $p_cs_precedes = $params->{p_cs_precedes}; my $p_sep_by_space = $params->{p_sep_by_space}; my $currency = GetCurrency(); @@ -92,21 +92,64 @@ sub _format_params { mon_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 => ',', - int_curr_symbol => $int_curr_symbol, - mon_thousands_sep => ' ', - thousands_sep => ' ', - mon_decimal_point => ',' - ); + if ( $currency_format =~ m/(_LEAD)/ ) { + $p_cs_precedes = 1 unless ( defined $p_cs_precedes ); + } + + if ( $currency_format =~ m/(_TRAIL)/ ) { + $p_cs_precedes = 0 unless ( defined $p_cs_precedes ); + } + + $format_params{'p_cs_precedes'} = $p_cs_precedes + if ( defined $p_cs_precedes ); + + if ( $currency_format =~ m/(_SPACE)/ ) { + $p_sep_by_space = 1 unless ( $p_sep_by_space ); + } + else { + $p_sep_by_space = 0 unless ( $p_sep_by_space ); + } + + $format_params{'p_sep_by_space'} = $p_sep_by_space; + + if ( $currency_format =~ m/(SYMB)/ ) { + $with_symbol = 1 unless ( defined $with_symbol ); + } + + $format_params{'int_curr_symbol'} = $currency->{symbol} + if ( $with_symbol ); + + # $format_params{'int_curr_symbol'} = "xxxxxxxxxxxxxx"; + + # TODO Add more currency formats (Syspref CurrencyFormat) + + # syspref FR: 360 000,00 + if ( $currency_format =~ m/(^FR)/ ) { + $format_params{'decimal_fill'} = '2'; + $format_params{'decimal_point'} = ','; + $format_params{'mon_decimal_point'} = ','; + $format_params{'thousands_sep'} = ' '; + $format_params{'mon_thousands_sep'} = ' '; + } + + # syspref US: 360,000.00 + if ( $currency_format =~ m/(^US)/ ) { + $format_params{'decimal_fill'} = '2'; + $format_params{'decimal_point'} = '.'; + $format_params{'mon_decimal_point'} = '.'; + $format_params{'thousands_sep'} = ','; + $format_params{'mon_thousands_sep'} = ','; + } + + # syspref CH: 360'000.00 + if ( $currency_format =~ m/(^CH)/ ) { + $format_params{'decimal_fill'} = '2'; + $format_params{'decimal_point'} = '.'; + $format_params{'mon_decimal_point'} = '.'; + $format_params{'thousands_sep'} = '\''; + $format_params{'mon_thousands_sep'} = '\''; } - $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; return \%format_params; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref index b52b5a9..fb4910e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref @@ -27,11 +27,24 @@ Acquisitions: branch: from staff member's library. all: in system, regardless of owner. - - - Display currencies using the following format + - "Display currencies using the following format (¤ = symbol of active currency as defined in Currency and exchange rates.)" - pref: CurrencyFormat choices: - US: 360,000.00 (US) - FR: 360 000,00 (FR) + US: "360,000.00" + US_SYMB_LEAD_SPACE: ¤ 360,000.00 + US_SYMB_LEAD: ¤360,000.00 + US_SYMB_TRAIL_SPACE: 360,000.00 ¤ + US_SYMB_TRAIL: 360,000.00¤ + FR: "360 000,00" + FR_SYMB_LEAD_SPACE: ¤ 360 000,00 + FR_SYMB_LEAD: ¤360 000,00 + FR_SYMB_TRAIL_SPACE: 360 000,00 ¤ + FR_SYMB_TRAIL: 360 000,00¤ + CH: "360'000.00" + CH_SYMB_LEAD_SPACE: ¤ 360'000.00 + CH_SYMB_LEAD: ¤360'000.00 + CH_SYMB_TRAIL_SPACE: 360'000.00 ¤ + CH_SYMB_TRAIL: 360'000.00¤ - - Tax rates are - pref: gist -- 1.7.10.4