From b1486a8cc36f3d798b9b323ef0c4baf3fcf60310 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 3 Mar 2026 07:47:55 +0000 Subject: [PATCH] Bug 40932: Add received column to aqorders_items and system preferences Adds aqorders_items.received (datetime, nullable) to track when an item was first physically received via circulation check-in. Adds system preferences: - AutoCloseInvoicesOnCheckin (YesNo, default off) - AutoCloseInvoiceAlertDays (Integer, default 14) Sponsored-by: Westminster City Council Sponsored-by: Royal Borough of Kensington and Chelsea Sponsored-by: OpenFifth --- .../data/mysql/atomicupdate/bug_40932.pl | 34 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 1 + installer/data/mysql/mandatory/sysprefs.sql | 2 ++ 3 files changed, 37 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_40932.pl diff --git a/installer/data/mysql/atomicupdate/bug_40932.pl b/installer/data/mysql/atomicupdate/bug_40932.pl new file mode 100755 index 00000000000..27fb173ea76 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_40932.pl @@ -0,0 +1,34 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "40932", + description => "Add automatic invoice closing on physical item receipt", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + if ( !column_exists( 'aqorders_items', 'received' ) ) { + $dbh->do( + q{ + ALTER TABLE aqorders_items + ADD COLUMN `received` datetime DEFAULT NULL + COMMENT 'Datetime the item was first physically received via circulation check-in' + } + ); + say_success( $out, "Added column 'aqorders_items.received'" ); + } + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) + VALUES + ('AutoCloseInvoicesOnCheckin', '0', NULL, + 'Automatically close acquisitions invoices when all their items have been physically checked in at circulation', 'YesNo'), + ('AutoCloseInvoiceAlertDays', '14', NULL, + 'Show staff alert for open invoices with outstanding items older than this many days. 0 = disabled.', 'Integer') + } + ); + say_success( $out, "Added system preferences 'AutoCloseInvoicesOnCheckin' and 'AutoCloseInvoiceAlertDays'" ); + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index a29c7e49292..4e789c74b80 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -833,6 +833,7 @@ CREATE TABLE `aqorders_items` ( `ordernumber` int(11) NOT NULL COMMENT 'the order this item is attached to (aqorders.ordernumber)', `itemnumber` int(11) NOT NULL COMMENT 'the item number for this item (items.itemnumber)', `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'the date and time this order item was last touched', + `received` datetime DEFAULT NULL COMMENT 'Datetime the item was first physically received via circulation check-in', PRIMARY KEY (`itemnumber`), KEY `ordernumber` (`ordernumber`), CONSTRAINT `aqorders_items_ibfk_1` FOREIGN KEY (`ordernumber`) REFERENCES `aqorders` (`ordernumber`) ON DELETE CASCADE ON UPDATE CASCADE diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 585d7a5d8d8..4b8afa218ce 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -91,6 +91,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('autoBarcode','OFF','incremental|annual|hbyymmincr|EAN13|OFF','Used to autogenerate a barcode: incremental will be of the form 1, 2, 3; annual of the form 2007-0001, 2007-0002; hbyymmincr of the form HB08010001 where HB=Home Branch','Choice'), ('AutoClaimReturnStatusOnCheckin','',NULL,'When in use this system preference will automatically resolve the claim return and will update the lost authorized value upon check in.','Free'), ('AutoClaimReturnStatusOnCheckout','',NULL,'When in use this system preference will automatically resolve the claim return and will update the lost authorized value upon check out.','Free'), +('AutoCloseInvoiceAlertDays','14',NULL,'Show a staff alert for open invoices with items not yet physically received for more than this many days (0 to disable).','Integer'), +('AutoCloseInvoicesOnCheckin','0',NULL,'If enabled, automatically close acquisition invoices when all items on non-cancelled order lines have been physically checked in at circulation.','YesNo'), ('autoControlNumber','OFF','biblionumber|OFF','Used to autogenerate a Control Number: biblionumber will be as biblionumber, OFF will leave the field as it is;','Choice'), ('AutoCreateAuthorities','0',NULL,'Automatically create authorities that do not exist when cataloging records.','YesNo'), ('AutoCreditNumber', '', NULL, 'Automatically generate a number for account credits', 'Choice'), -- 2.53.0