Bugzilla – Attachment 179617 Details for
Bug 14250
Don't allow to generate discharges for patrons with fines
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14250: Patron with fines cannot be discharged anymore
Bug-14250-Patron-with-fines-cannot-be-discharged-a.patch (text/plain), 9.90 KB, created by
Baptiste Wojtkowski (bwoj)
on 2025-03-21 14:26:15 UTC
(
hide
)
Description:
Bug 14250: Patron with fines cannot be discharged anymore
Filename:
MIME Type:
Creator:
Baptiste Wojtkowski (bwoj)
Created:
2025-03-21 14:26:15 UTC
Size:
9.90 KB
patch
obsolete
>From c807d48cd7ca2b8ef2f75ec531d8fd716ed61572 Mon Sep 17 00:00:00 2001 >From: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> >Date: Wed, 7 Aug 2024 14:18:20 +0200 >Subject: [PATCH] Bug 14250: Patron with fines cannot be discharged anymore > >TEST PLAN: >1 - In the intranet add fines to a client and ensure they have no checkout >2 - Set syspref useDischarge to 'Allow' >3 - On client profile click on "Discharge", see it is possible >4 - On the opac, go to the tab "Ask for discharge", see it is possible >5 - Apply patch >6 - Click on the button "Ask for discharge" -> it will not be possible > and you will be propperly messaged >7 - Return to the tab "Ask for a discharge", there will be no button > anymore >8 - On the intranet page, there will be no button anymore >9 - Check out a book >10 - Repeat 7 and 8 and see the message include issue with checkout >11 - Remove fine and repeat 7 & 8 >--- > Koha/Patron/Discharge.pm | 7 ++++- > .../prog/en/modules/members/discharge.tt | 13 +++++++- > .../bootstrap/en/modules/opac-discharge.tt | 30 ++++++++++++++++-- > members/discharge.pl | 5 +++ > opac/opac-discharge.pl | 16 +++++++--- > t/db_dependent/Patron/Borrower_Discharge.t | 31 +++++++++++++++++-- > 6 files changed, 89 insertions(+), 13 deletions(-) > >diff --git a/Koha/Patron/Discharge.pm b/Koha/Patron/Discharge.pm >index 6f702061..01b285fe 100644 >--- a/Koha/Patron/Discharge.pm >+++ b/Koha/Patron/Discharge.pm >@@ -39,7 +39,12 @@ sub can_be_discharged { > return unless $patron; > > my $has_pending_checkouts = $patron->checkouts->count; >- return $has_pending_checkouts ? 0 : 1; >+ return 0 if $has_pending_checkouts; >+ >+ my $has_debt = ( $patron->account->outstanding_debits->total_outstanding > 0 ); >+ return 0 if $has_debt; >+ >+ return 1; > } > > sub is_discharged { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/discharge.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/discharge.tt >index 9ebb53d7..01a1c003 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/discharge.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/discharge.tt >@@ -52,7 +52,18 @@ > </div> > [% END %] > [% UNLESS can_be_discharged %] >- <p>Cannot edit discharge: the patron has checked out items.</p> >+ <p>Cannot edit discharge for following reasons: </p> >+ <ul> >+ [% IF patron.checkouts.count %] >+ <li>They have checked out items</li> >+ [% END %] >+ [% IF (patron.account.outstanding_debits.total_outstanding > 0) %] >+ <li>They have unpaid fines</li> >+ [% END %] >+ [% IF patron.checkouts.count == 0 and (patron.account.outstanding_debits.total_outstanding == 0) %] >+ <li> Patron cannot be discharged for an unknown reason, please contact a librarian for more information</li> >+ [% END %] >+ </ul> > [% ELSE %] > [% IF patron.holds.count %] > <p>Patron has holds. They will be cancelled if the discharge is generated.</p> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-discharge.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-discharge.tt >index 5114ca7a..3578e1d2 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-discharge.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-discharge.tt >@@ -41,8 +41,19 @@ > <p><a href="/cgi-bin/koha/opac-discharge.pl?op=get">Get your discharge</a></p> > [% ELSIF pending %] > <p>Your discharge will be available on this page within a few days.</p> >- [% ELSIF has_issues %] >+ [% ELSIF failure %] > <p>You cannot be discharged, you have checked out items. Please return items before asking for a discharge.</p> >+ <ul> >+ [% IF has_debt %] >+ <li> You have unpaid fines. Please pay your fines before reapplying.</li> >+ [% END %] >+ [% IF has_issues %] >+ <li> You have checked out items. Please return them before reapplying.</li> >+ [% END %] >+ [% IF !has_issue and !has_debt %] >+ <li> Patron cannot be discharged for an unknown reason, please contact a librarian for more information</li> >+ [% END %] >+ </ul> > [% ELSIF not messages %] > <h2>What is a discharge?</h2> > <p >@@ -50,8 +61,21 @@ > available on your reader account.</p > > > <p><strong>Warning</strong>: This request is only valid if you are in good standing with the library. Once the application is made, you can not borrow library materials.</p> >- [% IF has_checkouts %] >- <div class="alert alert-info">You cannot be discharged, you have checked out items. Please return items before asking for a discharge.</div> >+ [% UNLESS can_be_discharged %] >+ <div class="alert alert-info" >+ >You cannot be discharged for following reasons: >+ <ul> >+ [% IF has_debt %] >+ <li> You have unpaid fines. Please pay your fines before reapplying.</li> >+ [% END %] >+ [% IF has_checkouts %] >+ <li> You have checked out items. Please return them before reapplying.</li> >+ [% END %] >+ [% IF !has_checkouts and !has_debt %] >+ <li> Patron cannot be discharged for an unknown reason, please contact a librarian for more information</li> >+ [% END %] >+ </ul> >+ </div> > [% ELSE %] > <form action="/cgi-bin/koha/opac-discharge.pl" method="post"> > [% INCLUDE 'csrf-token.inc' %] >diff --git a/members/discharge.pl b/members/discharge.pl >index 7798794a..e55ed6b0 100755 >--- a/members/discharge.pl >+++ b/members/discharge.pl >@@ -67,6 +67,11 @@ output_and_exit_if_error( > > my $can_be_discharged = Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $borrowernumber } ); > >+unless ($can_be_discharged) { >+ my $has_checkout = $patron->checkouts->count; >+ my $has_fine = $patron->account->outstanding_debits->total_outstanding; >+} >+ > # Generating discharge if needed > if ( $op eq 'cud-discharge' && $input->param('discharge') and $can_be_discharged ) { > my $is_discharged = Koha::Patron::Discharge::is_discharged( >diff --git a/opac/opac-discharge.pl b/opac/opac-discharge.pl >index 04325fa9..76d535b3 100755 >--- a/opac/opac-discharge.pl >+++ b/opac/opac-discharge.pl >@@ -45,10 +45,14 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >-my $can_be_discharged = Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $loggedinuser } ); >-if ( $can_be_discharged == 0 ) { >- $template->param( has_checkouts => 1 ); >-} >+my $can_be_discharged = Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $loggedinuser } ); >+my $patron = Koha::Patrons->find($loggedinuser); >+my $has_pending_checkouts = $patron->checkouts->count; >+my $has_debt = ( $patron->account->outstanding_debits->total_outstanding > 0 ); >+ >+$template->param( can_be_discharged => $can_be_discharged ); >+$template->param( has_checkouts => $has_pending_checkouts ); >+$template->param( has_debt => $has_debt ); > > my $pending = Koha::Patron::Discharge::count( > { >@@ -73,7 +77,9 @@ if ( $op eq 'cud-request' ) { > if ($success) { > $template->param( success => 1 ); > } else { >- $template->param( has_issues => 1 ); >+ $template->param( failure => 1 ); >+ $template->param( has_issues => $has_pending_checkouts ); >+ $template->param( has_debt => $has_debt ); > } > } elsif ( $op eq 'get' ) { > unless ($available) { >diff --git a/t/db_dependent/Patron/Borrower_Discharge.t b/t/db_dependent/Patron/Borrower_Discharge.t >index 9274096d..86d14b9e 100755 >--- a/t/db_dependent/Patron/Borrower_Discharge.t >+++ b/t/db_dependent/Patron/Borrower_Discharge.t >@@ -16,7 +16,7 @@ > > use Modern::Perl; > >-use Test::More tests => 23; >+use Test::More tests => 25; > > use Test::MockModule; > use Test::Warn; >@@ -105,12 +105,37 @@ is( > is_deeply( [Koha::Patron::Discharge::get_pendings], [], 'There is no pending discharge request' ); > is_deeply( [Koha::Patron::Discharge::get_validated], [], 'There is no validated discharge' ); > >+#Â Discharge not possible with issues and fines >+$patron->account->add_debit( >+ { >+ amount => 0.1, >+ interface => C4::Context->interface, >+ type => 'OVERDUE' >+ } >+); >+ >+is( >+ Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $patron->borrowernumber } ), 0, >+ 'A patron with fines and checkouts cannot be discharged' >+); >+ > AddReturn($barcode); > >-# Discharge possible without issue >+is( >+ Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $patron->borrowernumber } ), 0, >+ 'A patron with fines cannot be discharged' >+); >+ >+$patron->account->pay( >+ { >+ amount => 0.1, >+ } >+); >+ >+# Discharge possible without issue or fine > is( > Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $patron->borrowernumber } ), 1, >- 'A patron without issues can be discharged' >+ 'A patron without issues or fines can be discharged' > ); > > is( Koha::Patron::Discharge::generate_as_pdf, undef, "Confirm failure when lacking borrower number" ); >-- >2.30.2
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 14250
:
170136
|
170228
|
170581
|
170607
|
170662
|
170663
|
170664
|
170705
|
170706
|
170707
|
170708
|
171025
|
171026
|
171271
|
171272
|
171273
|
171274
|
171275
|
171276
| 179617 |
179618
|
179619
|
179620
|
179621
|
179622