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:
parent
8d6391d3f0
commit
5ea97b7dd5
|
|
@ -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";
|
||||
}
|
||||
|
||||
},
|
||||
};
|
||||
|
|
@ -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',
|
||||
|
|
|
|||
Loading…
Reference in New Issue