Bug 23415: (follow-up) Respect OPACFineNoRenewalsIncludeCredits preference
This patch fixes a regression introduced in the previous commits where we changed FineNoRenewals checking to use non_issues_charges instead of balance. While this change was correct for focusing on blocking charges, we inadvertently removed the handling of the OPACFineNoRenewalsIncludeCredits preference. The OPACFineNoRenewalsIncludeCredits preference controls whether unapplied account credits should be included when calculating if a patron exceeds the FineNoRenewals threshold. When this preference is enabled, the patron's net balance (debits minus credits) should be used instead of just their outstanding debits. This patch restores the preference handling for both: 1. Manual renewals in CanBookBeRenewed() 2. Auto renewals in _CanBookBeAutoRenewed() When OPACFineNoRenewalsIncludeCredits = 1: Use balance (all charges net of credits) When OPACFineNoRenewalsIncludeCredits = 0: Use non_issues_charges (only blocking charges, no credits) This ensures that patrons with sufficient credits can renew their items when the preference is enabled, while still maintaining the focus on non-issuing charges introduced in the previous commits. Test plan: 1. Run prove t/db_dependent/Circulation.t 2. All tests should pass, particularly the "auto_too_much_owing | OPACFineNoRenewalsBlockAutoRenew & OPACFineNoRenewalsIncludeCredits" subtest Sponsored-by: OpenFifth <https://openfifth.co.uk/> Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
This commit is contained in:
parent
8b35dfcc9d
commit
06fd7ed7e4
|
|
@ -3274,6 +3274,10 @@ sub CanBookBeRenewed {
|
|||
my $account = $patron->account;
|
||||
my $balance = $account->balance;
|
||||
my $non_issues_charges = $account->non_issues_charges;
|
||||
my $amountoutstanding_for_renewal =
|
||||
C4::Context->preference("OPACFineNoRenewalsIncludeCredits")
|
||||
? $balance
|
||||
: $non_issues_charges;
|
||||
|
||||
if ( $restricted and $restrictionblockrenewing ) {
|
||||
return ( 0, 'restriction' );
|
||||
|
|
@ -3281,7 +3285,7 @@ sub CanBookBeRenewed {
|
|||
|| ( $issue->is_overdue and $overduesblockrenewing eq 'blockitem' ) )
|
||||
{
|
||||
return ( 0, 'overdue' );
|
||||
} elsif ( $finesblockrenewing && $non_issues_charges > $finesblockrenewing ) {
|
||||
} elsif ( $finesblockrenewing && $amountoutstanding_for_renewal > $finesblockrenewing ) {
|
||||
return ( 0, 'too_much_owing' );
|
||||
}
|
||||
|
||||
|
|
@ -5049,10 +5053,13 @@ sub _CanBookBeAutoRenewed {
|
|||
}
|
||||
|
||||
if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) {
|
||||
my $fine_no_renewals = C4::Context->preference("FineNoRenewals");
|
||||
my $account = $patron->account;
|
||||
my $non_issues_charges = $account->non_issues_charges;
|
||||
if ( $non_issues_charges and $non_issues_charges > $fine_no_renewals ) {
|
||||
my $fine_no_renewals = C4::Context->preference("FineNoRenewals");
|
||||
my $account = $patron->account;
|
||||
my $amountoutstanding =
|
||||
C4::Context->preference("OPACFineNoRenewalsIncludeCredits")
|
||||
? $account->balance
|
||||
: $account->non_issues_charges;
|
||||
if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
|
||||
return "auto_too_much_owing";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue