Bugzilla – Attachment 171271 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), 10.14 KB, created by
Sukhmandeep
on 2024-09-10 16:49:58 UTC
(
hide
)
Description:
Bug 14250: Patron with fines cannot be discharged anymore
Filename:
MIME Type:
Creator:
Sukhmandeep
Created:
2024-09-10 16:49:58 UTC
Size:
10.14 KB
patch
obsolete
>From d8eb9bd78af071a479fc77f3e8b5ea7912c9f7b7 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 > >Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Sukhmandeep Benipal <sukhmandeep.benipal@inLibro.com> >--- > Koha/Patron/Discharge.pm | 7 +++- > .../prog/en/modules/members/discharge.tt | 13 +++++++- > .../bootstrap/en/modules/opac-discharge.tt | 29 +++++++++++++++-- > members/discharge.pl | 6 ++++ > opac/opac-discharge.pl | 16 +++++++--- > t/db_dependent/Patron/Borrower_Discharge.t | 32 +++++++++++++++++-- > 6 files changed, 90 insertions(+), 13 deletions(-) > >diff --git a/Koha/Patron/Discharge.pm b/Koha/Patron/Discharge.pm >index f86d4d77ee..a72f7f2b7b 100644 >--- a/Koha/Patron/Discharge.pm >+++ b/Koha/Patron/Discharge.pm >@@ -40,7 +40,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 70300e88fe..e0e403a730 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 96f019d796..752b58aea4 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-discharge.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-discharge.tt >@@ -43,14 +43,37 @@ > <a href="/cgi-bin/koha/opac-discharge.pl?op=get">Get your discharge</a></li> > [% 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>This document certifies that you have returned all borrowed items. It is sometimes asked during a file transfer from a school to another. The discharge is sent by us to your school. You will also find it 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 10002e21c5..2742bad084 100755 >--- a/members/discharge.pl >+++ b/members/discharge.pl >@@ -65,6 +65,12 @@ 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 d232ea5722..5e6869be44 100755 >--- a/opac/opac-discharge.pl >+++ b/opac/opac-discharge.pl >@@ -43,10 +43,14 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ > type => "opac", > }); > >-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({ > borrowernumber => $loggedinuser, >@@ -67,7 +71,9 @@ if ( $op eq 'cud-request' ) { > $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' ) { >diff --git a/t/db_dependent/Patron/Borrower_Discharge.t b/t/db_dependent/Patron/Borrower_Discharge.t >index 6c06ecff90..8769f50f11 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; >@@ -90,10 +90,36 @@ is( Koha::Patron::Discharge::discharge({ borrowernumber => $patron->borrowernumb > 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 }), 1, 'A patron without issues can be discharged' ); >+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 or fines can be discharged' >+); > > is(Koha::Patron::Discharge::generate_as_pdf,undef,"Confirm failure when lacking borrower number"); > >-- >2.34.1
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