Bug 36506: Database update

Sponsored-by: The Main Library Alliance <https://www.mainlib.org/>
Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2025-08-06 19:14:56 +00:00 committed by Lucas Gass
parent 8d6391d3f0
commit 5ea97b7dd5
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 41 additions and 1 deletions

View File

@ -0,0 +1,41 @@
use Modern::Perl;
use Koha::Installer::Output qw(say_warning say_success say_info);
return {
bug_number => "36506",
description => "Move itemtype processing fees to the circulation rules",
up => sub {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};
if ( column_exists( 'itemtypes', 'processfee' ) ) {
my $existing_fees = $dbh->selectall_arrayref(
q|SELECT itemtype, processfee FROM itemtypes WHERE processfee IS NOT NULL|,
{ Slice => {} }
);
foreach my $existing_fee ( @{$existing_fees} ) {
my $itemtype = $existing_fee->{itemtype};
my $fee = $existing_fee->{processfee};
my $existing_rule = $dbh->selectall_arrayref(
q|SELECT * FROM circulation_rules WHERE branchcode IS NULL AND categorycode IS NULL
AND rule_name = "lost_item_processing_fee" AND itemtype = ?|, undef, $itemtype
);
if ( @{$existing_rule} ) {
say_warning( $out, "Existing default rule for $itemtype found, not moving value from itemtypes" );
next;
}
$dbh->do(
q{
INSERT INTO circulation_rules (branchcode, categorycode, itemtype, rule_name, rule_value )
VALUES ( NULL, NULL, ?, "lost_item_processing_fee", ? )
}, undef, $itemtype, $fee
);
}
say $out "Moved existing processing fees from itemtypes to circulation rules";
$dbh->do('ALTER TABLE itemtypes DROP COLUMN processfee');
say $out "Removed existing processfee column from itemtypes";
}
},
};

View File

@ -4300,7 +4300,6 @@ CREATE TABLE `itemtypes` (
`rentalcharge_hourly` decimal(28,6) DEFAULT NULL COMMENT 'the amount charged for each hour between checkout date and due date',
`rentalcharge_hourly_calendar` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'controls if the hourly rental fee is calculated directly or using finesCalendar',
`defaultreplacecost` decimal(28,6) DEFAULT NULL COMMENT 'default replacement cost',
`processfee` decimal(28,6) DEFAULT NULL COMMENT 'default text be recorded in the column note when the processing fee is applied',
`notforloan` tinyint(1) NOT NULL DEFAULT 0 COMMENT '1 if the item is not for loan, 0 if the item is available for loan',
`imageurl` varchar(200) DEFAULT NULL COMMENT 'URL for the item type icon',
`summary` mediumtext DEFAULT NULL COMMENT 'information from the summary field, may include HTML',