Bugzilla – Attachment 176532 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: Add section to output
Bug-38689-Add-section-to-output.patch (text/plain), 13.09 KB, created by
Martin Renvoize (ashimema)
on 2025-01-14 17:17:15 UTC
(
hide
)
Description:
Bug 38689: Add section to output
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-01-14 17:17:15 UTC
Size:
13.09 KB
patch
obsolete
>From 2e992847e031aee6a66d0694918de5ed59a9f5e9 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 7 Jan 2025 10:41:07 +0000 >Subject: [PATCH] Bug 38689: Add section to output > >We attempt to add the relevant part of the EDI message to the 'section' >field of the edifact_errors record and then display this alongside the >error details. > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/EDI.pm | 90 ++++++++++++------- > .../prog/en/modules/acqui/edifactmsgs.tt | 7 +- > 2 files changed, 62 insertions(+), 35 deletions(-) > >diff --git a/Koha/EDI.pm b/Koha/EDI.pm >index 00cf5f95dde..60d5e966a51 100644 >--- a/Koha/EDI.pm >+++ b/Koha/EDI.pm >@@ -110,6 +110,11 @@ sub create_edi_order { > )->single; > } > >+ unless ( $ean_obj ) { >+ carp "No matching EAN found for $ean"; >+ return; >+ } >+ > my $dbh = C4::Context->dbh; > my $arr_ref = $dbh->selectcol_arrayref( > 'select id from edifact_messages where basketno = ? and message_type = \'QUOTE\'', >@@ -292,7 +297,7 @@ sub process_invoice { > if ( !$vendor_acct ) { > $invoice_message->add_to_edifact_errors( > { >- section => '', >+ section => "NAD+SU+" . $msg->supplier_ean, > details => "Skipped invoice $invoicenumber with unmatched vendor san: $vendor_ean" > } > ); >@@ -300,7 +305,7 @@ sub process_invoice { > next; > } > $invoice_message->edi_acct( $vendor_acct->id ); >- $logger->trace("Adding invoice:$invoicenumber"); >+ $logger->trace("Adding invoice: $invoicenumber"); > my $new_invoice = $schema->resultset('Aqinvoice')->create( > { > invoicenumber => $invoicenumber, >@@ -321,8 +326,8 @@ sub process_invoice { > if ( !$ordernumber ) { > $invoice_message->add_to_edifact_errors( > { >- section => $line->line_item_number, >- details => "Message missing ordernumber" >+ section => join("\n", map { $_->as_string } @{$line->{segs}}), >+ details => "Skipped invoice line " . $line->line_item_number . ", missing ordernumber" > } > ); > $logger->error("Skipping invoice line, no associated ordernumber"); >@@ -334,8 +339,11 @@ sub process_invoice { > if ( !$order ) { > $invoice_message->add_to_edifact_errors( > { >- section => $line->line_item_number, >- details => "Koha order $ordernumber missing" >+ section => join( "\n", map { $_->as_string } @{ $line->{segs} } ), >+ details => "Skipped invoice line " >+ . $line->line_item_number >+ . ", cannot find order with ordernumber " >+ . $ordernumber > } > ); > $logger->error("Skipping invoice line, no order found for $ordernumber, invoice:$invoicenumber"); >@@ -346,8 +354,11 @@ sub process_invoice { > if ( !$bib ) { > $invoice_message->add_to_edifact_errors( > { >- section => $line->line_item_number, >- details => "Koha biblio missing" >+ section => join( "\n", map { $_->as_string } @{ $line->{segs} } ), >+ details => "Skipped invoice line " >+ . $line->line_item_number >+ . ", cannot find biblio for ordernumber " >+ . $ordernumber > } > ); > $logger->error( >@@ -477,8 +488,12 @@ sub receipt_items { > my $i = $ilink->itemnumber; > $invoice_message->add_to_edifact_errors( > { >- section => $inv_line->line_item_number, >- details => "Cannot fine aqorder item" >+ section => join( "\n", map { $_->as_string } @{ $inv_line->{segs} } ), >+ details => "Skipped invoice line " >+ . $inv_line->line_item_number >+ . ", Koha item with itemnumber " >+ . $i >+ . "is missing" > } > ); > $logger->warn( >@@ -522,8 +537,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" >+ section => join( "\n", map { $_->as_string } @{ $inv_line->{segs} } ), >+ details => "Failed to assign barcode " >+ . $barcode >+ . "for invoice line " >+ . $inv_line->line_item_number >+ . ", duplicate found" > } > ); > $logger->warn("Barcode $barcode is a duplicate"); >@@ -552,8 +571,11 @@ sub receipt_items { > else { > $invoice_message->add_to_edifact_errors( > { >- section => $inv_line->line_item_number, >- details => "Unmatched item at branch $branch" >+ section => join("\n", map { $_->as_string } @{$inv_line->{segs}}), >+ details => "No matching item found for invoice line " >+ . $inv_line->line_item_number . ":" >+ . $gir_occurrence >+ . " at branch $branch" > } > ); > $logger->warn("Unmatched item at branch:$branch"); >@@ -722,10 +744,10 @@ sub quote_item { > details => "Failed to create basket" > } > ); >- $logger->error('Skipping order creation no valid basketno'); >+ $logger->error('Skipped order creation no valid basketno'); > return; > } >- $logger->trace( 'Checking db for matches with ', $item->item_number_id() ); >+ $logger->trace( 'Checking db for matches with ' . $item->item_number_id() ); > my $bib = _check_for_existing_bib( $item->item_number_id() ); > if ( !defined $bib ) { > $bib = {}; >@@ -736,10 +758,10 @@ sub quote_item { > > ( $bib->{biblionumber}, $bib->{biblioitemnumber} ) = > AddBiblio( $bib_record, q{} ); >- $logger->trace("New biblio added $bib->{biblionumber}"); >+ $logger->trace("Added biblio: ". $bib->{biblionumber}); > } > else { >- $logger->trace("Match found: $bib->{biblionumber}"); >+ $logger->trace("Match found: " .$bib->{biblionumber}); > } > > # Create an orderline >@@ -752,7 +774,7 @@ sub quote_item { > if ( $gir_count != $order_quantity ) { > $quote_message->add_to_edifact_errors( > { >- section => "GIR", >+ section => join('\n', @{$item->{GIR}}), > details => "Order for $order_quantity items, $gir_count segments present" > } > ); >@@ -838,20 +860,20 @@ sub quote_item { > if ( $item->quantity > 1 ) { > $quote_message->add_to_edifact_errors( > { >- section => "GIR", >+ section => join( '\n', @{ $item->{GIR} } ), > details => "Skipped GIR line with invalid budget: " . $item->girfield('fund_allocation') > } > ); >- $logger->trace('girfield skipped for invalid budget'); >+ $logger->trace( 'Skipping item with invalid budget: ' . $item->girfield('fund_allocation') ); > $skip++; > } else { > $quote_message->add_to_edifact_errors( > { >- section => "GIR", >+ section => join( "\n", map { $_->as_string } @{ $item->{segs} } ), > details => "Skipped orderline line with invalid budget: " . $item->girfield('fund_allocation') > } > ); >- $logger->trace('orderline skipped for invalid budget'); >+ $logger->trace( 'Skipping orderline with invalid budget: ' . $item->girfield('fund_allocation') ); > return; > } > } >@@ -885,7 +907,7 @@ sub quote_item { > $item_hash->{biblioitemnumber} = $bib->{biblioitemnumber}; > my $kitem = Koha::Item->new( $item_hash )->store; > my $itemnumber = $kitem->itemnumber; >- $logger->trace("Added item:$itemnumber"); >+ $logger->trace("Added item: ". $itemnumber); > $schema->resultset('AqordersItem')->create( > { > ordernumber => $first_order->ordernumber, >@@ -902,12 +924,12 @@ sub quote_item { > ); > if ($rota) { > $rota->add_item($itemnumber); >- $logger->trace("Item added to rota $rota->id"); >+ $logger->trace("Item added to rota " . $rota->title); > } else { > $quote_message->add_to_edifact_errors( > { >- section => "LRP", >- details => "No rota found for passed $lrp in orderline" >+ section => "$item->{GIR}->[0]", >+ details => "No rota found for passed LRP:$lrp in orderline" > } > ); > $logger->error("No rota found matching $lrp in orderline"); >@@ -930,12 +952,12 @@ sub quote_item { > $item->girfield( 'fund_allocation', $occurrence ); > $quote_message->add_to_edifact_errors( > { >- section => "GIR", >- details => "Skipped GIR line with invalid budget: $bad_budget" >+ section => "$item->{GIR}->[$occurrence]", >+ details => "Invalid budget $bad_budget found" > } > ); > $logger->trace( >- "girfield skipped for invalid budget:$bad_budget"); >+ "Skipping item with invalid budget: " . $bad_budget); > ++$occurrence; ## lets look at the next one not this one again > next; > } >@@ -1025,8 +1047,8 @@ sub quote_item { > else { > $quote_message->add_to_edifact_errors( > { >- section => "LRP", >- details => "No rota found for passed $lrp in orderline" >+ section => "$item->{GIR}->[$occurrence]", >+ details => "No rota found for passed LRP:$lrp in orderline" > } > ); > $logger->error( >@@ -1101,8 +1123,8 @@ sub quote_item { > else { > $quote_message->add_to_edifact_errors( > { >- section => "LRP", >- details => "No rota found for passed $lrp in orderline" >+ section => "$item->{GIR}->[$occurrence]", >+ details => "No rota found for passed LRP:$lrp in orderline" > } > ); > $logger->error( >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt >index 94a9ca180ca..8147dc7119b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt >@@ -130,7 +130,12 @@ > let errorsList = '<ul>'; > row.errors.forEach(error => { > if (error.details) { >- errorsList += '<li>' + error.details + '</li>'; >+ errorsList += '<li>' >+ errorsList += error.details >+ if (error.section) { >+ errorsList += '</br><pre>' + error.section + '</pre>'; >+ } >+ errorsList += '</li>'; > } > }); > errorsList += '</ul>'; >-- >2.47.1
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