From: Lebbeous Fogle-Weekley Date: Tue, 16 Apr 2013 19:18:17 +0000 (-0400) Subject: Acq: When building invoices from EDI messages, avoid bad data X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=2eaa5523b0c48e48bed70de200b6f5233c24cf37;p=evergreen%2Fequinox.git 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 Signed-off-by: Ben Shum --- 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 be6968981f..43167670d4 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; + } } }