Bug 39532: Use new FINES restriction type to avoid conflict with SUSPENSION

This patch introduces a new unique restriction type 'FINES' specifically
for the debar_patrons_with_fines.pl script to prevent duplicate
restrictions on repeated runs.

The original fix used 'SUSPENSION' but this conflicted with the
fine-in-days feature which uses SUSPENSION for time-limited restrictions
when overdue items are returned. Running the script would overwrite
those time-limited restrictions with indefinite ones.

Changes:
- Add new 'FINES' system restriction type to patron_restriction_types.yml
  for new installations
- Create database update to add 'FINES' type to existing installations
- Update debar_patrons_with_fines.pl to use 'FINES' instead of 'SUSPENSION'
- Update AddUniqueDebarment and DelUniqueDebarment POD documentation

This keeps SUSPENSION exclusively for the fine-in-days feature while
preventing duplicate restrictions from the fines script.

Test plan:
1. Run database update
2. Verify new FINES restriction type exists in restriction_types table
3. Run debar_patrons_with_fines.pl multiple times
4. Confirm only one FINES restriction per patron (no duplicates)
5. Verify SUSPENSION restrictions from fine-in-days are not affected
6. Run tests: prove t/db_dependent/Patron/Borrower_Debarments.t

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Martin Renvoize 2025-11-20 09:15:22 +00:00 committed by Lucas Gass
parent fdb7c9b405
commit d90333e911
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
4 changed files with 29 additions and 3 deletions

View File

@ -184,7 +184,7 @@ my $success = AddUniqueDebarment({
Creates a new debarment of the type defined by the key type.
If a unique debarment already exists of the given type, it is updated instead.
The current unique debarment types are OVERDUES, and SUSPENSION
The current unique debarment types are OVERDUES, SUSPENSION, and FINES
Required keys: borrowernumber, type
@ -232,7 +232,7 @@ my $success = _DelUniqueDebarment({
});
Deletes a unique debarment of the type defined by the key type.
The current unique debarment types are OVERDUES, and SUSPENSION
The current unique debarment types are OVERDUES, SUSPENSION, and FINES
Required keys: borrowernumber, type

View File

@ -0,0 +1,21 @@
use Modern::Perl;
use Koha::Installer::Output qw(say_success);
return {
bug_number => "39532",
description => "Add FINES restriction type for debar_patrons_with_fines.pl script",
up => sub {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};
# Add the new FINES restriction type
$dbh->do(
q{
INSERT IGNORE INTO restriction_types (code, display_text, is_system, is_default)
VALUES ('FINES', 'Fines suspension', 1, 0)
}
);
say_success( $out, "Added new system restriction type 'FINES'" );
},
};

View File

@ -49,3 +49,8 @@ tables:
display_text: "Notice failure suspension"
is_system: 1
is_default: 0
- code: "FINES"
display_text: "Fines suspension"
is_system: 1
is_default: 0

View File

@ -110,7 +110,7 @@ while ( my $patron = $patrons->next ) {
{
borrowernumber => $patron->id,
expiration => $expiration,
type => 'SUSPENSION',
type => 'FINES',
comment => $message,
}
);