Bugzilla – Attachment 70349 Details for
Bug 19933
Move C4::Members::patronflags to the Koha namespace - part 1
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19933: Remove patronflags - easy ones
Bug-19933-Remove-patronflags---easy-ones.patch (text/plain), 7.43 KB, created by
Jonathan Druart
on 2018-01-09 14:24:59 UTC
(
hide
)
Description:
Bug 19933: Remove patronflags - easy ones
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-01-09 14:24:59 UTC
Size:
7.43 KB
patch
obsolete
>From afa43ff70fb76a96996d51c0a38cd5fd0eecec91 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Sun, 7 Jan 2018 14:42:00 -0300 >Subject: [PATCH] Bug 19933: Remove patronflags - easy ones > >This patch replaces the easy occurrences of patronflags. > >These calls only need the CHARGES->amount value, that is the non issues >charges. Luckily we now have a Koha::Account->non_issues_charges that >deal with that. >--- > C4/ILSDI/Services.pm | 3 +-- > koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt | 3 ++- > members/deletemem.pl | 10 +++++----- > members/member-flags.pl | 1 - > misc/cronjobs/delete_patrons.pl | 9 ++++++--- > t/db_dependent/Circulation/dateexpiry.t | 3 --- > 6 files changed, 14 insertions(+), 15 deletions(-) > >diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm >index a0aec9987d..4aa72e5801 100644 >--- a/C4/ILSDI/Services.pm >+++ b/C4/ILSDI/Services.pm >@@ -376,8 +376,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'}; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt >index 82ba917c06..eed29cb20c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt >@@ -1,3 +1,4 @@ >+[% USE Price %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Delete patron [% firstname %] [% surname %]</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -21,7 +22,7 @@ > <li>Patron has [% ItemsOnIssues %] item(s) checked out.</li> > [% END %] > [% IF ( charges ) %] >- <li>Patron has [% charges %] in fines.</li> >+ <li>Patron has [% charges | $Prices %] in fines.</li> > [% END %] > [% IF ( guarantees ) %] > <li>Patron's record has guaranteed accounts attached.</li> >diff --git a/members/deletemem.pl b/members/deletemem.pl >index ea12ae6008..4287c2917f 100755 >--- a/members/deletemem.pl >+++ b/members/deletemem.pl >@@ -79,7 +79,7 @@ unless ( $patron ) { > print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$member"); > exit; > } >-my $flags = C4::Members::patronflags( $patron->unblessed ); >+my $charges = $patron->account->non_issues_charges; > my $userenv = C4::Context->userenv; > > >@@ -109,7 +109,7 @@ if (C4::Context->preference("IndependentBranches")) { > my $op = $input->param('op') || 'delete_confirm'; > my $dbh = C4::Context->dbh; > my $is_guarantor = $dbh->selectrow_array("SELECT COUNT(*) FROM borrowers WHERE guarantorid=?", undef, $member); >-if ( $op eq 'delete_confirm' or $countissues > 0 or $flags->{'CHARGES'} or $is_guarantor or $deletelocal == 0) { >+if ( $op eq 'delete_confirm' or $countissues > 0 or $charges or $is_guarantor or $deletelocal == 0) { > $template->param( picture => 1 ) if $patron->image; > > $template->param( adultborrower => 1 ) if $patron->category->category_type =~ /^(A|I)$/; >@@ -136,8 +136,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); >@@ -146,7 +146,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') }), >diff --git a/members/member-flags.pl b/members/member-flags.pl >index 27e020c96a..a0dd308271 100755 >--- a/members/member-flags.pl >+++ b/members/member-flags.pl >@@ -103,7 +103,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 >diff --git a/misc/cronjobs/delete_patrons.pl b/misc/cronjobs/delete_patrons.pl >index ee015a6856..4470746a96 100755 >--- a/misc/cronjobs/delete_patrons.pl >+++ b/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" . ( $@ ? ": ($@)" : "" ); >diff --git a/t/db_dependent/Circulation/dateexpiry.t b/t/db_dependent/Circulation/dateexpiry.t >index 97e22a8a5d..c20a737c9c 100644 >--- a/t/db_dependent/Circulation/dateexpiry.t >+++ b/t/db_dependent/Circulation/dateexpiry.t >@@ -55,7 +55,6 @@ sub can_book_be_issued { > } > } > ); >- $patron->{flags} = C4::Members::patronflags( $patron ); > my $duration = gettimeofday(); > my ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); > $duration = gettimeofday() - $duration; >@@ -71,7 +70,6 @@ sub can_book_be_issued { > } > } > ); >- $patron->{flags} = C4::Members::patronflags( $patron ); > ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); > is( $issuingimpossible->{EXPIRED}, 1, 'The patron should be considered as expired if dateexpiry is 0000-00-00' ); > >@@ -85,7 +83,6 @@ sub can_book_be_issued { > }, > } > ); >- $patron->{flags} = C4::Members::patronflags( $patron ); > ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); > is( not( exists $issuingimpossible->{EXPIRED} ), 1, 'The patron should not be considered as expired if dateexpiry is tomorrow' ); > >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19933
:
70347
|
70348
|
70349
|
70350
|
71803
|
71804
|
71805
|
71806
|
72004
|
72005
|
72006
|
72007
|
72094
|
72095
|
72350
|
72351
|
72352
|
72353
|
72354
|
72355
|
72356
|
72472
|
72473
|
72474
|
72475
|
72476
|
72477
|
72478