From beaff2003dc2eb39cd08d071732c83db394bfcfc Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 18 Dec 2019 12:00:14 +0100 Subject: [PATCH] Bug 20352: Add the ability to chose the position of the currency This patch mimicks what has been done for p_sep_by_space to add a space separation between the symbol and the value. Here we are adding p_cs_precedes to display the symbol before or after the value. Note that so far the symbol is only displayed in one place at the OPAC (opac-main) Test plan: - Create a manual invoice for a patron - Edit the active currency, select 'Before' (should be the default here) - Use the charged patron to login at the OPAC => On the mainpage you should see the charges displayed, with the symbol before the value - Edit the active currency, select 'After' => The symbol is now positionned after the value QA note: From https://www.gnu.org/software/libc/manual/html_node/Currency-Symbol.html p_cs_precedes is only used for positive amount, n_cs_precedes should be used for negative. Here we are assuming that positive and negative amounts are displayed the same way. Signed-off-by: Martin Renvoize --- Koha/Number/Price.pm | 3 +-- admin/currency.pl | 3 +++ .../prog/en/modules/admin/currency.tt | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Koha/Number/Price.pm b/Koha/Number/Price.pm index 7b0b826a14..ab361973ad 100644 --- a/Koha/Number/Price.pm +++ b/Koha/Number/Price.pm @@ -95,7 +95,6 @@ sub round { sub _format_params { my ( $self, $params ) = @_; my $with_symbol = $params->{with_symbol} || 0; - my $p_cs_precedes = $params->{p_cs_precedes}; my $currency = Koha::Acquisition::Currencies->get_active; my $currency_format = C4::Context->preference("CurrencyFormat"); @@ -132,8 +131,8 @@ sub _format_params { } - $format_params{p_cs_precedes} = $p_cs_precedes if defined $p_cs_precedes; $format_params{p_sep_by_space} = ( $currency and $currency->p_sep_by_space ) ? 1 : 0; + $format_params{p_cs_precedes} = ( $currency and $currency->p_cs_precedes ) ? 1 : 0; return \%format_params; } diff --git a/admin/currency.pl b/admin/currency.pl index 41003aeca9..4733b147bf 100755 --- a/admin/currency.pl +++ b/admin/currency.pl @@ -58,6 +58,7 @@ if ( $op eq 'add_form' ) { my $rate = $input->param('rate'); my $active = $input->param('active'); my $p_sep_by_space = $input->param('p_sep_by_space'); + my $p_cs_precedes = $input->param('p_cs_precedes'); my $is_a_modif = $input->param('is_a_modif'); if ($is_a_modif) { @@ -67,6 +68,7 @@ if ( $op eq 'add_form' ) { $currency->rate($rate); $currency->active($active); $currency->p_sep_by_space($p_sep_by_space); + $currency->p_cs_precedes($p_cs_precedes); eval { $currency->store; }; if ($@) { push @messages, { type => 'error', code => 'error_on_update' }; @@ -81,6 +83,7 @@ if ( $op eq 'add_form' ) { rate => $rate, active => $active, p_sep_by_space => $p_sep_by_space, + p_cs_precedes => $p_cs_precedes, } ); eval { $currency->store; }; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt index e16313110b..1025de096f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt @@ -102,6 +102,20 @@ [% END %] +
  • + + [% IF currency.p_cs_precedes %] + + + [% ELSE %] + + + [% END %] +
  • [% IF currency.active %] -- 2.20.1