From: Lebbeous Fogle-Weekley Date: Thu, 24 Jan 2013 22:25:50 +0000 (-0500) Subject: Acq: Fixes to new vencode parsing for incoming EDI messages X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b5c7bd86300098aabd89301759dd4e4de26f2908;p=working%2FEvergreen.git Acq: Fixes to new vencode parsing for incoming EDI messages Signed-off-by: Lebbeous Fogle-Weekley --- 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 f26e98c7ac..962ad416a1 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm @@ -493,7 +493,7 @@ sub process_message_buyer { # some vendors encode the SAN as "$SAN $vendcode" my $vendcode; - ($buyer, $vendcode) = $_ =~ /(\S+)\s*(\S+)?$/; + ($buyer, $vendcode) = $buyer =~ /(\S+)\s*(\S+)?$/; my $addr = $e->search_actor_org_address( {valid => "t", san => $buyer})->[0]; @@ -502,15 +502,15 @@ sub process_message_buyer { $eg_inv->receiver($addr->org_unit) if $eg_inv; - if (defined $vendcode) { + my $orig_acct = $e->retrieve_acq_edi_account($message->account); + + if (defined($vendcode) and ($orig_acct->vendcode ne $vendcode)) { # The vendcode can give us the opportunity to change the # acq.edi_account with which our acq.edi_message is associated # in case it's wrong. - my $orig_acct = $e->retrieve_acq_edi_account($message->account); my $other_accounts = $e->search_acq_edi_account( { - id => {"!=" => $orig_acct->id}, vendcode => $vendcode, host => $orig_acct->host, username => $orig_acct->username, @@ -520,25 +520,17 @@ sub process_message_buyer { ); if (@$other_accounts) { - if (@$other_accounts == 1) { - # We can update this object because the caller saves - # it with cstore later. - $message->account($other_accounts->[0]->id); - - $logger->info( - $log_prefix . sprintf( - "changing edi_account from %d to %d based on " . - "vendcode '%s'", - $orig_acct->id, $message->account, $vendcode - ) - ); - } else { - $logger->info( - $log_prefix . - "too many matching edi_account's based on " . - "vendcode $vendcode to be certain which to use" - ); - } + # We can update this object because the caller saves + # it with cstore later. + $message->account($other_accounts->[0]->id); + + $logger->info( + $log_prefix . sprintf( + "changing edi_account from %d to %d based on " . + "vendcode '%s'", + $orig_acct->id, $message->account, $vendcode + ) + ); } } @@ -571,9 +563,9 @@ sub process_parsed_msg { # ORDRSP # First do this for the whole message... - my $e = new_editor; - $class->process_message_buyer($e, $msg_hash, $incoming, "ORDRSP processing"); - $e->disconnect; + $class->process_message_buyer( + new_editor, $msg_hash, $incoming, "ORDRSP processing" + ); # ... now do this stuff per-lineitem. for my $li_hash (@{$msg_hash->{lineitems}}) {