Bug 23415: Add new syspref AllowFineOverrideRenewing

This patch adds new syspref AllowFineOverrideRenewing. It allows
staff to renew items for patrons whose fines are over limit set
in syspref FineNoRenewals. Otherwise renewing is prevented. If
renewing items is allowed staff is still required to confirm
if they really want to renew items for the patron.

To test:
1. Apply this patch, update database and restart all services.
2. Find patron with fines over limit set in FineNoRenewals and
renewable items.
=> Note that renewing is prevented with message "Cannot renew,
the patron has a debt of..."
3. Set syspref AllowFineOverrideRenewing as "Allow".
=> Note that items can now be renewed and renewing them displays
confirmation pop-up.

Sponsored-by: Koha-Suomi Oy
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-of-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
This commit is contained in:
Emmi Takkinen 2025-08-08 15:07:24 +03:00 committed by Martin Renvoize
parent 167a3da258
commit f2b7a744b8
No known key found for this signature in database
GPG Key ID: 2D86E0EAEC83711B
5 changed files with 38 additions and 9 deletions

View File

@ -3266,12 +3266,13 @@ sub CanBookBeRenewed {
$final_unseen_renewal = ( C4::Context->preference('UnseenRenewals')
&& $issuing_rule->{unseen_renewals_allowed} == ( $issue->unseen_renewals + 1 ) ) ? 1 : 0;
my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
my $finesblockrenewing = C4::Context->preference("FineNoRenewals");
my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
my $restricted = $patron->is_debarred;
my $hasoverdues = $patron->has_overdues;
my $balance = $patron->account->balance;
my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
my $finesblockrenewing = C4::Context->preference("FineNoRenewals");
my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
my $allowfineoverriderenewing = C4::Context->preference("AllowFineOverrideRenewing");
my $restricted = $patron->is_debarred;
my $hasoverdues = $patron->has_overdues;
my $balance = $patron->account->balance;
if ( $restricted and $restrictionblockrenewing ) {
return ( 0, 'restriction' );
@ -3279,7 +3280,7 @@ sub CanBookBeRenewed {
|| ( $issue->is_overdue and $overduesblockrenewing eq 'blockitem' ) )
{
return ( 0, 'overdue' );
} elsif ( $finesblockrenewing && $balance > $finesblockrenewing ) {
} elsif ( $finesblockrenewing && $balance > $finesblockrenewing && !$allowfineoverriderenewing ) {
return ( 0, 'too_much_oweing');
}

View File

@ -2,17 +2,26 @@ use Modern::Perl;
return {
bug_number => "23415",
description => "Rename OPACFineNoRenewals",
description => "Rename OPACFineNoRenewals and add new syspref AllowFineOverrideRenewing",
up => sub {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};
$dbh->do(
q{
UPDATE systempreferences SET variable = "FineNoRenewals", explanation = "Fine limit above which user or staff cannot renew items" WHERE variable = "OPACFineNoRenewals";
UPDATE IGNORE systempreferences SET variable = "FineNoRenewals", explanation = "Fine limit above which user or staff cannot renew items" WHERE variable = "OPACFineNoRenewals";
}
);
say $out "Updated system preference 'OPACFineNoRenewals'";
$dbh->do(
q{
INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type)
VALUES ('AllowFineOverrideRenewing', '0', '0', 'If on, staff will be able to renew items for patrons with fines greater than FineNoRenewals.','YesNo')
}
);
say $out "Added new system preference 'AllowFineOverrideRenewing'";
},
};

View File

@ -30,6 +30,7 @@ INSERT INTO systempreferences ( `variable`, `value` ) VALUES
('AllowAllMessageDeletion','0'),
('AllowCheckoutNotes', '0'),
('AllowFineOverride','0'),
('AllowFineOverrideRenewing','0'),
('AllowHoldDateInFuture','0'),
('AllowHoldItemTypeSelection','0'),
('AllowHoldPolicyOverride','0'),

View File

@ -263,6 +263,12 @@ Circulation:
1: Allow
0: "Don't allow"
- staff to manually override and check out items to patrons who have more in fines than set in the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=noissuescharge">noissuescharge</a> system preference.
-
- pref: AllowFineOverrideRenewing
choices:
1: Allow
0: "Don't allow"
- staff to manually override and renew items for patrons who have more in fines than set in the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=FineNoRenewals">FineNoRenewals</a> system preference.
-
- pref: AutomaticItemReturn
choices:

View File

@ -501,6 +501,18 @@ function LoadIssuesTable() {
__("Renewal denied by syspref") +
"</span>";
span_style = "display: none";
span_class = "renewals-allowed";
} else if (
oObj.can_renew_error == "too_much_oweing"
) {
msg +=
"<span class='renewals-disabled'>" +
__(
"Cannot renew, he patron has a debt of " + parseFloat(oObj.fine).format_price()
) +
"</span>";
span_style = "display: none";
span_class = "renewals-allowed";
} else {