View | Details | Raw Unified | Return to bug 36506
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_36506.pl (+41 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_success say_info);
3
4
return {
5
    bug_number  => "36506",
6
    description => "Move itemtype processing fees to the circulation rules",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        if ( column_exists( 'itemtypes', 'processfee' ) ) {
12
            my $existing_fees = $dbh->selectall_arrayref(
13
                q|SELECT itemtype, processfee FROM itemtypes WHERE processfee IS NOT NULL|,
14
                { Slice => {} }
15
            );
16
            foreach my $existing_fee ( @{$existing_fees} ) {
17
                my $itemtype      = $existing_fee->{itemtype};
18
                my $fee           = $existing_fee->{processfee};
19
                my $existing_rule = $dbh->selectall_arrayref(
20
                    q|SELECT * FROM circulation_rules WHERE branchcode IS NULL AND categorycode IS NULL
21
                    AND rule_name = "lost_item_processing_fee" AND itemtype = ?|, undef, $itemtype
22
                );
23
                if ( @{$existing_rule} ) {
24
                    say_warning( $out, "Existing default rule for $itemtype found, not moving value from itemtypes" );
25
                    next;
26
                }
27
                $dbh->do(
28
                    q{
29
                    INSERT INTO circulation_rules (branchcode, categorycode, itemtype, rule_name, rule_value )
30
                    VALUES ( NULL, NULL, ?, "lost_item_processing_fee", ? )
31
                }, undef, $itemtype, $fee
32
                );
33
            }
34
            say $out "Moved existing processing fees from itemtypes to circulation rules";
35
36
            $dbh->do('ALTER TABLE itemtypes DROP COLUMN processfee');
37
            say $out "Removed existing processfee column from itemtypes";
38
        }
39
40
    },
41
};
(-)a/installer/data/mysql/kohastructure.sql (-2 lines)
Lines 4233-4239 CREATE TABLE `itemtypes` ( Link Here
4233
  `rentalcharge_hourly` decimal(28,6) DEFAULT NULL COMMENT 'the amount charged for each hour between checkout date and due date',
4233
  `rentalcharge_hourly` decimal(28,6) DEFAULT NULL COMMENT 'the amount charged for each hour between checkout date and due date',
4234
  `rentalcharge_hourly_calendar` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'controls if the hourly rental fee is calculated directly or using finesCalendar',
4234
  `rentalcharge_hourly_calendar` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'controls if the hourly rental fee is calculated directly or using finesCalendar',
4235
  `defaultreplacecost` decimal(28,6) DEFAULT NULL COMMENT 'default replacement cost',
4235
  `defaultreplacecost` decimal(28,6) DEFAULT NULL COMMENT 'default replacement cost',
4236
  `processfee` decimal(28,6) DEFAULT NULL COMMENT 'default text be recorded in the column note when the processing fee is applied',
4237
  `notforloan` tinyint(1) NOT NULL DEFAULT 0 COMMENT '1 if the item is not for loan, 0 if the item is available for loan',
4236
  `notforloan` tinyint(1) NOT NULL DEFAULT 0 COMMENT '1 if the item is not for loan, 0 if the item is available for loan',
4238
  `imageurl` varchar(200) DEFAULT NULL COMMENT 'URL for the item type icon',
4237
  `imageurl` varchar(200) DEFAULT NULL COMMENT 'URL for the item type icon',
4239
  `summary` mediumtext DEFAULT NULL COMMENT 'information from the summary field, may include HTML',
4238
  `summary` mediumtext DEFAULT NULL COMMENT 'information from the summary field, may include HTML',
4240
- 

Return to bug 36506