Bug 40587 - Prevent selection of different EAN's on EDI ORDER when the Basket is generated from a QUOTE message
Summary: Prevent selection of different EAN's on EDI ORDER when the Basket is generate...
Status: Needs Signoff
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Martin Renvoize (ashimema)
QA Contact: Testopia
URL:
Keywords:
Depends on: 39572 21417
Blocks:
  Show dependency treegraph
 
Reported: 2025-08-04 12:17 UTC by Martin Renvoize (ashimema)
Modified: 2025-08-04 13:41 UTC (History)
3 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 40587: Add tests for multiple message EAN handling in EDI quotes (4.68 KB, patch)
2025-08-04 13:37 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 40587: Auto-select EAN from QUOTE message when creating EDIFACT orders (9.33 KB, patch)
2025-08-04 13:37 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize (ashimema) 2025-08-04 12:17:37 UTC
This is a follow-up to bug 39572 and bug 21417. When an EDI basket is generated from then EDI QUOTE message, I believe the correct EAN is included in the original QUOTE. As such, we should be able to bind the 'Create EDI Order' button to only allow use of that EAN when automatic ordering is disabled.
Comment 1 Martin Renvoize (ashimema) 2025-08-04 13:37:54 UTC
Created attachment 185099 [details] [review]
Bug 40587: Add tests for multiple message EAN handling in EDI quotes

This patch adds unit tests to verify that when processing EDI QUOTE transports
containing multiple messages with different buyer EANs, each basket gets the
correct EAN for its corresponding message.

Test plan:
1. Run: prove t/db_dependent/Koha/EDI.t
2. Verify the new 'multiple_message_ean_handling' subtest passes
3. Verify that all existing EDI tests continue to pass
Comment 2 Martin Renvoize (ashimema) 2025-08-04 13:37:56 UTC
Created attachment 185100 [details] [review]
Bug 40587: Auto-select EAN from QUOTE message when creating EDIFACT orders

When a basket is generated via an EDI QUOTE message, the QUOTE message
includes a library's EAN code (buyer_ean). This patch makes the 'Create
EDIFACT order' button automatically use the EAN from the original QUOTE
message instead of requiring manual EAN selection.

This patch also fixes a bug in process_quote where all baskets in
multi-message QUOTE transports incorrectly used the first message's
buyer_ean, even when subsequent messages had different EANs.

Changes made:

1. Fixed Koha/EDI.pm process_quote auto-order creation to use the correct
   buyer_ean for each message/basket pair in multi-message transports
2. Enhanced acqui/basket.pl to extract and provide the quote_ean from
   QUOTE messages, handling both single and multi-message scenarios
3. Updated basket.tt template to automatically select the EAN from the
   original QUOTE message when available and matching

Test plan:
1. Create a vendor with EDI account and multiple EANs configured
2. Process a QUOTE message that creates a basket
3. Go to the basket page and click "Create EDIFACT order"
4. Verify it automatically uses the EAN from the QUOTE message
   (shows tooltip "Using EAN from original QUOTE message")
5. Test with multi-message QUOTE files to ensure each basket uses
   the correct EAN from its corresponding message
6. Verify fallback behavior when no QUOTE EAN matches available EANs