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.

Signed-off-by: Ray Delahunty <lib-systems@arts.ac.uk>
Signed-off-by: Hannah Dunne-Howrie <hdunne-howrie@westminster.gov.uk>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Martin Renvoize 2026-03-05 11:58:21 +00:00 committed by Pedro Amorim
parent a3889a7d90
commit e9a442e933
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 11 additions and 2 deletions

View File

@ -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, {