Bugzilla – Attachment 46693 Details for
Bug 15582
Ability to block auto renewals if the OPACFineNoRenewals amount is reached
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15582: Ability to block auto renewals if the max outstanding balance is reached
Bug-15582-Ability-to-block-auto-renewals-if-the-ma.patch (text/plain), 5.81 KB, created by
Jonathan Druart
on 2016-01-15 12:54:45 UTC
(
hide
)
Description:
Bug 15582: Ability to block auto renewals if the max outstanding balance is reached
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-01-15 12:54:45 UTC
Size:
5.81 KB
patch
obsolete
>From 9b5f4f7f0dca0c6316b33ce8212bf778db9b6e60 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 14 Jan 2016 14:52:06 +0000 >Subject: [PATCH] Bug 15582: Ability to block auto renewals if the max > outstanding balance is reached > >If a patron owes more than the max outstanding balance (defined in the >maxoutstanding syspref), the issue won't be auto renewed anymore (driven >by the new pref MaxOutstandingBlockAutoRenew). > >Test plan: >Note: You will have to manually change data in your DB, make sure you >have access to the sql cli. >1/ Set the maxoutstanding to 5 (for instance) >2/ Set MaxOutstandingBlockAutoRenew to block >3/ Check an item out to a patron and mark is as an auto renewal >4/ Make sure the patron does not have any fees or charges. >5/ Execute the automatic renewals cronjob script (misc/cronjobs/automatic_renewals.pl) >Confirm that the issue has been renewed >6/ Create an invoice for this patron with a amount > maxoustanding (6 >for instance) >7/ Execute the automatic renewals cronjob script (misc/cronjobs/automatic_renewals.pl) >Confirm that the issue has not been renewed. >8/ Set MaxOutstandingBlockAutoRenew to allow >9/ Execute the automatic renewals cronjob script (misc/cronjobs/automatic_renewals.pl) >Confirm that the issue has been renewed > >Sponsored-by: University of the Arts London >--- > C4/Circulation.pm | 8 +++++ > .../intranet-tmpl/prog/en/modules/circ/renew.tt | 2 +- > t/db_dependent/Circulation.t | 42 +++++++++++++++++++++- > 3 files changed, 50 insertions(+), 2 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 80939a7..9efbe7e 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2842,6 +2842,14 @@ sub CanBookBeRenewed { > } > } > >+ if ( C4::Context->preference('MaxOutstandingBlockAutoRenew') ) { >+ my $maxoutstanding = C4::Context->preference("maxoutstanding"); >+ my ( $amountoutstanding ) = C4::Members::GetMemberAccountRecords($borrower->{borrowernumber}); >+ if ( $amountoutstanding and $amountoutstanding > $maxoutstanding ) { >+ return ( 0, "auto_too_much_oweing" ); >+ } >+ } >+ > if ( defined $issuingrule->{norenewalbefore} > and $issuingrule->{norenewalbefore} ne "" ) > { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt >index e741209..d671275 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt >@@ -89,7 +89,7 @@ > </form> > [% END %] > >- [% ELSIF error == "auto_renew" %] >+ [% ELSIF error == "auto_renew" or error == "auto_too_much_oweing" %] > > <p>[% item.biblio.title %] [% item.biblioitem.subtitle %] ( [% item.barcode %] ) has been scheduled for automatic renewal. </p> > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 3a6cfdf..8c307d9 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -29,7 +29,7 @@ use Koha::Database; > > use t::lib::TestBuilder; > >-use Test::More tests => 84; >+use Test::More tests => 85; > > BEGIN { > use_ok('C4::Circulation'); >@@ -555,6 +555,46 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); > }; > >+ subtest "auto_too_much_oweing | MaxOutstandingBlockAutoRenew" => sub { >+ plan tests => 6; >+ my $item_to_auto_renew = $builder->build({ >+ source => 'Item', >+ value => { >+ biblionumber => $biblionumber, >+ homebranch => $branch, >+ holdingbranch => $branch, >+ } >+ }); >+ >+ my $ten_days_before = dt_from_string->add( days => -10 ); >+ my $ten_days_ahead = dt_from_string->add( days => 10 ); >+ AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); >+ >+ $dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11'); >+ C4::Context->set_preference('MaxOutstandingBlockAutoRenew','1'); >+ C4::Context->set_preference('maxoutstanding','10'); >+ my $fines_amount = 5; >+ C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount ); >+ ( $renewokay, $error ) = >+ CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ is( $renewokay, 0, 'Do not renew, renewal is automatic' ); >+ is( $error, 'auto_renew', 'Can auto renew, maxoutstanding=10, patron has 5' ); >+ >+ C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount ); >+ ( $renewokay, $error ) = >+ CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ is( $renewokay, 0, 'Do not renew, renewal is automatic' ); >+ is( $error, 'auto_renew', 'Can auto renew, maxoutstanding=10, patron has 10' ); >+ >+ C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount ); >+ ( $renewokay, $error ) = >+ CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ is( $renewokay, 0, 'Do not renew, renewal is automatic' ); >+ is( $error, 'auto_too_much_oweing', 'Cannot auto renew, maxoutstanding=10, patron has 15' ); >+ >+ $dbh->do('DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber); >+ }; >+ > subtest "GetLatestAutoRenewDate" => sub { > plan tests => 3; > my $item_to_auto_renew = $builder->build( >-- >2.1.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 15582
:
46693
|
46694
|
47382
|
47383
|
47384
|
50333
|
50334
|
50678
|
50679
|
50726
|
53521
|
54347
|
56753
|
56754
|
56755
|
56978
|
56979
|
56980
|
57738
|
57739
|
57740
|
61077
|
61078
|
61079
|
61502
|
61503
|
61504
|
62881
|
62882
|
62883
|
62914
|
62915
|
62916