[Bug 40932] New: Automated trigger for invoice closure
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 Bug ID: 40932 Summary: Automated trigger for invoice closure Change sponsored?: --- Product: Koha Version: unspecified Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Acquisitions Assignee: koha-bugs@lists.koha-community.org Reporter: hdunne-howrie@westminster.gov.uk QA Contact: testopia@bugs.koha-community.org We would like to see the ability to set a trigger for a series of actions that would close an invoice automatically without us manually going into the invoice and ticking close and saving. We want to see a workflow whereby once all items associated to an invoice, when they are all returned for the first time this would trigger a cron job to close the invoice. This would help us to automate our acquisitions checking processes. Currently a staff member has to run a report and check in with staff to make sure they have returned items and then they spend a considerable time checking through for each invoice to make sure items have been physically received and then closing the invoice. If we can automate this last step so that when all items are checked in for the first time, the invoice will automatically close. It would also be useful to have this automatic action as a cron job so that if something goes wrong we could interrupt the next run and correct. Also, the ability to reopen the invoice is also the other failsafe. -- 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=40932 --- Comment #1 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- It sounds like this would be a good use case for a plugin that checks on item return if the invoice has already been closed etc. I think this would probably work with existing hooks. Libraries handle the closing of invoices very differently and I think as a general behavior this might not make as much sense. There is also work underway for a new acq module. -- 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=40932 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 CC| |martin.renvoize@openfifth.c | |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=40932 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Small patch Status|NEW |Needs Signoff Comma delimited| |OpenFifth list of Sponsors| |<https://openfifth.co.uk>, | |Royal Borough of Kensington | |and Chelsea | |<https://www.rbkc.gov.uk/>, | |Westminster City Council | |<https://www.westminster.go | |v.uk/> Sponsorship status|--- |Sponsored -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 --- Comment #2 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 194385 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=194385&action=edit Bug 40932: Add received column to aqorders_items and system preferences Adds aqorders_items.received (datetime, nullable) to track when an item was first physically received via circulation check-in. Adds system preferences: - AutoCloseInvoicesOnCheckin (YesNo, default off) - AutoCloseInvoiceAlertDays (Integer, default 14) 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 --- Comment #3 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 194386 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=194386&action=edit Bug 40932: Automated Schema Update 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 --- Comment #4 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 194387 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=194387&action=edit Bug 40932: Add automatic invoice closing on physical item receipt Adds AutoCloseInvoicesOnCheckin and AutoCloseInvoiceAlertDays system preferences. On every circulation check-in, if the item is linked to a non-cancelled acquisitions order, aqorders_items.received is stamped with the current datetime (first check-in only). If AutoCloseInvoicesOnCheckin is enabled and all items on the invoice are now received, the invoice is closed automatically. New Koha::Acquisition::Invoice::check_and_close() method contains the close logic using DBIC queries. C4::Acquisition::CheckAndCloseInvoice() is a thin wrapper for backward compatibility. Additional features: - "Check & close if all items received" button on the invoice page (acqui/invoice.pl + invoice.tt) - Batch "Close completed invoices" tool (acqui/close-completed-invoices.pl + close-completed-invoices.tt) - Staff home page alert when open invoices have items outstanding for more than AutoCloseInvoiceAlertDays days (mainpage.pl + intranet-main.tt) 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 --- Comment #5 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 194388 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=194388&action=edit Bug 40932: Add tests for automatic invoice closing Add unit tests covering the check_and_close() method and _record_physical_receipt integration via AddReturn, including the AutoCloseInvoicesOnCheckin preference. Also fix _record_physical_receipt to use get_column('invoiceid') instead of ->invoiceid on a raw DBIC Aqorder result, where the relationship accessor of the same name shadows the column accessor. 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 --- Comment #6 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 194389 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=194389&action=edit Feature proposal -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hdunne-howrie@westminster.g | |ov.uk -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |42890 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42890 [Bug 42890] EDI INVOIC processing should create/link items in aqorders_items when AcqCreateItem=receiving -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #194385|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=40932 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #194386|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=40932 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #194387|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=40932 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #194388|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=40932 --- Comment #7 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 200821 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200821&action=edit Bug 40932: Add received column to aqorders_items and system preferences Adds aqorders_items.received (datetime, nullable) to track when an item was first physically received via circulation check-in. Adds system preferences: - AutoCloseInvoicesOnCheckin (YesNo, default off) - AutoCloseInvoiceAlertDays (Integer, default 14) 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 --- Comment #8 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 200822 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200822&action=edit Bug 40932: Automated Schema Update 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 --- Comment #9 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 200823 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200823&action=edit Bug 40932: Add automatic invoice closing on physical item receipt Adds AutoCloseInvoicesOnCheckin and AutoCloseInvoiceAlertDays system preferences. On every circulation check-in, if the item is linked to a non-cancelled acquisitions order, aqorders_items.received is stamped with the current datetime (first check-in only). If AutoCloseInvoicesOnCheckin is enabled and all items on the invoice are now received, the invoice is closed automatically. New Koha::Acquisition::Invoice::check_and_close() method contains the close logic using DBIC queries. C4::Acquisition::CheckAndCloseInvoice() is a thin wrapper for backward compatibility. Additional features: - "Check & close if all items received" button on the invoice page (acqui/invoice.pl + invoice.tt) - Batch "Close completed invoices" tool (acqui/close-completed-invoices.pl + close-completed-invoices.tt) - Staff home page alert when open invoices have items outstanding for more than AutoCloseInvoiceAlertDays days (mainpage.pl + intranet-main.tt) 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 --- Comment #10 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 200824 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200824&action=edit Bug 40932: Add tests for automatic invoice closing Add unit tests covering the check_and_close() method and _record_physical_receipt integration via AddReturn, including the AutoCloseInvoicesOnCheckin preference. Also fix _record_physical_receipt to use get_column('invoiceid') instead of ->invoiceid on a raw DBIC Aqorder result, where the relationship accessor of the same name shadows the column accessor. 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 --- Comment #19 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201856 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201856&action=edit Bug 40932: Add tests for automatic invoice closing Covers Koha::Acquisition::Invoice::check_and_close (all-received closes, an unreceived item blocks, cancelled order lines are excluded, an invoice with no linked items stays open, already-closed is a no-op, and aggregation across multiple active orders) and Koha::Acquisition::Order::Item::record_physical_receipt via the real AddIssue/AddReturn circulation flow (first-checkin stamps received and auto-closes when enabled, a second check-in does not overwrite it, the whole feature is a no-op when AutoCloseInvoicesOnCheckin is disabled, no matching aqorders_items row is a no-op, AcqCreateItem policies other than "ordering" are a no-op, a cancelled order is a no-op, an order with no linked invoice is a no-op, and a DB failure inside record_physical_receipt is swallowed so check-in still succeeds). 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 --- Comment #16 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201853 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201853&action=edit Bug 40932: Automated Schema Update 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 --- Comment #18 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201855 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201855&action=edit Bug 40932: Add automatic invoice closing on physical item receipt On circulation check-in (AddReturn), if the checked-in item is linked to a non-cancelled acquisitions order and the AutoCloseInvoicesOnCheckin system preference is enabled, aqorders_items.received is stamped with the current datetime (first check-in only) and the linked invoice is closed if every item on every non-cancelled order line of that invoice has now been received. The whole feature - both the stamp and the close - is gated behind the preference, so libraries who leave it disabled see no extra queries on this hot circulation path. New Koha::Acquisition::Order::Item/Items classes wrap aqorders_items. Koha::Acquisition::Invoice gains check_and_close(), independent of the AutoCloseInvoicesOnCheckin preference so it can also be triggered manually or in bulk. Additional features: - "Check & close if all items received" button on the invoice page (acqui/invoice.pl + invoice.tt), surfacing closed/not_ready/error results distinctly. - Batch "Close completed invoices" tool (acqui/close-completed-invoices.pl + close-completed-invoices.tt), implemented as a Koha::BackgroundJob (Koha::BackgroundJob::CloseCompletedInvoices) so a large open-invoice backlog doesn't block the CGI process; per-invoice results distinguish closed/not_ready/error in the job report. - Staff home page alert when open invoices have items outstanding for more than AutoCloseInvoiceAlertDays days (mainpage.pl + intranet-main.tt), cached for a day at a time since the underlying query joins aqinvoices/aqorders/aqorders_items. Failures caught internally are logged via Koha::Logger rather than a bare warn. 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #201814|0 |1 is obsolete| | Attachment #201815|0 |1 is obsolete| | Attachment #201816|0 |1 is obsolete| | Attachment #201817|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=40932 --- Comment #15 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201852 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201852&action=edit Bug 40932: Add received column to aqorders_items and system preferences Adds aqorders_items.received (datetime, nullable) to track when an item was first physically received via circulation check-in, with a supporting index for the lookups added later in this series. Adds system preferences, both disabled by default so the feature is fully opt-in: - AutoCloseInvoicesOnCheckin (YesNo, default off) - AutoCloseInvoiceAlertDays (Integer, default off/0) Also indexes aqinvoices.closedate and aqinvoices.shipmentdate, used by the staff home page alert query added later in this series. 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 --- Comment #17 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201854 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201854&action=edit Bug 40932: Add koha_object_class mapping for AqordersItem Maps the AqordersItem DBIC source to the new Koha::Acquisition::Order::Item and Koha::Acquisition::Order::Items classes added later in this series. 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 --- Comment #12 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201815 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201815&action=edit Bug 40932: Automated Schema Update 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 --- Comment #14 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201817 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201817&action=edit Bug 40932: Add tests for automatic invoice closing Add unit tests covering the check_and_close() method and _record_physical_receipt integration via AddReturn, including the AutoCloseInvoicesOnCheckin preference. Also fix _record_physical_receipt to use get_column('invoiceid') instead of ->invoiceid on a raw DBIC Aqorder result, where the relationship accessor of the same name shadows the column accessor. 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #200821|0 |1 is obsolete| | Attachment #200822|0 |1 is obsolete| | Attachment #200823|0 |1 is obsolete| | Attachment #200824|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=40932 --- Comment #13 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201816 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201816&action=edit Bug 40932: Add automatic invoice closing on physical item receipt Adds AutoCloseInvoicesOnCheckin and AutoCloseInvoiceAlertDays system preferences. On every circulation check-in, if the item is linked to a non-cancelled acquisitions order, aqorders_items.received is stamped with the current datetime (first check-in only). If AutoCloseInvoicesOnCheckin is enabled and all items on the invoice are now received, the invoice is closed automatically. New Koha::Acquisition::Invoice::check_and_close() method contains the close logic using DBIC queries. C4::Acquisition::CheckAndCloseInvoice() is a thin wrapper for backward compatibility. Additional features: - "Check & close if all items received" button on the invoice page (acqui/invoice.pl + invoice.tt) - Batch "Close completed invoices" tool (acqui/close-completed-invoices.pl + close-completed-invoices.tt) - Staff home page alert when open invoices have items outstanding for more than AutoCloseInvoiceAlertDays days (mainpage.pl + intranet-main.tt) 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40932 --- Comment #11 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201814 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201814&action=edit Bug 40932: Add received column to aqorders_items and system preferences Adds aqorders_items.received (datetime, nullable) to track when an item was first physically received via circulation check-in. Adds system preferences: - AutoCloseInvoicesOnCheckin (YesNo, default off) - AutoCloseInvoiceAlertDays (Integer, default 14) 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> -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org