Bugzilla – Attachment 176375 Details for
Bug 38689
EDIFACT errors should log to a staff accessible location
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38689: Record errors on invoice processing
Bug-38689-Record-errors-on-invoice-processing.patch (text/plain), 6.34 KB, created by
Kyle M Hall (khall)
on 2025-01-10 17:25:00 UTC
(
hide
)
Description:
Bug 38689: Record errors on invoice processing
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2025-01-10 17:25:00 UTC
Size:
6.34 KB
patch
obsolete
>From 848aa9a76406b3b1e5b79c11d604ea1d8d7a92bb Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 19 Dec 2024 16:56:29 +0000 >Subject: [PATCH] Bug 38689: Record errors on invoice processing > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/EDI.pm | 55 ++++++++++++++++++++++++++++++++++++++++++----------- > 1 file changed, 44 insertions(+), 11 deletions(-) > >diff --git a/Koha/EDI.pm b/Koha/EDI.pm >index 09b3d6f74f4..d5666da2adf 100644 >--- a/Koha/EDI.pm >+++ b/Koha/EDI.pm >@@ -290,7 +290,8 @@ sub process_invoice { > )->single; > } > if ( !$vendor_acct ) { >- carp "Cannot find vendor with ean $vendor_ean for invoice $invoicenumber in ".$invoice_message->filename; >+ $invoice_message->add_to_edifact_errors({ details => "Cannot find vendor with ean $vendor_ean" }); >+ $logger->error("Cannot find vendor with ean $vendor_ean for invoice $invoicenumber in ".$invoice_message->filename); > next; > } > $invoice_message->edi_acct( $vendor_acct->id ); >@@ -313,6 +314,12 @@ sub process_invoice { > foreach my $line ( @{$lines} ) { > my $ordernumber = $line->ordernumber; > if ( !$ordernumber ) { >+ $invoice_message->add_to_edifact_errors( >+ { >+ section => $line->line_item_number, >+ details => "Message missing ordernumber" >+ } >+ ); > $logger->error("Skipping invoice line, no associated ordernumber"); > next; > } >@@ -320,12 +327,24 @@ sub process_invoice { > # ModReceiveOrder does not validate that $ordernumber exists validate here > my $order = $schema->resultset('Aqorder')->find($ordernumber); > if ( !$order ) { >+ $invoice_message->add_to_edifact_errors( >+ { >+ section => $line->line_item_number, >+ details => "Koha order $ordernumber missing" >+ } >+ ); > $logger->error("Skipping invoice line, no order found for $ordernumber, invoice:$invoicenumber"); > next; > } > > my $bib = $order->biblionumber; > if ( !$bib ) { >+ $invoice_message->add_to_edifact_errors( >+ { >+ section => $line->line_item_number, >+ details => "Koha biblio missing" >+ } >+ ); > $logger->error( > "Skipping invoice line, no bibliographic record found for $ordernumber, invoice:$invoicenumber" > ); >@@ -384,13 +403,10 @@ sub process_invoice { > tax_value_on_receiving => $quantity * $price_excl_tax * $tax_rate->{rate}, > } > ); >- transfer_items( >- $schema, $line, $order, >- $received_order, $quantity >- ); >+ transfer_items( $schema, $line, $order, $received_order, $quantity ); > receipt_items( >- $schema, $line, >- $received_order->ordernumber, $quantity >+ $schema, $line, >+ $received_order->ordernumber, $quantity, $invoice_message > ); > } else { # simple receipt all copies on order > $order->quantityreceived($quantity); >@@ -403,7 +419,7 @@ sub process_invoice { > $order->tax_value_on_receiving( $quantity * $price_excl_tax * $tax_rate->{rate} ); > $order->orderstatus('complete'); > $order->update; >- receipt_items( $schema, $line, $ordernumber, $quantity ); >+ receipt_items( $schema, $line, $ordernumber, $quantity, $invoice_message ); > } > } > } >@@ -440,7 +456,7 @@ sub _get_invoiced_price { > } > > sub receipt_items { >- my ( $schema, $inv_line, $ordernumber, $quantity ) = @_; >+ my ( $schema, $inv_line, $ordernumber, $quantity, $invoice_message ) = @_; > my $logger = Koha::Logger->get( { interface => 'edi' } ); > > # itemnumber is not a foreign key ??? makes this a bit cumbersome >@@ -454,6 +470,12 @@ sub receipt_items { > my $item = $schema->resultset('Item')->find( $ilink->itemnumber ); > if ( !$item ) { > my $i = $ilink->itemnumber; >+ $invoice_message->add_to_edifact_errors( >+ { >+ section => $inv_line->line_item_number, >+ details => "Cannot fine aqorder item" >+ } >+ ); > $logger->warn( > "Cannot find aqorder item for $i :Order:$ordernumber"); > next; >@@ -493,6 +515,12 @@ sub receipt_items { > } > ); > if ( $rs->count > 0 ) { >+ $invoice_message->add_to_edifact_errors( >+ { >+ section => $inv_line->line_item_number . " : " . $gir_occurrence, >+ details => "Duplicate barcode found $barcode" >+ } >+ ); > $logger->warn("Barcode $barcode is a duplicate"); > } > else { >@@ -517,12 +545,17 @@ sub receipt_items { > $item->update; > } > else { >+ $invoice_message->add_to_edifact_errors( >+ { >+ section => $inv_line->line_item_number, >+ details => "Unmatched item at branch $branch" >+ } >+ ); > $logger->warn("Unmatched item at branch:$branch"); > } > ++$gir_occurrence; > } > return; >- > } > > sub transfer_items { >@@ -1298,7 +1331,7 @@ Koha::EDI > > =head2 receipt_items > >- receipt_items( schema_obj, invoice_line, ordernumber, $quantity) >+ receipt_items( schema_obj, invoice_line, ordernumber, $quantity, $invoice_message) > > receipts the items recorded on this invoice line > >-- >2.39.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 38689
:
175788
|
175789
|
175790
|
175793
|
175794
|
175795
|
175796
|
175797
|
175809
|
175810
|
175811
|
175812
|
175813
|
175814
|
175815
|
175816
|
175817
|
176127
|
176128
|
176129
|
176130
|
176131
|
176132
|
176133
|
176134
|
176173
|
176174
|
176175
|
176176
|
176177
|
176178
|
176179
|
176180
|
176181
|
176182
|
176183
|
176373
|
176374
|
176375
|
176376
|
176377
|
176378
|
176379
|
176380
|
176381
|
176382
|
176524
|
176525
|
176526
|
176527
|
176528
|
176529
|
176530
|
176531
|
176532
|
176533
|
176605
|
176606
|
176607
|
176608
|
176609
|
176610
|
176611
|
176612
|
176613
|
176614