Bugzilla – Attachment 47936 Details for
Bug 14577
Allow restriction of checkouts based on fines of guarantor/guarantee
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14577 - Allow restriction of checkouts based on fines of guarantor's guarantees
Bug-14577---Allow-restriction-of-checkouts-based-o.patch (text/plain), 14.30 KB, created by
Kyle M Hall (khall)
on 2016-02-11 19:30:23 UTC
(
hide
)
Description:
Bug 14577 - Allow restriction of checkouts based on fines of guarantor's guarantees
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-02-11 19:30:23 UTC
Size:
14.30 KB
patch
obsolete
>From 3efa666e4fd2b000cc9d4edaf19199f496439ef5 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 11 Feb 2016 01:23:09 +0000 >Subject: [PATCH] Bug 14577 - Allow restriction of checkouts based on fines of > guarantor's guarantees > >This enhancment allows a library to prevent patrons from checking out >items if his or her guarantees own too much. >--- > C4/Circulation.pm | 37 ++++++++++++++++++ > C4/Members.pm | 31 +++++++++++++-- > Koha/Borrower.pm | 6 +++ > circ/circulation.pl | 15 ++++++++ > installer/data/mysql/atomicupdate/bug_14577.sql | 2 + > installer/data/mysql/sysprefs.sql | 1 + > .../en/modules/admin/preferences/circulation.pref | 5 +++ > .../prog/en/modules/circ/circulation.tt | 44 +++++++++++++++------- > 8 files changed, 123 insertions(+), 18 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_14577.sql > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index ae53366..a3dcb26 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -53,6 +53,7 @@ use Koha::Borrower::Debarments; > use Koha::Database; > use Carp; > use List::MoreUtils qw( uniq ); >+use Scalar::Util qw( looks_like_number ); > use Date::Calc qw( > Today > Today_and_Now >@@ -840,9 +841,44 @@ sub CanBookBeIssued { > # DEBTS > my ($balance, $non_issue_charges, $other_charges) = > C4::Members::GetMemberAccountBalance( $borrower->{'borrowernumber'} ); >+ > my $amountlimit = C4::Context->preference("noissuescharge"); > my $allowfineoverride = C4::Context->preference("AllowFineOverride"); > my $allfinesneedoverride = C4::Context->preference("AllFinesNeedOverride"); >+ >+ # Check the debt of this patrons guarantees >+ my $no_issues_charge_guarantees = C4::Context->preference("NoIssuesChargeGuarantees"); >+ $no_issues_charge_guarantees = undef unless looks_like_number( $no_issues_charge_guarantees ); >+ if ( defined $no_issues_charge_guarantees ) { >+ my $b = Koha::Borrowers->find( $borrower->{borrowernumber} ); >+ my @guarantees = $b->guarantees(); >+ my $guarantees_non_issues_charges; >+ foreach my $g ( @guarantees ) { >+ my ( $b, $n, $o ) = C4::Members::GetMemberAccountBalance( $g->id ); >+ $guarantees_non_issues_charges += $n; >+ } >+ >+ if ( C4::Context->preference("IssuingInProcess") ) { >+ if ( $guarantees_non_issues_charges > $no_issues_charge_guarantees && !$inprocess && !$allowfineoverride) { >+ $issuingimpossible{DEBT_GUARANTEES} = sprintf( "%.2f", $guarantees_non_issues_charges ); >+ } elsif ( $guarantees_non_issues_charges > $no_issues_charge_guarantees && !$inprocess && $allowfineoverride) { >+ $needsconfirmation{DEBT_GUARANTEES} = sprintf( "%.2f", $guarantees_non_issues_charges ); >+ } elsif ( $allfinesneedoverride && $guarantees_non_issues_charges > 0 && $guarantees_non_issues_charges <= $no_issues_charge_guarantees && !$inprocess ) { >+ $needsconfirmation{DEBT_GUARANTEES} = sprintf( "%.2f", $guarantees_non_issues_charges ); >+ } >+ } >+ else { >+ if ( $guarantees_non_issues_charges > $no_issues_charge_guarantees && $allowfineoverride ) { >+ $needsconfirmation{DEBT_GUARANTEES} = sprintf( "%.2f", $guarantees_non_issues_charges ); >+ } elsif ( $guarantees_non_issues_charges > $no_issues_charge_guarantees && !$allowfineoverride) { >+ $issuingimpossible{DEBT_GUARANTEES} = sprintf( "%.2f", $guarantees_non_issues_charges ); >+ } elsif ( $guarantees_non_issues_charges > 0 && $allfinesneedoverride ) { >+ $needsconfirmation{DEBT_GUARANTEES} = sprintf( "%.2f", $guarantees_non_issues_charges ); >+ } >+ } >+ >+ } >+ > if ( C4::Context->preference("IssuingInProcess") ) { > if ( $non_issue_charges > $amountlimit && !$inprocess && !$allowfineoverride) { > $issuingimpossible{DEBT} = sprintf( "%.2f", $non_issue_charges ); >@@ -861,6 +897,7 @@ sub CanBookBeIssued { > $needsconfirmation{DEBT} = sprintf( "%.2f", $non_issue_charges ); > } > } >+ > if ($balance > 0 && $other_charges > 0) { > $alerts{OTHER_CHARGES} = sprintf( "%.2f", $other_charges ); > } >diff --git a/C4/Members.pm b/C4/Members.pm >index 4ba1f19..ec1cfdb 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -24,6 +24,7 @@ use strict; > #use warnings; FIXME - Bug 2505 > use C4::Context; > use String::Random qw( random_string ); >+use Scalar::Util qw( looks_like_number ); > use Date::Calc qw/Today Add_Delta_YM check_date Date_to_Days/; > use C4::Log; # logaction > use C4::Overdues; >@@ -326,13 +327,13 @@ sub patronflags { > my ($balance, $owing) = GetMemberAccountBalance( $patroninformation->{'borrowernumber'}); > if ( $owing > 0 ) { > my %flaginfo; >- my $noissuescharge = C4::Context->preference("noissuescharge") || 5; >- $flaginfo{'message'} = sprintf 'Patron owes %.02f', $owing; >+ my $noissuescharge = c4::context->preference("noissuescharge") || 5; >+ $flaginfo{'message'} = sprintf 'patron owes %.02f', $owing; > $flaginfo{'amount'} = sprintf "%.02f", $owing; >- if ( $owing > $noissuescharge && !C4::Context->preference("AllowFineOverride") ) { >+ if ( $owing > $noissuescharge && !c4::context->preference("allowfineoverride") ) { > $flaginfo{'noissues'} = 1; > } >- $flags{'CHARGES'} = \%flaginfo; >+ $flags{'charges'} = \%flaginfo; > } > elsif ( $balance < 0 ) { > my %flaginfo; >@@ -340,6 +341,28 @@ sub patronflags { > $flaginfo{'amount'} = sprintf "%.02f", $balance; > $flags{'CREDITS'} = \%flaginfo; > } >+ >+ # Check the debt of the guarntees of this patron >+ my $no_issues_charge_guarantees = C4::Context->preference("NoIssuesChargeGuarantees"); >+ $no_issues_charge_guarantees = undef unless looks_like_number( $no_issues_charge_guarantees ); >+ if ( defined $no_issues_charge_guarantees ) { >+ my $b = Koha::Borrowers->find( $patroninformation->{borrowernumber} ); >+ my @guarantees = $b->guarantees(); >+ my $guarantees_non_issues_charges; >+ foreach my $g ( @guarantees ) { >+ my ( $b, $n, $o ) = C4::Members::GetMemberAccountBalance( $g->id ); >+ $guarantees_non_issues_charges += $n; >+ } >+ >+ if ( $guarantees_non_issues_charges > $no_issues_charge_guarantees ) { >+ my %flaginfo; >+ $flaginfo{'message'} = sprintf 'patron guarantees owe %.02f', $guarantees_non_issues_charges; >+ $flaginfo{'amount'} = sprintf "%.02f", $guarantees_non_issues_charges; >+ $flaginfo{'noissues'} = 1 unless C4::Context->preference("allowfineoverride"); >+ $flags{'CHARGES_GUARANTEES'} = \%flaginfo; >+ } >+ } >+ > if ( $patroninformation->{'gonenoaddress'} > && $patroninformation->{'gonenoaddress'} == 1 ) > { >diff --git a/Koha/Borrower.pm b/Koha/Borrower.pm >index 6604b8a..bb99602 100644 >--- a/Koha/Borrower.pm >+++ b/Koha/Borrower.pm >@@ -47,6 +47,12 @@ sub guarantor { > return Koha::Borrowers->find( $self->guarantorid() ); > } > >+sub guarantees { >+ my ( $self ) = @_; >+ >+ return Koha::Borrowers->search( { guarantorid => $self->id } ); >+} >+ > =head3 type > > =cut >diff --git a/circ/circulation.pl b/circ/circulation.pl >index e6ba9a2..5e933b6 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -500,6 +500,14 @@ foreach my $flag ( sort keys %$flags ) { > charges_is_blocker => 1 > ); > } >+ elsif ( $flag eq 'CHARGES_GUARANTEES' ) { >+ $template->param( >+ charges_guarantees => 'true', >+ chargesmsg_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'message'}, >+ chargesamount_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'amount'}, >+ charges_guarantees_is_blocker => 1 >+ ); >+ } > elsif ( $flag eq 'CREDITS' ) { > $template->param( > credits => 'true', >@@ -516,6 +524,13 @@ foreach my $flag ( sort keys %$flags ) { > chargesamount => $flags->{'CHARGES'}->{'amount'}, > ); > } >+ elsif ( $flag eq 'CHARGES_GUARANTEES' ) { >+ $template->param( >+ charges_guarantees => 'true', >+ chargesmsg_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'message'}, >+ chargesamount_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'amount'}, >+ ); >+ } > elsif ( $flag eq 'CREDITS' ) { > $template->param( > credits => 'true', >diff --git a/installer/data/mysql/atomicupdate/bug_14577.sql b/installer/data/mysql/atomicupdate/bug_14577.sql >new file mode 100644 >index 0000000..ab62900 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_14577.sql >@@ -0,0 +1,2 @@ >+INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES >+('NoIssuesChargeGuarantees','','','Define maximum amount withstanding before check outs are blocked','Integer'); >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 96ea9ad..ad310d0 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -231,6 +231,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('NewItemsDefaultLocation','','','If set, all new items will have a location of the given Location Code ( Authorized Value type LOC )',''), > ('NewsAuthorDisplay','none','none|opac|staff|both','Display the author name for news items.','Choice'), > ('noissuescharge','5','','Define maximum amount withstanding before check outs are blocked','Integer'), >+('NoIssuesChargeGuarantees','','','Define maximum amount withstanding before check outs are blocked','Integer'), > ('noItemTypeImages','0',NULL,'If ON, disables item-type images','YesNo'), > ('NoLoginInstructions', '', '60|10', 'Instructions to display on the OPAC login form when a patron is not logged in', 'Textarea'), > ('NorwegianPatronDBEnable','0',NULL,'Enable communication with the Norwegian national patron database.', 'YesNo'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >index d9c7e25..7b8c021 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >@@ -291,6 +291,11 @@ Circulation: > class: integer > - '[% local_currency %] in fines.' > - >+ - Prevent patrons from checking out books if the have guarantees owing in total more than >+ - pref: NoIssuesChargeGuarantees >+ class: integer >+ - '[% local_currency %] in fines.' >+ - > - pref: RentalsInNoissuesCharge > choices: > yes: Include >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index 633e756..aebfa6e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -229,6 +229,11 @@ $(document).ready(function() { > [% IF ( DEBT ) %] > <li>The patron has a debt of [% DEBT %].</li> > [% END %] >+ >+[% IF ( DEBT_GUARANTEES ) %] >+ <li>The patron's guarantees collectively have a debt of [% DEBT_GUARANTEES %].</li> >+[% END %] >+ > [% IF ( RENTALCHARGE && RENTALCHARGE > 0 ) %] > <li>Rental charge for this item: [% RENTALCHARGE %]</li> > [% END %] >@@ -787,21 +792,32 @@ No patron matched <span class="ex">[% message %]</span> > [% IF ( odues ) %]<li>[% IF ( nonreturns ) %]<span class="circ-hlt">Overdues: Patron has ITEMS OVERDUE</span>. See highlighted items <a href="#checkouts">below</a>[% END %]</li> > [% END %] > >- [% IF ( charges ) %] >- <li> >- <span class="circ-hlt">Fees & Charges:</span> Patron has <a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrowernumber %]">Outstanding fees & charges[% IF ( chargesamount ) %] of [% chargesamount %][% END %]</a>. >- [% IF ( charges_is_blocker ) %] >- <span class="circ-hlt">Checkouts are BLOCKED because fine balance is OVER THE LIMIT.</span> >- [% END %] >- <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrowernumber %]">Make payment</a> or >- <a href="/cgi-bin/koha/members/paycollect.pl?borrowernumber=[% borrowernumber %]">Pay all fines</a></li> >- [% END %] >+ [% IF ( charges ) %] >+ <li> >+ <span class="circ-hlt">Fees & Charges:</span> Patron has <a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrowernumber %]">Outstanding fees & charges[% IF ( chargesamount ) %] of [% chargesamount %][% END %]</a>. >+ [% IF ( charges_is_blocker ) %] >+ <span class="circ-hlt">Checkouts are BLOCKED because fine balance is OVER THE LIMIT.</span> >+ [% END %] >+ <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrowernumber %]">Make payment</a> or >+ <a href="/cgi-bin/koha/members/paycollect.pl?borrowernumber=[% borrowernumber %]">Pay all fines</a> >+ </li> >+ [% END %] > >- [% IF ( credits ) %] >- <li> >- <span class="circ-hlt">Credits:</span> Patron has a credit[% IF ( creditsamount ) %] of [% creditsamount %][% END %] >- </li> >- [% END %] >+ [% IF ( charges_guarantees ) %] >+ <li> >+ <span class="circ-hlt">Fees & Charges:</span> Patron's guarantees collectively owe [% chargesamount_guarantees %]. >+ [% IF ( charges_guarantees_is_blocker ) %] >+ <span class="circ-hlt">Checkouts are BLOCKED because fine balance is OVER THE LIMIT.</span> >+ [% END %] >+ </li> >+ [% END %] >+ >+ >+ [% IF ( credits ) %] >+ <li> >+ <span class="circ-hlt">Credits:</span> Patron has a credit[% IF ( creditsamount ) %] of [% creditsamount %][% END %] >+ </li> >+ [% END %] > > </ul> > </div> >-- >2.1.4
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 14577
:
47936
|
48632
|
48639
|
48759
|
48784
|
49036
|
49236
|
49237
|
49303
|
49304
|
50834
|
50835