From 2e92b234fde2632faff661240b169b6bc22841d8 Mon Sep 17 00:00:00 2001 From: Jacob O'Mara Date: Mon, 30 Jun 2025 12:05:35 +0100 Subject: [PATCH] Bug 4858: Add patron category column and debit type for print notice charging - Add print_notice_charge patron category column to set charge amount - Add PRINT_NOTICE debit type for billing system integration - Create atomic update for existing installations This provides the foundation for implementing print notice charging to recover postage and processing costs. To test: prove -vv t/db_dependent/Koha/Account/PrintNoticeCharges.t prove -vv t/db_dependent/Koha/Patron/Category.t prove -vv t/db_dependent/PrintNoticeCharging_EndToEnd.t Navigate to patron categories, and check that you can set a print notice charge amount Check that in messaging preferences, you can amend the preferences of print notices for both patrons and patron categories Check that in messaging preferences on the opac, you will receive a warning if print notice charging is enabled (set to anything other than 0 for this patron category) and a recommendation to set up email to avoid charges. Sponsored-by: OpenFifth Signed-off-by: Jackie Usher --- .../bug_4858-print-notice-charge.pl | 58 +++++++++++++++++++ .../en/mandatory/account_debit_types.yml | 7 +++ installer/data/mysql/kohastructure.sql | 1 + 3 files changed, 66 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_4858-print-notice-charge.pl diff --git a/installer/data/mysql/atomicupdate/bug_4858-print-notice-charge.pl b/installer/data/mysql/atomicupdate/bug_4858-print-notice-charge.pl new file mode 100755 index 00000000000..770bb5e5fa5 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_4858-print-notice-charge.pl @@ -0,0 +1,58 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "4858", + description => "Add print notice charge to patron categories and setup print transports", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Add print_notice_charge column to categories table + $dbh->do( + q{ALTER TABLE categories + ADD COLUMN print_notice_charge decimal(28,6) DEFAULT 0.00 + COMMENT 'charge for print notices (0.00 = disabled)' + AFTER reservefee} + ); + + # Add PRINT_NOTICE debit type + $dbh->do( + q{ + INSERT IGNORE INTO account_debit_types (code, description, can_be_invoiced, can_be_sold, default_amount, is_system, restricts_checkouts) + VALUES ('PRINT_NOTICE', 'Print notice charge', 0, 0, 0.50, 1, 0) + } + ); + + # Add comprehensive print transport entries for all standard notice types + # This enables print checkboxes to appear in messaging preferences + $dbh->do( + q{ + INSERT IGNORE INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code, branchcode) + VALUES + (1, 'print', 0, 'circulation', 'DUE', ''), + (1, 'print', 1, 'circulation', 'DUEDGST', ''), + (2, 'print', 0, 'circulation', 'PREDUE', ''), + (2, 'print', 1, 'circulation', 'PREDUEDGST', ''), + (4, 'print', 0, 'reserves', 'HOLD', ''), + (4, 'print', 1, 'reserves', 'HOLDDGST', ''), + (5, 'print', 0, 'circulation', 'CHECKIN', ''), + (6, 'print', 0, 'circulation', 'CHECKOUT', ''), + (7, 'print', 0, 'ill', 'ILL_PICKUP_READY', ''), + (8, 'print', 0, 'ill', 'ILL_REQUEST_UNAVAIL', ''), + (9, 'print', 0, 'circulation', 'AUTO_RENEWALS', ''), + (9, 'print', 1, 'circulation', 'AUTO_RENEWALS_DGST', ''), + (10, 'print', 0, 'circulation', 'HOLD_REMINDER', ''), + (11, 'print', 0, 'ill', 'ILL_REQUEST_UPDATE', ''), + (12, 'print', 0, 'circulation', 'PICKUP_RECALLED_ITEM', ''), + (13, 'print', 0, 'circulation', 'RETURN_RECALLED_ITEM', ''), + (14, 'print', 0, 'members', 'MEMBERSHIP_EXPIRY', '') + } + ); + + say_success( + $out, + "Added print_notice_charge column to categories table, debit type, and comprehensive print transport entries for print notice charging" + ); + }, +}; diff --git a/installer/data/mysql/en/mandatory/account_debit_types.yml b/installer/data/mysql/en/mandatory/account_debit_types.yml index 749d962d112..bad86bdf95e 100644 --- a/installer/data/mysql/en/mandatory/account_debit_types.yml +++ b/installer/data/mysql/en/mandatory/account_debit_types.yml @@ -74,6 +74,13 @@ tables: default_amount: ~ is_system: "1" + - code: "PRINT_NOTICE" + description: "Print notice charge" + can_be_invoiced: "0" + can_be_sold: "0" + default_amount: ~ + is_system: "1" + - code: "PROCESSING" description: "Lost item processing fee" can_be_invoiced: "0" diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index a29c7e49292..1d5184dd03d 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1810,6 +1810,7 @@ CREATE TABLE `categories` ( `dateofbirthrequired` tinyint(1) DEFAULT NULL COMMENT 'the minimum age required for the patron category', `enrolmentfee` decimal(28,6) DEFAULT NULL COMMENT 'enrollment fee for the patron', `overduenoticerequired` tinyint(1) DEFAULT NULL COMMENT 'are overdue notices sent to this patron category (1 for yes, 0 for no)', + `print_notice_charge` decimal(28,6) DEFAULT 0.00 COMMENT 'charge for print notices (0.00 = disabled)', `hidelostitems` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'are lost items shown to this category (1 for yes, 0 for no)', `category_type` varchar(1) NOT NULL DEFAULT 'A' COMMENT 'type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)', `BlockExpiredPatronOpacActions` varchar(128) NOT NULL DEFAULT 'follow_syspref_BlockExpiredPatronOpacActions' COMMENT 'specific actions expired patrons of this category are blocked from performing or if the BlockExpiredPatronOpacActions system preference is to be followed', -- 2.53.0