From: Lebbeous Fogle-Weekley Date: Wed, 23 Jan 2013 18:24:05 +0000 (-0500) Subject: Acq: Bubble up errors better from invoice processing X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=06f1e7aec33657696b2d69ddd87bac5f93b80746;p=working%2FEvergreen.git Acq: Bubble up errors better from invoice processing Errors were getting logged, but weren't linked on the related acq.edi_message row in the database like they could have been to make debugging easier. This incidentally elevates one possible message from warning level to error, but even as a warning it was stopping the processing of the invoice in question there. So there's no meaningful difference. 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 d898a8c647..8a7bfc496a 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm @@ -208,6 +208,7 @@ sub process_retrieval { $e->xact_begin; $incoming = $e->retrieve_acq_edi_message($incoming->id); if ($@) { + $logger->error($@); $incoming->status('proc_error'); $incoming->error($@); } else { @@ -741,23 +742,19 @@ sub create_acq_invoice_from_edi { } if (!$eg_inv->receiver) { - $logger->error($log_prefix . + die($log_prefix . sprintf("unable to determine buyer (org unit) in invoice; ". "buyer_san=%s; buyer_acct=%s", ($invoice->{buyer_san} || ''), ($invoice->{buyer_acct} || '') ) ); - return 0; } $eg_inv->inv_ident($invoice->{invoice_ident}); if (!$eg_inv->inv_ident) { - $logger->error( - $log_prefix . "no invoice ID # in INVOIC message; " . shift - ); - return 0; + die($log_prefix . "no invoice ID # in INVOIC message; " . shift); } my @eg_inv_entries; @@ -776,9 +773,7 @@ sub create_acq_invoice_from_edi { my $li = $e->retrieve_acq_lineitem($li_id); if (!$li) { - $logger->warn($log_prefix . - "no LI found with ID: $li_id : " . $e->event); - return 0; + die($log_prefix . "no LI found with ID: $li_id : " . $e->event); } my ($quant) = grep {$_->{code} eq '47'} @{$lineitem->{quantities}}; @@ -865,16 +860,12 @@ sub create_acq_invoice_from_edi { # save changes to acq.edi_message row if (not $e->update_acq_edi_message($message)) { - $logger->error( - $log_prefix . "couldn't update edi_message " . $message->id - ); - return 0; + die($log_prefix . "couldn't update edi_message " . $message->id); } # create EG invoice if (not $e->create_acq_invoice($eg_inv)) { - $logger->error($log_prefix . "couldn't create invoice: " . $e->event); - return 0; + die($log_prefix . "couldn't create invoice: " . $e->event); } # Now we have a pkey for our EG invoice, so set the invoice field on all @@ -883,11 +874,10 @@ sub create_acq_invoice_from_edi { foreach (@eg_inv_entries) { $_->invoice($eg_inv_id); if (not $e->create_acq_invoice_entry($_)) { - $logger->error( + die( $log_prefix . "couldn't create entry against lineitem " . $_->lineitem . ": " . $e->event ); - return 0; } } @@ -895,10 +885,7 @@ sub create_acq_invoice_from_edi { foreach (@eg_inv_items) { $_->invoice($eg_inv_id); if (not $e->create_acq_invoice_item($_)) { - $logger->error( - $log_prefix . "couldn't create inv item: " . $e->event - ); - return 0; + die($log_prefix . "couldn't create inv item: " . $e->event); } } @@ -944,10 +931,9 @@ sub create_acq_invoice_from_edi { $lid->clear_cancel_reason; unless ($e->update_acq_lineitem_detail($lid)) { - $logger->error($log_prefix . + die($log_prefix . "couldn't clear lid cancel reason: ". $e->die_event ); - return 0; } } @@ -956,10 +942,9 @@ sub create_acq_invoice_from_edi { $li->edit_time('now'); unless ($e->update_acq_lineitem($li)) { - $logger->error($log_prefix . + die($log_prefix . "couldn't clear li cancel reason: ". $e->die_event ); - return 0; } }