From 556c66b6950644abb5744da37d553e6655d71bfb Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Tue, 16 Apr 2013 15:18:17 -0400 Subject: [PATCH] Acq: When building invoices from EDI messages, avoid bad data From some vendors, these EDI messages contain strings (useless ones, like just the name of the vendor) where we had been expecting numeric identifiers. Signed-off-by: Lebbeous Fogle-Weekley --- .../perlmods/lib/OpenILS/Application/Acq/EDI.pm | 23 +++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm index c46b504866..564f99c9ff 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm @@ -218,11 +218,24 @@ sub process_retrieval { $incoming->translate_time('NOW'); 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; + # Some vendors just put their name where there ought to be a number, + # and others put alphanumeric strings that mean nothing to us, so + # we sure won't match a PO in the system this way. We can pick + # up PO number later from the lineitems themselves if necessary. + + if ($msg_hash->{purchase_order} !~ /^\d+$/) { + $logger->warn("EDI: PO identifier is non-numeric. Continuing."); + # No "next" here; we'll process this and just not link to acqpo. + } else { + $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; + } } } -- 2.11.0