From cf14d66f47f6f6c88f5f0319f9aeba4259177416 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 20 Nov 2025 09:15:22 +0000 Subject: [PATCH] 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 --- Koha/Patron/Debarments.pm | 4 ++-- .../data/mysql/atomicupdate/bug_39532.pl | 21 +++++++++++++++++++ .../en/mandatory/patron_restriction_types.yml | 5 +++++ misc/cronjobs/debar_patrons_with_fines.pl | 2 +- 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_39532.pl diff --git a/Koha/Patron/Debarments.pm b/Koha/Patron/Debarments.pm index 89e46a5fd66..7e77296cc3f 100644 --- a/Koha/Patron/Debarments.pm +++ b/Koha/Patron/Debarments.pm @@ -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 diff --git a/installer/data/mysql/atomicupdate/bug_39532.pl b/installer/data/mysql/atomicupdate/bug_39532.pl new file mode 100755 index 00000000000..126159830e7 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_39532.pl @@ -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'" ); + }, +}; diff --git a/installer/data/mysql/en/mandatory/patron_restriction_types.yml b/installer/data/mysql/en/mandatory/patron_restriction_types.yml index ba27b4261f2..8281688b68d 100644 --- a/installer/data/mysql/en/mandatory/patron_restriction_types.yml +++ b/installer/data/mysql/en/mandatory/patron_restriction_types.yml @@ -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 diff --git a/misc/cronjobs/debar_patrons_with_fines.pl b/misc/cronjobs/debar_patrons_with_fines.pl index b79c59245ae..3c02be0d934 100755 --- a/misc/cronjobs/debar_patrons_with_fines.pl +++ b/misc/cronjobs/debar_patrons_with_fines.pl @@ -110,7 +110,7 @@ while ( my $patron = $patrons->next ) { { borrowernumber => $patron->id, expiration => $expiration, - type => 'SUSPENSION', + type => 'FINES', comment => $message, } ); -- 2.51.1