Browse Source

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>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
17.05.x
Jonathan Druart 9 years ago
committed by Kyle M Hall
parent
commit
d08a0bc685
  1. 8
      C4/Circulation.pm
  2. 2
      koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt
  3. 42
      t/db_dependent/Circulation.t

8
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

2
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>

42
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(

Loading…
Cancel
Save