Bug 30144: (QA follow-up) Only show servicing instructions when EDIFACT is available

The new servicing instructions UI on the "add order" form was showing
unconditionally, even when the EDIFACT system preference is disabled
or the vendor has no EDI account configured. Elsewhere in acquisitions
(e.g. acqui/basket.tt) EDI-only UI is gated on
Koha.Preference('EDIFACT') && ediaccount, so apply the same check here.

Test plan:
1. With EDIFACT disabled, or EDIFACT enabled but the vendor has no
   entry in vendor_edi_accounts, open Acquisitions > a basket > Add
   order (neworderempty.pl)
   => No "Servicing instructions" field is shown
2. Enable EDIFACT and add a vendor_edi_accounts row for the vendor
   => The "Servicing instructions" field appears and behaves as before

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Martin Renvoize 2026-09-08 15:01:35 +01:00 committed by Pedro Amorim
parent b210605ef7
commit 9371504d98
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
2 changed files with 18 additions and 10 deletions

View File

@ -92,6 +92,7 @@ use Koha::Acquisition::Booksellers;
use Koha::Acquisition::Currencies; use Koha::Acquisition::Currencies;
use Koha::Biblios; use Koha::Biblios;
use Koha::BiblioFrameworks; use Koha::BiblioFrameworks;
use Koha::Database;
use Koha::DateUtils qw( dt_from_string ); use Koha::DateUtils qw( dt_from_string );
use Koha::MarcSubfieldStructures; use Koha::MarcSubfieldStructures;
use Koha::ItemTypes; use Koha::ItemTypes;
@ -446,6 +447,10 @@ $template->param(
items => $items, items => $items,
); );
# Only offer EDIFACT servicing instructions when EDIFACT is enabled and the vendor has an EDI account
my $ediaccount =
Koha::Database->new()->schema()->resultset('VendorEdiAccount')->search( { vendor_id => $booksellerid } )->count > 0;
# Get servicing instruction authorized values for EDIFACT_SI category # Get servicing instruction authorized values for EDIFACT_SI category
my @servicing_instruction_authorised_values = Koha::AuthorisedValues->search( my @servicing_instruction_authorised_values = Koha::AuthorisedValues->search(
{ category => 'EDIFACT_SI' }, { category => 'EDIFACT_SI' },
@ -496,6 +501,7 @@ $template->param(
orderdiscount => $data->{'discount'}, orderdiscount => $data->{'discount'},
order_internalnote => $data->{'order_internalnote'}, order_internalnote => $data->{'order_internalnote'},
order_vendornote => $data->{'order_vendornote'}, order_vendornote => $data->{'order_vendornote'},
ediaccount => $ediaccount,
servicing_instruction_groups => $servicing_instruction_groups, servicing_instruction_groups => $servicing_instruction_groups,
servicing_instruction_groups_json => $servicing_instruction_groups_json, servicing_instruction_groups_json => $servicing_instruction_groups_json,
servicing_instruction_avs_json => $servicing_instruction_avs_json, servicing_instruction_avs_json => $servicing_instruction_avs_json,

View File

@ -962,6 +962,7 @@
<label for="order_vendornote">Vendor note: </label> <label for="order_vendornote">Vendor note: </label>
<textarea id="order_vendornote" cols="30" rows="3" name="order_vendornote">[% IF ( order_vendornote ) %][% order_vendornote | html %][% END %]</textarea> <textarea id="order_vendornote" cols="30" rows="3" name="order_vendornote">[% IF ( order_vendornote ) %][% order_vendornote | html %][% END %]</textarea>
</li> </li>
[% IF Koha.Preference('EDIFACT') && ediaccount %]
<li> <li>
<label for="servicing_instructions">Servicing instructions: </label> <label for="servicing_instructions">Servicing instructions: </label>
<div id="servicing_instructions_container"> <div id="servicing_instructions_container">
@ -972,6 +973,7 @@
<input type="hidden" id="servicing_instruction_avs_json" value="[% servicing_instruction_avs_json | html %]" /> <input type="hidden" id="servicing_instruction_avs_json" value="[% servicing_instruction_avs_json | html %]" />
<div class="hint">EDIFACT servicing instructions (GIR LVT/LVC). Each group can contain multiple coded (LVC) and/or free-text (LVT) instructions that work together.</div> <div class="hint">EDIFACT servicing instructions (GIR LVT/LVC). Each group can contain multiple coded (LVC) and/or free-text (LVT) instructions that work together.</div>
</li> </li>
[% END %]
<li> <li>
<label for="estimated_delivery_date">Estimated delivery date: </label> <label for="estimated_delivery_date">Estimated delivery date: </label>
<input type="text" id="estimated_delivery_date" size="10" name="estimated_delivery_date" class="flatpickr" value="[% estimated_delivery_date | html %]" /> <input type="text" id="estimated_delivery_date" size="10" name="estimated_delivery_date" class="flatpickr" value="[% estimated_delivery_date | html %]" />