EDI: protect against invalid order response
authorBill Erickson <berick@esilibrary.com>
Mon, 3 Dec 2012 14:20:29 +0000 (09:20 -0500)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 14 Jan 2013 22:10:30 +0000 (17:10 -0500)
Do not attempt to createI EDI messages for order responses which
reference nonexistent purchase orders, since it results in
transaction commit errors on invalid foreign keys, preventing
subsequent EDI files from getting processed.  Instead, log it
and skip it.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm

index f41d29c..1ed4697 100644 (file)
@@ -184,6 +184,10 @@ sub process_retrieval {
         if ($msg_hash->{purchase_order}) {
             $logger->info("EDI: processing message for PO " . $msg_hash->{purchase_order});
             $incoming->purchase_order($msg_hash->{purchase_order});
+            unless ($e->retrieve_acq_purchase_order($incoming->purchase_order)) {
+                $logger->warn("EDI: received order response for nonexistent PO.  Skipping...");
+                next;
+            }
         }
 
         $e->xact_begin;