Bugzilla – Attachment 183955 Details for
Bug 20253
Optionally use buyer's purchase order number from EDIFACT quote in basket name
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20253: Optionally use buyer's purchase order number from EDIFACT quote in basket name
Bug-20253-Optionally-use-buyers-purchase-order-num.patch (text/plain), 6.94 KB, created by
Martin Renvoize (ashimema)
on 2025-07-10 17:11:39 UTC
(
hide
)
Description:
Bug 20253: Optionally use buyer's purchase order number from EDIFACT quote in basket name
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-07-10 17:11:39 UTC
Size:
6.94 KB
patch
obsolete
>From 5b23da21a2d19e527f508860342b74b529900282 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Tue, 8 Jul 2025 14:45:19 +0100 >Subject: [PATCH] Bug 20253: Optionally use buyer's purchase order number from > EDIFACT quote in basket name > >This enhancement allows libraries to configure vendors to use the buyer's >purchase order number (from RFF+ON segments) as the basket name instead of >the EDIFACT filename, improving searchability and reference tracking. > >Backend Changes: >- Added purchase_order_number() method to Koha::Edifact::Message to extract > RFF+ON segments from message-level data (before first LIN segment) >- Modified process_quote() in Koha::EDI to use purchase order number for > basket naming when configured, with fallback to filename > >Frontend Changes: >- Updated admin/edi_accounts.pl to handle basket_name_source parameter >- Added "Basket name source" dropdown to EDI accounts template with options: > - "Quote filename" (default) > - "Purchase order number (RFF+ON)" > >Test Plan: >1. Apply patches and run database update >2. Go to Administration > Acquisitions > EDI accounts >3. Create or edit a vendor EDI account >4. Verify "Basket name source" dropdown appears with options: > - "Quote filename" (default) > - "Purchase order number (RFF+ON)" >5. Set to "Purchase order number (RFF+ON)" and save >6. Process an EDIFACT quote file that contains RFF+ON segments >7. Verify the created basket name uses the purchase order number instead of filename >8. Process a quote file without RFF+ON segments >9. Verify the basket name falls back to the filename >10. Test with "Quote filename" setting >11. Verify basket names use filenames regardless of RFF+ON presence >12. Run tests: prove t/Edifact_RFF_ON.t t/db_dependent/Koha/EDI.t > >The feature is optional and backward compatible - existing behavior is >unchanged unless explicitly configured. >--- > Koha/EDI.pm | 27 ++++++++++++++----- > Koha/Edifact/Message.pm | 20 ++++++++++++++ > admin/edi_accounts.pl | 1 + > .../prog/en/modules/admin/edi_accounts.tt | 13 +++++++++ > 4 files changed, 54 insertions(+), 7 deletions(-) > >diff --git a/Koha/EDI.pm b/Koha/EDI.pm >index 6b485bf864c..f5a6005cb1d 100644 >--- a/Koha/EDI.pm >+++ b/Koha/EDI.pm >@@ -645,11 +645,29 @@ sub process_quote { > my $split_message; > my @added_baskets; # if auto & multiple baskets need to order all > >+ # Get vendor EDI account configuration >+ my $v = $schema->resultset('VendorEdiAccount')->search( >+ { >+ vendor_id => $quote_message->vendor_id, >+ } >+ )->single; >+ > if ( @{$messages} && $quote_message->vendor_id ) { >+ > foreach my $msg ( @{$messages} ) { > ++$message_count; >+ >+ # Determine basket name based on vendor configuration >+ my $basket_name = $quote_message->filename; >+ if ( $v && $v->basket_name_source && $v->basket_name_source eq 'purchase_order_number' ) { >+ my $purchase_order_number = $msg->purchase_order_number; >+ if ($purchase_order_number) { >+ $basket_name = $purchase_order_number; >+ } >+ } >+ > my $basketno = NewBasket( >- $quote_message->vendor_id, 0, $quote_message->filename, q{}, >+ $quote_message->vendor_id, 0, $basket_name, q{}, > q{} . q{} > ); > push @added_baskets, $basketno; >@@ -691,12 +709,7 @@ sub process_quote { > $quote_message->status($status); > $quote_message->update; # status and basketno link > # Do we automatically generate orders for this vendor >- my $v = $schema->resultset('VendorEdiAccount')->search( >- { >- vendor_id => $quote_message->vendor_id, >- } >- )->single; >- if ( $v->auto_orders ) { >+ if ( $v && $v->auto_orders ) { > for my $b (@added_baskets) { > create_edi_order( > { >diff --git a/Koha/Edifact/Message.pm b/Koha/Edifact/Message.pm >index 5983b4b670e..3a0c2fbd74a 100644 >--- a/Koha/Edifact/Message.pm >+++ b/Koha/Edifact/Message.pm >@@ -183,6 +183,22 @@ sub supplier_ean { > > } > >+sub purchase_order_number { >+ my $self = shift; >+ foreach my $s ( @{ $self->{datasegs} } ) { >+ if ( $s->tag eq 'LIN' ) { >+ last; >+ } >+ if ( $s->tag eq 'RFF' ) { >+ my $qualifier = $s->elem( 0, 0 ); >+ if ( $qualifier eq 'ON' ) { >+ return $s->elem( 0, 1 ); >+ } >+ } >+ } >+ return; >+} >+ > sub lineitems { > my $self = shift; > if ( $self->{quotation_lines} ) { >@@ -280,6 +296,10 @@ Missing POD for buyer_ean. > > Missing POD for supplier_ean. > >+=head2 purchase_order_number >+ >+Missing POD for purchase_order_number. >+ > =head2 lineitems > > Missing POD for lineitems. >diff --git a/admin/edi_accounts.pl b/admin/edi_accounts.pl >index 410bcb8eaf4..62f78693b41 100755 >--- a/admin/edi_accounts.pl >+++ b/admin/edi_accounts.pl >@@ -94,6 +94,7 @@ if ( $op eq 'acct_form' ) { > auto_orders => $input->param('auto_orders') ? 1 : 0, > id_code_qualifier => scalar $input->param('id_code_qualifier'), > plugin => scalar $input->param('plugin'), >+ basket_name_source => scalar $input->param('basket_name_source') || 'filename', > }; > > if ($id) { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_accounts.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_accounts.tt >index 4e554f03eb7..1006655d44c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_accounts.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_accounts.tt >@@ -251,6 +251,19 @@ > [% END %] > <div class="hint"> With automatic ordering quotes generate orders without staff intervention. </div> > </li> >+ <li> >+ <label for="basket_name_source">Basket name source: </label> >+ <select name="basket_name_source" id="basket_name_source"> >+ [% IF account.basket_name_source == 'purchase_order_number' %] >+ <option value="filename">Quote filename</option> >+ <option value="purchase_order_number" selected="selected">Purchase order number (RFF+ON)</option> >+ [% ELSE %] >+ <option value="filename" selected="selected">Quote filename</option> >+ <option value="purchase_order_number">Purchase order number (RFF+ON)</option> >+ [% END %] >+ </select> >+ <div class="hint"> Determines how basket names are generated from quotes. Purchase order number uses RFF+ON segment from EDIFACT message if available, otherwise falls back to filename. </div> >+ </li> > </ol> > </fieldset> > >-- >2.50.0
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 20253
:
183859
|
183860
|
183861
|
183862
|
183953
|
183954
|
183955
|
183956
|
183957
|
183958
|
184000
|
184001
|
184002
|
184003
|
184004
|
184005
|
184006
|
184007
|
185221
|
185222
|
185223
|
185224
|
185225
|
185226
|
185227
|
185228