From 482dc947dcce4041cfb9ab7d232b006cbc884e6f Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 19 Dec 2024 16:56:29 +0000 Subject: [PATCH] Bug 38689: Record errors on invoice processing --- Koha/EDI.pm | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Koha/EDI.pm b/Koha/EDI.pm index 499acedad0a..11e562ca5d7 100644 --- a/Koha/EDI.pm +++ b/Koha/EDI.pm @@ -290,7 +290,8 @@ sub process_invoice { )->single; } if ( !$vendor_acct ) { - carp "Cannot find vendor with ean $vendor_ean for invoice $invoicenumber in ".$invoice_message->filename; + $invoice_message->add_to_edifact_errors({ details => "Cannot find vendor with ean $vendor_ean" }); + $logger->error("Cannot find vendor with ean $vendor_ean for invoice $invoicenumber in ".$invoice_message->filename); next; } $invoice_message->edi_acct( $vendor_acct->id ); @@ -313,6 +314,12 @@ sub process_invoice { foreach my $line ( @{$lines} ) { my $ordernumber = $line->ordernumber; if ( !$ordernumber ) { + $invoice_message->add_to_edifact_errors( + { + section => $line->line_item_number, + details => "Message missing ordernumber" + } + ); $logger->error("Skipping invoice line, no associated ordernumber"); next; } @@ -320,12 +327,24 @@ sub process_invoice { # ModReceiveOrder does not validate that $ordernumber exists validate here my $order = $schema->resultset('Aqorder')->find($ordernumber); if ( !$order ) { + $invoice_message->add_to_edifact_errors( + { + section => $line->line_item_number, + details => "Koha order $ordernumber missing" + } + ); $logger->error("Skipping invoice line, no order found for $ordernumber, invoice:$invoicenumber"); next; } my $bib = $order->biblionumber; if ( !$bib ) { + $invoice_message->add_to_edifact_errors( + { + section => $line->line_item_number, + details => "Koha biblio missing" + } + ); $logger->error( "Skipping invoice line, no bibliographic record found for $ordernumber, invoice:$invoicenumber" ); -- 2.47.1