LP1952931 ASN support Ingram message format (PCI field)
authorBill Erickson <berickxx@gmail.com>
Mon, 12 Sep 2022 15:31:04 +0000 (11:31 -0400)
committerJane Sandberg <sandbergja@gmail.com>
Thu, 20 Oct 2022 13:56:20 +0000 (06:56 -0700)
Includes change to allow skipping line items that have no container
code, which happens with Ingram messages sometimes.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm
Open-ILS/src/perlmods/lib/OpenILS/Utils/EDIReader.pm

index c0af836..c024fc5 100644 (file)
@@ -1160,6 +1160,9 @@ sub create_shipment_notification_from_edi {
     my %containers = map {$_->{container_code} => 1} @{$msg_data->{lineitems}};
 
     for my $container_code (keys %containers) {
+
+        next unless $container_code;
+
         $logger->info("ACQ processing container: $container_code");
 
         my $eg_asn = Fieldmapper::acq::shipment_notification->new;
index 5433f9f..9193806 100644 (file)
@@ -34,6 +34,7 @@ my %edi_fields = (
     invoice_date    => qr/^DTM\+137:([^:]+)/, # This is really "messge date"
     # We don't retain a top-level container code -- they can repeat.
     _container_code => qr/^GIN\+BJ\+([^:]+)/,
+    _container_code_alt => qr/^PCI\+33E\+([^:]+)/,
     lading_number   => qr/^RFF\+BM:([^:]+)/
 );
 
@@ -131,8 +132,8 @@ sub read {
             # each container.  Instead of restructuring the messages to
             # be containers of lineitems, just tag each lineitem with
             # its container if one is specified.
-            $msg->{_current_li}->{container_code} = 
-                $msg->{_container_code} if $msg->{_container_code};
+            my $ccode = $msg->{_container_code} || $msg->{_container_code_alt};
+            $msg->{_current_li}->{container_code} = $ccode if $ccode;
 
             push(@{$msg->{lineitems}}, $msg->{_current_li});
         }