Bugzilla – Attachment 184004 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 as basket name
Bug-20253-Optionally-use-buyers-purchase-order-num.patch (text/plain), 13.51 KB, created by
Martin Renvoize (ashimema)
on 2025-07-11 15:36:22 UTC
(
hide
)
Description:
Bug 20253: Optionally use buyer's purchase order number from EDIFACT quote as basket name
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-07-11 15:36:22 UTC
Size:
13.51 KB
patch
obsolete
>From f4e66a6fc6563ff86b7e6deb8d4390ddc355c41f 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 as 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 po_is_basketname parameter >- Added "Use purhase order numbers" option to EDI accounts template > >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 "Use purchase order numbers" option appears >5. Enable "Use purchase order numbers" 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 "Use purchase order numbers" disabled >11. Verify basket names use filenames regardless of RFF+ON presence >12. Run tests: prove t/Edifact.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 | 108 ++++++++++++------ > 4 files changed, 112 insertions(+), 44 deletions(-) > >diff --git a/Koha/EDI.pm b/Koha/EDI.pm >index 6b485bf864c..ce349b501db 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->po_is_basketname ) { >+ 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..da084238f81 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'), >+ po_is_basketname => $input->param('po_is_basketname') ? 1 : 0, > }; > > 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..88dfcd41dca 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 >@@ -95,9 +95,10 @@ > <span>New account</span> > [% END %] > </h1> >- <fieldset class="rows"> >- <legend class="sr-only">Account details</legend> > >+ <!-- Basic Information --> >+ <fieldset class="rows"> >+ <legend>Basic Information</legend> > <ol> > <li> > <label for="vendor_id">Vendor: </label> >@@ -111,6 +112,10 @@ > [% END %] > </select> > </li> >+ <li> >+ <label for="description">Description: </label> >+ <input type="text" name="description" id="description" size="20" value="[% account.description | html %]" /> >+ </li> > [% IF plugins %] > <li> > <label for="plugin">Plugin: </label> >@@ -129,9 +134,45 @@ > <input type="hidden" name="plugin" value="" /> > [% END %] > <li> >- <label for="description">Description: </label> >- <input type="text" name="description" id="description" size="20" value="[% account.description | html %]" /> >+ <label for="id_code_qualifier">Qualifier:</label> >+ <select name="id_code_qualifier" id="id_code_qualifier"> >+ [% FOREACH qualifier IN code_qualifiers %] >+ [% IF qualifier.code == account.id_code_qualifier %] >+ <option value="[% qualifier.code | html %]" selected="selected"> [% qualifier.description | html %] ([% qualifier.code | html %]) </option> >+ [% ELSE %] >+ <option value="[% qualifier.code | html %]"> [% qualifier.description | html %] ([% qualifier.code | html %]) </option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ <li> >+ <label for="san">SAN: </label> >+ <input type="text" name="san" id="san" size="20" maxlength="20" value="[% account.san | html %]" /> >+ </li> >+ <li> >+ <label for="standard">Standard:</label> >+ <select name="standard" id="standard"> >+ [% FOREACH standard IN standards %] >+ [% IF standard == 'BIC' %] >+ [% SET description = 'BiC' %] >+ [% ELSE %] >+ [% SET description = 'EDItEUR' %] >+ [% END %] >+ [% IF standard == account.standard %] >+ <option value="[% standard | html %]" selected="selected"> [% description | html %] </option> >+ [% ELSE %] >+ <option value="[% standard | html %]"> [% description | html %] </option> >+ [% END %] >+ [% END %] >+ </select> > </li> >+ </ol> >+ </fieldset> >+ >+ <!-- Transport Settings --> >+ <fieldset class="rows"> >+ <legend>Transport Settings</legend> >+ <ol> > <li> > [% transport_types = [ 'FTP', 'SFTP', 'FILE' ] %] > <label for="transport">Transport: </label> >@@ -177,39 +218,13 @@ > <input type="text" name="upload_directory" id="upload_directory" size="20" value="[% account.upload_directory | html %]" /> > <div class="hint">The upload directory specifies the directory on the ftp site to which orders are uploaded.</div> > </li> >- <li> >- <label for="id_code_qualifier">Qualifier:</label> >- <select name="id_code_qualifier" id="id_code_qualifier"> >- [% FOREACH qualifier IN code_qualifiers %] >- [% IF qualifier.code == account.id_code_qualifier %] >- <option value="[% qualifier.code | html %]" selected="selected"> [% qualifier.description | html %] ([% qualifier.code | html %]) </option> >- [% ELSE %] >- <option value="[% qualifier.code | html %]"> [% qualifier.description | html %] ([% qualifier.code | html %]) </option> >- [% END %] >- [% END %] >- </select> >- </li> >- <li> >- <label for="san">SAN: </label> >- <input type="text" name="san" id="san" size="20" maxlength="20" value="[% account.san | html %]" /> >- </li> >- <li> >- <label for="standard">Standard:</label> >- <select name="standard" id="standard"> >- [% FOREACH standard IN standards %] >- [% IF standard == 'BIC' %] >- [% SET description = 'BiC' %] >- [% ELSE %] >- [% SET description = 'EDItEUR' %] >- [% END %] >- [% IF standard == account.standard %] >- <option value="[% standard | html %]" selected="selected"> [% description | html %] </option> >- [% ELSE %] >- <option value="[% standard | html %]"> [% description | html %] </option> >- [% END %] >- [% END %] >- </select> >- </li> >+ </ol> >+ </fieldset> >+ >+ <!-- Message Types --> >+ <fieldset class="rows"> >+ <legend>Message Types</legend> >+ <ol> > <li> > <label for="quotes_enabled">Quotes enabled: </label> > [% IF account.quotes_enabled %] >@@ -242,6 +257,13 @@ > <input type="checkbox" name="responses_enabled" id="responses_enabled" value="1" /> > [% END %] > </li> >+ </ol> >+ </fieldset> >+ >+ <!-- Functional Switches --> >+ <fieldset class="rows"> >+ <legend>Functional Switches</legend> >+ <ol> > <li> > <label for="auto_orders">Automatic ordering: </label> > [% IF account.auto_orders %] >@@ -251,6 +273,18 @@ > [% END %] > <div class="hint"> With automatic ordering quotes generate orders without staff intervention. </div> > </li> >+ <li> >+ <label for="po_is_basketname">Use purchase order numbers: </label> >+ [% IF account.po_is_basketname %] >+ <input type="checkbox" name="po_is_basketname" id="po_is_basketname" value="1" checked="checked" /> >+ [% ELSE %] >+ <input type="checkbox" name="po_is_basketname" id="po_is_basketname" value="1" /> >+ [% END %] >+ <div class="hint"> >+ When enabled, basket names are used as purchase order numbers. <br />For received QUOTE messages, we will use the RFF+ON field to populate the basket name. <br />For generated ORDER messages, we will use the >+ basket name to populate the BGM segment.</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