Bug 43072: (Bug 41267 follow-up) Add default rules when not set

Bug 41267 defined the new rule, but didn't set the default.

For consistencies sake we should create these in the DB

To test:
1 - Create 'Default holds and bookings policies by item type' for two itemtypes
    Set 'Fill other record level holds on record at checkout' to yes for one and no for the other
2 - Apply this patch
3 - updatedatabase
4 - Verify the rules are not altered
5 - Chekc the DB:
    SELECT * FROM circulation_rules WHERE branchcode IS NULL and categorycode IS NULL;
6 - Note the number of rules/ids
7 - Run the DB update and confirm nothing changes
8 - DELETE from circulation_rules WHERE rule_name='fill_other_biblio_holds_policy';
9 - Run the DB update
10 - Confirm rules are replaced, both as yes
11 - Delete a single one of the rules now:
    DELETE from circulation_rules WHERE rule_name='fill_other_biblio_holds_policy' AND id=#;
12 - Run the DB update
13 - Confirm only that rule is replaced
14 - DELETE from circulation_rules WHERE branchcode IS NULL and categorycode IS NULL;
15 - Run the DB update
16 - No new rules are created

 follo#	Koha/.Patrons.pm.swp

Signed-off-by: Lawrence O'Regan-Lloyd <loreganlloyd@clamsnet.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Nick Clemens 2026-08-02 19:40:46 +00:00 committed by Pedro Amorim
parent 0c86df4755
commit 241abf5545
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,26 @@
use Modern::Perl;
use Koha::Installer::Output qw(say_warning say_success say_info);
return {
bug_number => "BUG_NUMBER",
description => "A single line description",
up => sub {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};
# Do you stuffs here
$dbh->do(
q{
INSERT INTO circulation_rules (itemtype,rule_name,rule_value)
SELECT itemtype,'fill_other_biblio_holds_policy',1 FROM circulation_rules
WHERE branchcode IS NULL AND categorycode IS NULL and rule_name='holdallowed' AND
itemtype NOT IN (
SELECT itemtype FROM circulation_rules
WHERE branchcode IS NULL AND categorycode IS NULL and rule_name='fill_other_biblio_holds_policy'
)
}
);
say $out "Set default fill_other_biblio_holds_policy rule for itemtypes with other policies set";
},
};