From ef592384e57e5abacad565f3b555c5954d53e44a Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 5 Mar 2026 11:30:01 +0000 Subject: [PATCH] Bug 41996: Add invoicenumber column to edifact_errors table Adds an optional invoicenumber column to edifact_errors so that errors generated during invoice processing can be associated with the specific invoice they relate to, rather than only the EDI message as a whole. Message-level errors (e.g. unmatched vendor EAN) leave invoicenumber NULL, indicating they apply to the whole file. --- .../data/mysql/atomicupdate/bug_41996.pl | 32 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 2 ++ 2 files changed, 34 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_41996.pl diff --git a/installer/data/mysql/atomicupdate/bug_41996.pl b/installer/data/mysql/atomicupdate/bug_41996.pl new file mode 100644 index 00000000000..7cf905fdd37 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_41996.pl @@ -0,0 +1,32 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "41996", + description => "Add invoicenumber column to edifact_errors for per-invoice error filtering", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + if ( !column_exists( 'edifact_errors', 'invoicenumber' ) ) { + $dbh->do( + q{ + ALTER TABLE edifact_errors + ADD COLUMN invoicenumber varchar(48) DEFAULT NULL + AFTER message_id + } + ); + say_success( $out, "Added invoicenumber column to edifact_errors" ); + + $dbh->do( + q{ + ALTER TABLE edifact_errors + ADD INDEX message_id_invoicenumber (message_id, invoicenumber) + } + ); + say_success( $out, "Added index message_id_invoicenumber to edifact_errors" ); + } else { + say_info( $out, "Column invoicenumber already exists in edifact_errors" ); + } + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index a29c7e49292..406f171ad79 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2915,11 +2915,13 @@ DROP TABLE IF EXISTS `edifact_errors`; CREATE TABLE `edifact_errors` ( `id` int(11) NOT NULL AUTO_INCREMENT, `message_id` int(11) NOT NULL, + `invoicenumber` varchar(48) DEFAULT NULL, `date` date DEFAULT NULL, `section` mediumtext DEFAULT NULL, `details` mediumtext DEFAULT NULL, PRIMARY KEY (`id`), KEY `messageid` (`message_id`), + KEY `message_id_invoicenumber` (`message_id`, `invoicenumber`), CONSTRAINT `emfk_message` FOREIGN KEY (`message_id`) REFERENCES `edifact_messages` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- 2.53.0