Koha-clms/acqui
Martin Renvoize 943bfe097e
Bug 20253: (follow-up) Block auto_orders and UI ordering for duplicate PO numbers
When po_is_basketname is enabled for a vendor, duplicate purchase order
numbers should prevent both automatic ordering (auto_orders) and manual
UI-triggered ordering to avoid conflicts with existing baskets.

This patch implements blocking functionality that:

1. Auto-orders blocking:
   - Tracks baskets with PO number conflicts during quote processing
   - Skips auto-ordering for baskets with duplicate PO numbers
   - Logs clear warnings about blocked baskets

2. UI basket ordering blocking:
   - Adds duplicate checking in create_edi_order function
   - Returns detailed error information when conflicts detected
   - Prevents EDI order creation for conflicting baskets

3. User-friendly error handling:
   - Updates basket.pl to handle duplicate PO number errors
   - Stays on basket page to display error messages
   - Provides clear messaging about conflicts and resolution steps

4. Template messaging:
   - Adds clear error message explaining duplicate PO conflicts
   - Shows which existing basket uses the same PO number
   - Guides users on next steps to resolve the issue

This ensures data integrity and prevents order processing conflicts
while providing clear feedback to users about duplicate PO number
issues.

Test plan:
1. Set up a vendor with EDI account and enable "po_is_basketname"
2. Create a basket with a specific name (e.g., "PO12345")
3. Process an EDIFACT quote that contains the same PO number:
   - If auto_orders is enabled: verify the new basket is created but NOT automatically ordered
   - Check the logs show "Auto-order blocked" message
4. For UI testing, create another basket manually with the same name
5. Try to generate EDI order via "Generate EDI order" button
6. Verify: Error message appears stating duplicate PO number conflict
7. Verify: Basket remains open (not closed)
8. Verify: Error message shows which existing basket uses the PO number
9. Test with po_is_basketname disabled: verify normal operation continues
10. Test with unique PO numbers: verify orders process normally

Signed-off-by: Hannah Dunne-Howrie <hdunne-howrie@westminster.gov.uk>
Sponsored-by: Westminster City Council <https://www.westminster.gov.uk/>
Sponsored-by: Royal Borough of Kensington and Chelsea <https://www.rbkc.gov.uk/>
Sponsored-by: OpenFifth <https://openfifth.co.uk/>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-11-03 14:13:39 -07:00
..
acqui-home.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
addorder.pl Bug 7132: Acq: Check for duplicates when ordering from empty record 2025-10-15 16:12:08 -06:00
addorderiso2709.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
ajax-getauthvaluedropbox.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
basket.pl Bug 20253: (follow-up) Block auto_orders and UI ordering for duplicate PO numbers 2025-11-03 14:13:39 -07:00
basketgroup.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
basketheader.pl Bug 20253: (follow-up) Make basket name read-only when derived from EDI purchase order number 2025-11-03 14:13:38 -07:00
booksellers.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
cancelorder.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
check_budget_total.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
check_uniqueness.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
duplicate_orders.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
edifactmsgs.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
edimsg.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
finishreceive.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
histsearch.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
invoice-files.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
invoice.pl Bug 40333: Add EDIFACT message view to invoice display page 2025-10-22 07:42:51 -06:00
invoices.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
lateorders-export.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
lateorders.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
moddeliverydate.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
modordernotes.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
neworderempty.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
newordersubscription.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
newordersuggestion.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
ordered.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
orderreceive.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
parcel.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
parcels.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
showorder.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
spent.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
transferorder.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
uncertainprice.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
vendor_issues.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
vendors.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
z3950_search.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00