From 46c3bcf93d0b14b9cc4eb5c6bda70a54a4ed96e8 Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Mon, 30 Dec 2019 15:13:36 +0200 Subject: [PATCH] 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 4fda2449ba..375cf34f13 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -40,6 +40,8 @@ use Koha::Notice::Templates; use Koha::DateUtils qw( format_sqldatetime dt_from_string ); use Koha::Patrons; use Koha::Subscriptions; +use Koha::Account::Lines; +use Locale::Currency::Format; use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); @@ -632,11 +634,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 bceaa83262..2565a2867f 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.11.0