LP#1713138 EDI buyer codes from RFF+API
authorBill Erickson <berickxx@gmail.com>
Fri, 25 Aug 2017 19:46:31 +0000 (15:46 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Thu, 15 Oct 2020 19:03:37 +0000 (15:03 -0400)
Support extracting buyer code (AKE edi_account.vendcode) values directly
from the EDI RFF+API field.  This provides better matching to
edi_accounts based on vendcode values for inbound EDI messages.

The code will still fall back to extracting vendcodes appended to the SAN,
when no RFF+API is present.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>

Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm
Open-ILS/src/perlmods/lib/OpenILS/Utils/EDIReader.pm

index 49feb96..5557027 100644 (file)
@@ -521,6 +521,8 @@ sub nice_string {
 sub process_message_buyer {
     my ($class, $e, $msg_hash, $message,  $log_prefix, $eg_inv) = @_;
 
+    my $vendcode = $msg_hash->{buyer_code};
+
     # some vendors encode the account number as the SAN.
     # starting with the san value, then the account value, 
     # treat each as a san, then an acct number until the first success
@@ -528,8 +530,9 @@ sub process_message_buyer {
         next unless $buyer;
 
         # some vendors encode the SAN as "$SAN $vendcode"
-        my $vendcode;
-        ($buyer, $vendcode) = $buyer =~ /(\S+)\s*(\S+)?$/;
+        if (!$vendcode) {
+            ($buyer, $vendcode) = $buyer =~ /(\S+)\s*(\S+)?$/;
+        }
 
         my $addr = $e->search_actor_org_address(
             {valid => "t", san => $buyer})->[0];
index 4c17d34..7b91722 100644 (file)
@@ -23,6 +23,7 @@ my %edi_fields = (
     message_type    => qr/^UNH\+[A-z0-9]+\+(\S{6})/,
     buyer_san       => qr/^NAD\+BY\+([^:]+)::31B/,
     buyer_acct      => qr/^NAD\+BY\+([^:]+)::91/,
+    buyer_code      => qr/^RFF\+API:(\S+)/,
     vendor_san      => qr/^NAD\+SU\+([^:]+)::31B/,
     vendor_acct     => qr/^NAD\+SU\+([^:]+)::91/,
     purchase_order  => qr/^RFF\+ON:(\S+)/,