Bugzilla – Attachment 62882 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 OPACFineNoRenewals is reached
Bug-15582-Ability-to-block-auto-renewals-if-OPACFi.patch (text/plain), 5.92 KB, created by
Jonathan Druart
on 2017-04-28 20:34:22 UTC
(
hide
)
Description:
Bug 15582: Ability to block auto renewals if OPACFineNoRenewals is reached
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-04-28 20:34:22 UTC
Size:
5.92 KB
patch
obsolete
>From a8f59c4ca64bd010e7ff6ee63e33c9cc8b2625bc 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 > OPACFineNoRenewals is reached > >If a patron owes more than the OPACFineNoRenewals value, the issue won't >be auto renewed anymore (driven by the new pref OPACFineNoRenewalsBlockAutoRenew). > >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 OPACFineNoRenewals to 5 (for instance) >2/ Set OPACFineNoRenewalsBlockAutoRenew 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 > OPACFineNoRenewals (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 OPACFineNoRenewalsBlockAutoRenew 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 >Signed-off-by: Jonathan Field <jonathan.field@ptfs-europe.com> >Signed-off-by: Janet McGowan <janet.mcgowan@ptfs-europe.com> >--- > 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 174b3ac..b7d08ad 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2774,6 +2774,14 @@ sub CanBookBeRenewed { > return ( 0, "auto_too_late" ); > } > } >+ >+ if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) { >+ my $fine_no_renewals = C4::Context->preference("OPACFineNoRenewals"); >+ my ( $amountoutstanding ) = C4::Members::GetMemberAccountRecords($borrower->{borrowernumber}); >+ if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) { >+ return ( 0, "auto_too_much_oweing" ); >+ } >+ } > } > > if ( defined $issuing_rule->norenewalbefore >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 b63d7a4..dbcc096 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt >@@ -90,7 +90,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 1263122..9a5b821 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 94; >+use Test::More tests => 95; > > use DateTime; > >@@ -637,6 +637,46 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); > }; > >+ subtest "auto_too_much_oweing | OPACFineNoRenewalsBlockAutoRenew" => 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('OPACFineNoRenewalsBlockAutoRenew','1'); >+ C4::Context->set_preference('OPACFineNoRenewals','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, OPACFineNoRenewals=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, OPACFineNoRenewals=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, OPACFineNoRenewals=10, patron has 15' ); >+ >+ $dbh->do('DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber); >+ }; >+ > subtest "GetLatestAutoRenewDate" => sub { > plan tests => 5; > my $item_to_auto_renew = $builder->build( >-- >2.9.3
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