From c009c3fa81d6c87aede3bd3de1fd119c6516d319 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Fri, 13 Nov 2020 13:46:13 +0000 Subject: [PATCH] Bug 27017: Code more defensively in process_invoice This patch adds a check for ordernumber precence in the EDI Invoice message lines and skips process if one is not found. We log the failure as a trace log to allow administrators the oportunity to track down the issue further. We also add a trace log to entries to show which bib the invoice line is receipting to. Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- Koha/EDI.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Koha/EDI.pm b/Koha/EDI.pm index 4778a1d7f7..9fc92a48d7 100644 --- a/Koha/EDI.pm +++ b/Koha/EDI.pm @@ -312,12 +312,22 @@ sub process_invoice { foreach my $line ( @{$lines} ) { my $ordernumber = $line->ordernumber; + if (!$ordernumber ) { + $logger->trace( "Skipping invoice line, no associated ordernumber" ); + next; + } + $logger->trace( "Receipting order:$ordernumber Qty: ", $line->quantity ); my $order = $schema->resultset('Aqorder')->find($ordernumber); + if ($order->biblionumber->biblionumber) { + my $b = $order->biblionumber->biblionumber; + my $id = $line->item_number_id; + $logger->trace("Updating bib:$b id:$id"); + } - # ModReceiveOrder does not validate that $ordernumber exists validate here + # ModReceiveOrder does not validate that $ordernumber exists validate here if ($order) { # check suggestions -- 2.39.5