[Bug 43875] New: Do not auto-close invoices that have EDIFACT processing errors
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43875 Bug ID: 43875 Summary: Do not auto-close invoices that have EDIFACT processing errors 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 Depends on: 40932 Target Milestone: --- Bug 40932 adds three ways of closing an invoice automatically, and all of them call Koha::Acquisition::Invoice::check_and_close: circulation check-in when AutoCloseInvoicesOnCheckin is set, the "close completed invoices" background job, and the "check and close" action on the invoice page. check_and_close closes an invoice when every item on its non-cancelled orders has been received. It only looks at the orders that are linked to the invoice. An invoice line that EDI processing could not receive is not linked to it, so check_and_close cannot see it. For example, since bug 43756 an invoice line that refers to a cancelled order is skipped and an error is recorded in edifact_errors; the same happens for a line with no order number, an unknown order, or an order whose record has been deleted. The supplier has invoiced for those lines, so the invoice total in Koha is less than the supplier's and part of the invoice has not been dealt with. Once the other items are checked in, the invoice is closed automatically. Closing an invoice is often what triggers a finance integration to pay it, so an invoice that includes a line for something cancelled and never received could be paid in full, or the shortfall could go unnoticed. Proposed change: check_and_close does not close an invoice that has EDIFACT processing errors, and returns 0 as it does for an invoice that is not ready. The errors that count are those for the invoice (the same invoice number in the message) and the message-level ones that affect the whole file, as shown on the invoice page under "Processing errors". Staff can still close the invoice by hand once they have checked it with the supplier. A method on the invoice returns those errors, and the invoice page uses it instead of repeating the query. This is deliberately cautious: any recorded error, including a warning such as an invoice line for an order that is already complete, keeps an invoice from closing automatically. A flag that only covers the lines that were skipped would be more precise, but needs a change to the database. Related to bug 43756. Test plan: 1. Set AutoCloseInvoicesOnCheckin. Receive an EDIFACT invoice for two orders with items, where one line refers to an order that has been cancelled 2. Check in all the items of the order that was received 3. Without the patch: the invoice is closed 4. With the patch: the invoice stays open and the invoice page shows the processing error 5. Check and close the invoice from the invoice page, or run the close completed invoices job => the invoice is still open 6. Close the invoice by hand => it closes Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 [Bug 40932] Automated trigger for invoice closure -- 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=43875 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 the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43875 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 208629 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208629&action=edit Bug 43875: Do not auto-close invoices that have EDIFACT processing errors Bug 40932 closes an invoice automatically, when every item on its non-cancelled orders has been received, from circulation check-in, from the close completed invoices job and from the "check and close" action on the invoice page. All three call Koha::Acquisition::Invoice::check_and_close. It only looks at the orders that are linked to the invoice. An invoice line that EDI processing could not receive, because it refers to a cancelled order, has no order number, an unknown order or a deleted record, is not linked to the invoice, so it cannot be seen here. The supplier has invoiced for the line, so the invoice total in Koha is short, and once the other items are checked in the invoice is closed. Closing an invoice is often what triggers a finance integration to pay it, so a line for something that was cancelled and never received could be paid, or the shortfall could go unnoticed. check_and_close now returns 0, as it does for an invoice that is not ready, when the invoice has EDIFACT processing errors. The invoice can still be closed by hand once staff have checked it with the supplier. The errors that count are those recorded for the invoice number in the message the invoice came from, and the message-level ones that affect the whole file, as the invoice page shows under "Processing errors". Koha::Acquisition::Invoice::edifact_errors returns them, and acqui/invoice.pl uses it instead of repeating the query. This is deliberately cautious: any recorded error, including a warning such as a line for an order that is already complete, keeps an invoice from closing automatically. A flag for only the lines that were skipped would be more precise but needs a change to the database. Test plan: 1. Apply the patch 2. prove t/db_dependent/Circulation/AutoCloseInvoiceOnCheckin.t => the subtest 'check_and_close: EDIFACT processing errors keep invoice open' passes 3. Set AutoCloseInvoicesOnCheckin. Receive an EDIFACT invoice for two orders with items, where one line refers to an order that has been cancelled 4. Check in all the items of the order that was received => the invoice stays open and the invoice page shows the processing error 5. Use "check and close" on the invoice page, or run the close completed invoices job => the invoice is still open 6. Close the invoice by hand => it closes Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43875 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=43875 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.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org