[Bug 43790] New: EDIFACT messages Import button always runs the invoice importer, even for quotes
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43790 Bug ID: 43790 Summary: EDIFACT messages Import button always runs the invoice importer, even for quotes Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Acquisitions Assignee: koha-bugs@lists.koha-community.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org Target Milestone: --- The EDIFACT messages page (acqui/edifactmsgs.pl) shows an Import button for any message whose status is 'new', whatever its type, and op=import always calls process_invoice(). The button was added by Bug 23682 for invoices when EdifactInvoiceImport is set to 'manual', but nothing restricts it to invoices. If an inbound QUOTE (or ORDRSP) is left at status 'new' -- for example because edi_cron.pl did not get as far as processing it -- the button appears and clicking it runs the invoice importer on the quote. Quote lines carry RFF+QLI rather than RFF+LI, so every line is skipped with "Skipped invoice line N, missing ordernumber" in the EDI errors, an empty aqinvoices row is created for the quote's BGM document number on every click, and the message is marked 'received' without ever creating a basket. Further problems in the same code path: - op=import is a GET link rather than a cud- POST with a CSRF token, unlike the Delete button next to it. - The script does not check the message is still 'new', so a repeated or stale request imports it again and creates duplicate invoice headers. Proposed fix: offer Import for any unprocessed inbound message (QUOTE, INVOICE, ORDRSP) and dispatch on message_type to process_quote, process_invoice or process_ordrsp via a new Koha::EDI::process_message. Outbound ORDERS messages are not importable. Make the action a cud-import POST with CSRF token and only act on messages still in status 'new'. Test plan: 1. Enable EDIFACT. Insert (or download) an EDI message of type QUOTE with a valid quote in raw_msg, status 'new', for a vendor with an EDI account. 2. Go to Acquisitions > EDIFACT messages. 3. Without the patch: click Import. The invoice importer runs: an aqinvoices row is created, "missing ordernumber" errors are recorded and no basket exists. 4. Restore the message to status 'new' and apply the patch. 5. Reload: Import is shown for QUOTE, INVOICE and ORDRSP messages with status 'new' and not for ORDERS or already processed messages. 6. Click Import on the QUOTE: a basket is created from the quote and no invoice or error rows are created. Check an INVOICE (manual import mode) and an ORDRSP are processed by their own importer as well. 7. prove t/db_dependent/Koha/EDI.t -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43790 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 207816 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207816&action=edit Bug 43790: Dispatch EDIFACT message Import by message type The Import button on the EDIFACT messages page was shown for any message with status 'new' and always called process_invoice. Importing a QUOTE that way ran the invoice importer on it: every line was skipped with "missing ordernumber", an empty invoice header was created per click and the quote was marked received without a basket. Add Koha::EDI::process_message, which dispatches QUOTE, INVOICE and ORDRSP messages to process_quote, process_invoice and process_ordrsp and throws for anything else (outbound ORDERS). The Import button is now shown for unprocessed inbound messages of those types, is a cud-import POST with a CSRF token like Delete, and the script only imports messages still in status 'new'. Test plan: 1. prove t/db_dependent/Koha/EDI.t 2. Insert a 'new' QUOTE, an ORDERS and a processed QUOTE message in edifact_messages and open Acquisitions > EDIFACT messages 3. Import is shown only for the 'new' QUOTE 4. Click Import: a basket is created from the quote, no invoice or "missing ordernumber" errors are created 5. Repeat for INVOICE (EdifactInvoiceImport = manual) and ORDRSP Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43790 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |23682 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23682 [Bug 23682] Add ability to manually import EDI invoices as an alternative to automatic importing on download -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43790 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43790 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43790 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |kyle@bywatersolutions.com |y.org | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43790 Kyle M Hall (khall) <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43790 Kyle M Hall (khall) <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #207816|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43790 --- Comment #2 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- Created attachment 207958 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207958&action=edit Bug 43790: Dispatch EDIFACT message Import by message type The Import button on the EDIFACT messages page was shown for any message with status 'new' and always called process_invoice. Importing a QUOTE that way ran the invoice importer on it: every line was skipped with "missing ordernumber", an empty invoice header was created per click and the quote was marked received without a basket. Add Koha::EDI::process_message, which dispatches QUOTE, INVOICE and ORDRSP messages to process_quote, process_invoice and process_ordrsp and throws for anything else (outbound ORDERS). The Import button is now shown for unprocessed inbound messages of those types, is a cud-import POST with a CSRF token like Delete, and the script only imports messages still in status 'new'. Test plan: 1. prove t/db_dependent/Koha/EDI.t 2. Insert a 'new' QUOTE, an ORDERS and a processed QUOTE message in edifact_messages and open Acquisitions > EDIFACT messages 3. Import is shown only for the 'new' QUOTE 4. Click Import: a basket is created from the quote, no invoice or "missing ordernumber" errors are created 5. Repeat for INVOICE (EdifactInvoiceImport = manual) and ORDRSP Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43790 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |41852 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41852 [Bug 41852] Modernize EDI support in Koha -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43790 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |41087 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41087 [Bug 41087] EDI Retry: Add Rollback and Reprocess actions for EDIFACT messages -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43790 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |39215, 42001 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39215 [Bug 39215] EDIFACT quote files should skip orders that cannot be processed rather than failing to complete https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42001 [Bug 42001] Update duplicate purchase order number detection on EDI quote import to optionally send notifications to staff and vendors -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43790 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks|41852 | Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41852 [Bug 41852] Modernize EDI support in Koha -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43790 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #207958|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43790 --- Comment #3 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 208007 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208007&action=edit Bug 43790: Dispatch EDIFACT message Import by message type The Import button on the EDIFACT messages page was shown for any message with status 'new' and always called process_invoice. Importing a QUOTE that way ran the invoice importer on it: every line was skipped with "missing ordernumber", an empty invoice header was created per click and the quote was marked received without a basket. Add Koha::EDI::process_message, which dispatches QUOTE, INVOICE and ORDRSP messages to process_quote, process_invoice and process_ordrsp and throws for anything else (outbound ORDERS). The Import button is now shown for unprocessed inbound messages of those types, is a cud-import POST with a CSRF token like Delete, and the script only imports messages still in status 'new'. Test plan: 1. prove t/db_dependent/Koha/EDI.t 2. Insert a 'new' QUOTE, an ORDERS and a processed QUOTE message in edifact_messages and open Acquisitions > EDIFACT messages 3. Import is shown only for the 'new' QUOTE 4. Click Import: a basket is created from the quote, no invoice or "missing ordernumber" errors are created 5. Repeat for INVOICE (EdifactInvoiceImport = manual) and ORDRSP Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43790 --- Comment #4 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Refreshed the patch on top of the pending EDIFACT patches from bug 39215 and bug 42001 (now listed as dependencies): the only change is the test count in t/db_dependent/Koha/EDI.t, which now has to be 14 rather than 12. Kyle's sign-off is carried over unchanged. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org