From e3a40dcd488c56c9b83b446590266d2e8984abe8 Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Mon, 30 Dec 2019 15:13:36 +0200 Subject: [PATCH 2/5] Bug 13961: Add currency format handling Sponsored-by: Koha-Suomi Oy Signed-off-by: Sally --- C4/Letters.pm | 10 ++++++++-- tools/letter.pl | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index 5d039a83e0..b5f62da3e2 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -42,6 +42,8 @@ use Koha::DateUtils qw( format_sqldatetime dt_from_string ); use Koha::Patrons; use Koha::SMTP::Servers; use Koha::Subscriptions; +use Koha::Account::Lines; +use Locale::Currency::Format; use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); @@ -667,11 +669,15 @@ sub GetPreparedLetter { my $OPACBaseURL = C4::Context->preference('OPACBaseURL'); $letter->{content} =~ s/<>/$OPACBaseURL/go; + my $active_currency = Koha::Acquisition::Currencies->get_active; + my $currency_format = $active_currency->currency if defined($active_currency); + my $borrowernumber = $tables->{borrowers}; my $lines = Koha::Account::Lines->search({ borrowernumber => $borrowernumber }); my ($totalfine) = $lines->total_outstanding; - $totalfine = sprintf("%.2f", $totalfine); - $letter->{content} =~ s/<>/$totalfine/go; + my $totalfine_formatted = currency_format($currency_format, "$totalfine", FMT_SYMBOL); + $totalfine_formatted = sprintf("%.2f", $totalfine) unless $totalfine_formatted; + $letter->{content} =~ s/<>/$totalfine_formatted/go; if ($want_librarian) { # parsing librarian name diff --git a/tools/letter.pl b/tools/letter.pl index 968c79ace1..a0cafa5e6e 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -247,7 +247,7 @@ sub add_form { {value => 'items.content', text => 'items.content'}, {value => 'items.fine', text => 'items.fine'}, add_fields('borrowers'), - {value => 'borrowers.totalfine', text => 'borrowers.totalfine' }; + {value => 'borrowers.account_balance', text => 'borrowers.account_balance' }; if ($module eq 'circulation') { push @{$field_selection}, add_fields('opac_news'); -- 2.25.1