# 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];
$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,
);
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
+ )
+ );
}
}
# 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}}) {