Current default behaviour is to use the filename of the QUOTE in the basketname. This would instead use the buyer's purchase order number (segment RFF with a qualifier ON) instead so that this would be searchable. This should be optional as even when supplied many (most) sites do not have meaningful or distinctive data in the field (e.g. 'Books for branch X'). Logical is to add it as a vendor option
We would support this. We have recently started using EDI and one of the issues is not being able to see the basket name from the vendor in Koha. We enter a basket name on the vendor site based on site/date etc so we can tell from the basket name which site the order was placed for and the date. The quote in Koha only shows the file name. When we confirm the order, the actual order sent back to the vendor uses the Koha OrderID as the basket name. So we end up with 3 different references depending if it is a quote or order and whether you look in the vendor system or Koha so not easy to cross-check between the vendor and Koha. Ideally we would want to retain the vendor basketID in the Quote seen in Koha (or at least be able to see/search sort by this). It would also be useful to be able to use this as the basis for the orderID sent back to the vendor though it needs to be unique so would need koha to add some suffix to the order & quote don't have exactly the same refence on the vendor system
We also support this and would like to see this happen to automate the process and allow file names to be used for different purposes. Although, ideally, we'd want to see the order reference added in as the basket ID as opposed to the basket name.
Created attachment 183859 [details] [review] Bug 20253: Add tests for RFF+ON segment handling and basket naming This patch adds tests for: 1. RFF+ON (Purchase Order Number) segment parsing in EDIFACT messages 2. Vendor configuration for basket naming preferences 3. Basket naming logic in QUOTE processing Test coverage includes: - Message-level RFF+ON segment extraction - Validation that RFF+ON processing stops at LIN segments - Multiple RFF segment handling - Database field storage and constraints - Basket naming configuration logic - Fallback behavior when purchase order number unavailable
Created attachment 183860 [details] [review] Bug 20253: Add basket_name_source field to vendor_edi_accounts table This patch adds a new ENUM field 'basket_name_source' to the vendor_edi_accounts table to allow configuration of how basket names are generated from EDIFACT quotes. Options: - 'filename' (default): Use the EDIFACT filename as basket name - 'purchase_order_number': Use RFF+ON segment value as basket name Changes: - Added atomicupdate for existing installations - Updated kohastructure.sql for new installations
Created attachment 183861 [details] [review] 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.
Created attachment 183862 [details] [review] Bug 20253: (follow-up) Add RFF+ON segments to outgoing ORDER messages When vendors are configured to use purchase order numbers for basket naming, the purchase order number should be included in outgoing ORDER messages as an RFF+ON (Reference - Order Number) segment for proper EDI workflow continuity. This follow-up ensures that: 1. Purchase order numbers from incoming QUOTE messages are preserved 2. The same purchase order numbers are sent back in ORDER messages 3. Vendors receive the reference numbers they expect for order processing Implementation: - Added _get_purchase_order_number() method to extract PO number from basket name when vendor is configured with basket_name_source = 'purchase_order_number' - Modified order_msg_header() to include RFF+ON segment when PO number available - Added comprehensive tests for RFF+ON segment generation in ORDER messages Test Plan: 1. Apply patches 2. Configure a vendor EDI account with "Basket name source" = "Purchase order number" 3. Process a QUOTE message containing RFF+ON segment 4. Verify basket is created with purchase order number as name 5. Generate ORDER message from the basket 6. Verify ORDER message contains RFF+ON segment with the purchase order number 7. Run tests: prove t/db_dependent/Koha/Edifact/Order.t This completes the round-trip EDI workflow for purchase order number handling.
Created attachment 183953 [details] [review] Bug 20253: Add tests for RFF+ON segment handling and basket naming This patch adds tests for: 1. RFF+ON (Purchase Order Number) segment parsing in EDIFACT messages 2. Vendor configuration for basket naming preferences 3. Basket naming logic in QUOTE processing Test coverage includes: - Message-level RFF+ON segment extraction - Validation that RFF+ON processing stops at LIN segments - Multiple RFF segment handling - Database field storage and constraints - Basket naming configuration logic - Fallback behavior when purchase order number unavailable
Created attachment 183954 [details] [review] Bug 20253: Add basket_name_source field to vendor_edi_accounts table This patch adds a new ENUM field 'basket_name_source' to the vendor_edi_accounts table to allow configuration of how basket names are generated from EDIFACT quotes. Options: - 'filename' (default): Use the EDIFACT filename as basket name - 'purchase_order_number': Use RFF+ON segment value as basket name Changes: - Added atomicupdate for existing installations - Updated kohastructure.sql for new installations
Created attachment 183955 [details] [review] 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.
Created attachment 183956 [details] [review] Bug 20253: (follow-up) Add RFF+ON segments to outgoing ORDER messages When vendors are configured to use purchase order numbers for basket naming, the purchase order number should be included in outgoing ORDER messages as an RFF+ON (Reference - Order Number) segment for proper EDI workflow continuity. This follow-up ensures that: 1. Purchase order numbers from incoming QUOTE messages are preserved 2. The same purchase order numbers are sent back in ORDER messages 3. Vendors receive the reference numbers they expect for order processing Implementation: - Added _get_purchase_order_number() method to extract PO number from basket name when vendor is configured with basket_name_source = 'purchase_order_number' - Modified order_msg_header() to include RFF+ON segment when PO number available - Added comprehensive tests for RFF+ON segment generation in ORDER messages Test Plan: 1. Apply patches 2. Configure a vendor EDI account with "Basket name source" = "Purchase order number" 3. Process a QUOTE message containing RFF+ON segment 4. Verify basket is created with purchase order number as name 5. Generate ORDER message from the basket 6. Verify ORDER message contains RFF+ON segment with the purchase order number 7. Run tests: prove t/db_dependent/Koha/Edifact/Order.t This completes the round-trip EDI workflow for purchase order number handling.
Created attachment 183957 [details] [review] Bug 20253: (follow-up) Remove warnings from EDI when running tests
Created attachment 183958 [details] [review] Bug 20253: DBIC Schema
Created attachment 184000 [details] [review] Bug 20253: Remove warnings from EDI when running tests
Created attachment 184001 [details] [review] Bug 20253: Add tests for RFF+ON segment handling and basket naming This patch adds tests for: 1. RFF+ON (Purchase Order Number) segment parsing in EDIFACT messages 2. Vendor configuration for basket naming preferences 3. Basket naming logic in QUOTE processing Test coverage includes: - Message-level RFF+ON segment extraction - Validation that RFF+ON processing stops at LIN segments - Multiple RFF segment handling - Database field storage and constraints - Basket naming configuration logic - Fallback behavior when purchase order number unavailable
Created attachment 184002 [details] [review] Bug 20253: Add po_is_basketname field to vendor_edi_accounts table This patch adds a new boolean field 'po_is_basketname' to the vendor_edi_accounts table to allow configuration of how basket names are used in EDIFACT. Changes: - Added atomicupdate for existing installations - Updated kohastructure.sql for new installations
Created attachment 184003 [details] [review] Bug 20253: DBIC Schema
Created attachment 184004 [details] [review] 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.
Created attachment 184005 [details] [review] Bug 20253: (follow-up) Add duplicate purchase order number validation When processing EDI quotes with purchase order numbers, validate that the purchase order number is unique for the vendor to prevent operational confusion. The validation: - Checks for existing baskets with the same purchase order number and vendor - Includes both open and closed baskets in the uniqueness check - Logs an error with the raw RFF+ON segment and details to the edifact_errors table - Continues processing (non-blocking) to prevent data loss - Provides system log warnings for monitoring The error logging includes: - Section: Raw RFF+ON segment (e.g., "RFF+ON:orders 23/1") - Details: Clear description of the duplicate purchase order number issue This ensures administrators can identify and resolve duplicate purchase order numbers while maintaining system functionality and audit trails.
Created attachment 184006 [details] [review] Bug 20253: (follow-up) Make basket name read-only when derived from EDI purchase order number When a basket is created from an EDI quote with the vendor EDI account configured to use purchase order numbers, the basket name should be protected from changes to maintain the integrity of the purchase order number reference. This patch: - Makes the basket name field read-only in the UI when the basket was created from EDI with purchase order number setting - Adds explanatory text when the field is protected - Implements server-side protection to prevent basket name changes even if the UI is bypassed - Preserves the original purchase order number derived name
Created attachment 184007 [details] [review] Bug 20253: (follow-up) Use purchase order number in BGM segment for outgoing ORDER messages When vendors are configured to use purchase order numbers for basket naming, the purchase order number should be included in outgoing ORDER messages as the document message number in the BGM segment for proper EDI workflow continuity. According to EDIFACT specifications, the purchase order number from incoming quote messages (RFF+ON segments) should be used as the document message number in the BGM segment of outgoing ORDER messages, rather than as a separate RFF+ON segment. This follow-up ensures that: 1. Purchase order numbers from incoming QUOTE messages are preserved 2. The same purchase order numbers are sent back in ORDER messages via BGM segment 3. Vendors receive the reference numbers they expect for order processing in the correct format. Implementation: - Added get_purchase_order_number() method to extract PO number from basket name when vendor is configured with 'po_is_basketname' - Modified beginning_of_message() to accept purchase order number parameter - Uses purchase order number in BGM segment when available, falls back to basketno - Added comprehensive tests for purchase order number handling in ORDER messages Test Plan: 1. Apply patches 2. Configure a vendor EDI account with "Basket name source" = "Purchase order number" 3. Process a QUOTE message containing RFF+ON segment 4. Verify basket is created with purchase order number as name 5. Generate ORDER message from the basket 6. Verify ORDER message contains purchase order number in BGM segment 7. Run tests: prove t/db_dependent/Koha/Edifact/Order.t This completes the round-trip EDI workflow for purchase order number handling according to EDIFACT standards: Quote RFF+ON → Basket Name → Order BGM
Created attachment 185221 [details] [review] Bug 20253: Add tests for RFF+ON segment handling and basket naming This patch adds tests for: 1. RFF+ON (Purchase Order Number) segment parsing in EDIFACT messages 2. Vendor configuration for basket naming preferences 3. Basket naming logic in QUOTE processing Test coverage includes: - Message-level RFF+ON segment extraction - Validation that RFF+ON processing stops at LIN segments - Multiple RFF segment handling - Database field storage and constraints - Basket naming configuration logic - Fallback behavior when purchase order number unavailable
Created attachment 185222 [details] [review] Bug 20253: Add po_is_basketname field to vendor_edi_accounts table This patch adds a new boolean field 'po_is_basketname' to the vendor_edi_accounts table to allow configuration of how basket names are used in EDIFACT. Changes: - Added atomicupdate for existing installations - Updated kohastructure.sql for new installations
Created attachment 185223 [details] [review] Bug 20253: DBIC Schema
Created attachment 185224 [details] [review] 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.
Created attachment 185225 [details] [review] Bug 20253: (follow-up) Add duplicate purchase order number validation When processing EDI quotes with purchase order numbers, validate that the purchase order number is unique for the vendor to prevent operational confusion. The validation: - Checks for existing baskets with the same purchase order number and vendor - Includes both open and closed baskets in the uniqueness check - Logs an error with the raw RFF+ON segment and details to the edifact_errors table - Continues processing (non-blocking) to prevent data loss - Provides system log warnings for monitoring The error logging includes: - Section: Raw RFF+ON segment (e.g., "RFF+ON:orders 23/1") - Details: Clear description of the duplicate purchase order number issue This ensures administrators can identify and resolve duplicate purchase order numbers while maintaining system functionality and audit trails.
Created attachment 185226 [details] [review] Bug 20253: (follow-up) Make basket name read-only when derived from EDI purchase order number When a basket is created from an EDI quote with the vendor EDI account configured to use purchase order numbers, the basket name should be protected from changes to maintain the integrity of the purchase order number reference. This patch: - Makes the basket name field read-only in the UI when the basket was created from EDI with purchase order number setting - Adds explanatory text when the field is protected - Implements server-side protection to prevent basket name changes even if the UI is bypassed - Preserves the original purchase order number derived name
Created attachment 185227 [details] [review] Bug 20253: (follow-up) Use purchase order number in BGM segment for outgoing ORDER messages When vendors are configured to use purchase order numbers for basket naming, the purchase order number should be included in outgoing ORDER messages as the document message number in the BGM segment for proper EDI workflow continuity. According to EDIFACT specifications, the purchase order number from incoming quote messages (RFF+ON segments) should be used as the document message number in the BGM segment of outgoing ORDER messages, rather than as a separate RFF+ON segment. This follow-up ensures that: 1. Purchase order numbers from incoming QUOTE messages are preserved 2. The same purchase order numbers are sent back in ORDER messages via BGM segment 3. Vendors receive the reference numbers they expect for order processing in the correct format. Implementation: - Added get_purchase_order_number() method to extract PO number from basket name when vendor is configured with 'po_is_basketname' - Modified beginning_of_message() to accept purchase order number parameter - Uses purchase order number in BGM segment when available, falls back to basketno - Added comprehensive tests for purchase order number handling in ORDER messages Test Plan: 1. Apply patches 2. Configure a vendor EDI account with "Basket name source" = "Purchase order number" 3. Process a QUOTE message containing RFF+ON segment 4. Verify basket is created with purchase order number as name 5. Generate ORDER message from the basket 6. Verify ORDER message contains purchase order number in BGM segment 7. Run tests: prove t/db_dependent/Koha/Edifact/Order.t This completes the round-trip EDI workflow for purchase order number handling according to EDIFACT standards: Quote RFF+ON → Basket Name → Order BGM
Created attachment 185228 [details] [review] 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