From 23e58c8c2852a55eb2583a7dd132257e80dbeb1a Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 25 Aug 2017 15:46:31 -0400 Subject: [PATCH] LP#1713138 EDI buyer codes from RFF+API 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 Signed-off-by: Chris Sharp --- Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm | 7 +++++-- Open-ILS/src/perlmods/lib/OpenILS/Utils/EDIReader.pm | 1 + 2 files changed, 6 insertions(+), 2 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 49feb96098..55570272dd 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm @@ -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]; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/EDIReader.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/EDIReader.pm index 4c17d34cb1..7b91722921 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/EDIReader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/EDIReader.pm @@ -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+)/, -- 2.43.2