@@ -, +, @@
---
C4/ILSDI/Services.pm | 3 +--
koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt | 3 ++-
members/deletemem.pl | 9 +++++----
members/member-flags.pl | 1 -
misc/cronjobs/delete_patrons.pl | 9 ++++++---
5 files changed, 14 insertions(+), 11 deletions(-)
--- a/C4/ILSDI/Services.pm
+++ a/C4/ILSDI/Services.pm
@@ -393,8 +393,7 @@ sub GetPatronInfo {
# Cleaning the borrower hashref
my $borrower = $patron->unblessed;
- my $flags = C4::Members::patronflags( $borrower );
- $borrower->{'charges'} = $flags->{'CHARGES'}->{'amount'};
+ $borrower->{charges} = sprintf "%.02f", $patron->account->non_issues_charges; # FIXME Formatting should not be done here
my $library = Koha::Libraries->find( $borrower->{branchcode} );
$borrower->{'branchname'} = $library ? $library->branchname : '';
delete $borrower->{'userid'};
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt
@@ -1,3 +1,4 @@
+[% USE Price %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
Koha › Delete patron [% patron.firstname %] [% patron.surname %]
@@ -22,7 +23,7 @@
Patron has [% ItemsOnIssues %] item(s) checked out.
[% END %]
[% IF ( charges ) %]
- Patron has [% charges %] in fines.
+ Patron has [% charges | $Prices %] in fines.
[% END %]
[% IF ( guarantees ) %]
Patron's record has guaranteed accounts attached.
--- a/members/deletemem.pl
+++ a/members/deletemem.pl
@@ -77,7 +77,8 @@ if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preferen
my $issues = GetPendingIssues($member); # FIXME: wasteful call when really, we only want the count
my $countissues = scalar(@$issues);
-my $flags = C4::Members::patronflags( $patron->unblessed );
+my $patron = Koha::Patrons->find( $member );
+my $charges = $patron->account->non_issues_charges;
my $userenv = C4::Context->userenv;
@@ -115,8 +116,8 @@ if ( $op eq 'delete_confirm' or $countissues > 0 or $flags->{'CHARGES'} or $is_
if ($countissues >0) {
$template->param(ItemsOnIssues => $countissues);
}
- if ($flags->{'CHARGES'} ne '') {
- $template->param(charges => $flags->{'CHARGES'}->{'amount'});
+ if ( $charges > 0 ) {
+ $template->param(charges => $charges);
}
if ($is_guarantor) {
$template->param(guarantees => 1);
@@ -125,7 +126,7 @@ if ( $op eq 'delete_confirm' or $countissues > 0 or $flags->{'CHARGES'} or $is_
$template->param(keeplocal => 1);
}
# This is silly written but reflect the same conditions as above
- if ( not $countissues > 0 and not $flags->{CHARGES} ne '' and not $is_guarantor and not $deletelocal == 0 ) {
+ if ( not $countissues > 0 and not $charges and not $is_guarantor and not $deletelocal == 0 ) {
$template->param(
op => 'delete_confirm',
csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }),
--- a/members/member-flags.pl
+++ a/members/member-flags.pl
@@ -106,7 +106,6 @@ if ($input->param('newflags')) {
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member");
} else {
- my $flags = C4::Members::patronflags( $bor );
my $accessflags;
my $dbh = C4::Context->dbh();
# FIXME This needs to be improved to avoid doing the same query
--- a/misc/cronjobs/delete_patrons.pl
+++ a/misc/cronjobs/delete_patrons.pl
@@ -66,14 +66,17 @@ for my $member (@$members) {
if $verbose;
my $borrowernumber = $member->{borrowernumber};
- my $flags = C4::Members::patronflags( $member );
- if ( my $charges = $flags->{CHARGES}{amount} ) {
+ my $patron = Koha::Patrons->find( $borrowernumber );
+ unless ( $patron ) {
+ say "Patron with borrowernumber $borrowernumber does not exist";
+ next;
+ }
+ if ( my $charges = $patron->account->non_issues_charges ) { # And what if we owe to this patron?
say "Failed to delete patron $borrowernumber: patron has $charges in fines";
next;
}
if ( $confirm ) {
- my $patron = Koha::Patrons->find( $borrowernumber );
my $deleted = eval { $patron->move_to_deleted; };
if ($@ or not $deleted) {
say "Failed to delete patron $borrowernumber, cannot move it" . ( $@ ? ": ($@)" : "" );
--