From 162aac506ed06e9e92fb1665cc0ef3ce383a0dff Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 5 Mar 2026 11:58:21 +0000 Subject: [PATCH] Bug 41996: Filter EDI errors on invoice page by invoicenumber The invoice page previously fetched all edifact_errors for the EDI message, causing errors from unrelated invoice lines to appear on every invoice generated from the same EDI file. For example, one unmatched ordernumber in a file with 20 invoices would flag all 20 as having errors. Now only errors where invoicenumber matches the current invoice (or where invoicenumber is NULL, indicating a message-level error) are displayed. --- acqui/invoice.pl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/acqui/invoice.pl b/acqui/invoice.pl index e42542a1fad..4b9650a048c 100755 --- a/acqui/invoice.pl +++ b/acqui/invoice.pl @@ -328,8 +328,17 @@ if ( $edifact_enabled && $details->{'message_id'} ) { if ($edifact_message) { - # Get any processing errors for this message using the relation accessor - my $errors = $edifact_message->errors; + # Get processing errors for this specific invoice, plus any message-level + # errors (invoicenumber IS NULL) that affect the whole EDI file. + # This avoids showing errors from other invoices in the same EDI file. + my $errors = $edifact_message->errors->search( + { + -or => [ + { invoicenumber => $details->{'invoicenumber'} }, + { invoicenumber => undef }, + ] + } + ); while ( my $error = $errors->next ) { push @$edifact_errors, { -- 2.53.0