Koha Test Wiki Canasta - March 2024
One of a series of test instances for migrating the Koha Wiki MediaWiki database.
For the current Koha Wiki, visit https://wiki.koha-community.org .Overdues module rewrite RFC
Jump to navigation
Jump to search
The current overdues-module is old, fragmented and hard to modify and test. Most notoriously the overdue_notices.pl with 500 lines of code long nested loop with jump statements. Also the tools/overduerules.pl has all the CRUD-operations coded into the script, making CRUD operations for overdues very hard to test, or use in other related test cases.
The module needs to be refactored to something more MVC, and to use the new Koha-features: Koha::Object, Koha::Cache, DBIx, Cucumber- and Selenium-tests.
I am currently rewriting the module, and it looks like the architecture might stand as follow:
- Koha::Overdues::OverdueRule-object, containing overdueRules (delay, debarred, letterCode, fine, message_transport_types, ...) for each branchcode->borrowerCategory->letterNumber.
- Koha::Overdues::OverdueRulesMap-object, which receives all CRUD-operations for the OverdueRules and also helps in finding the correct OverdueRule for the given scenario, eg. by being given an MessageQueue-object or some parameters, like branchCode, borrowerCategory, letterNumber.
- C4::Overdues::Controller-object, to manage higher level operations, like finding and enqueuing new overdue notifications from Issues, or sending overdue notifications using various message transport types and subclassable PrintProviders to easily integrate to 3rd party printing services.
- C4::Overdues::Finder-object, does the work of finding Issues which could trigger different overdue notifications, and makes sure that letter1 and letter2 and letter3 always have the same delay between them, regardless of failures in message sending, so we wont accidentally send all overdue notices at once when the error in message sending has been resolved.
- C4::Overdues::Builder-object, builds the MessageQueue-objects and MessageQueueItem-objects from the Found overdue Issues, and also deals with migrating data from old message_queue-rows to the new message_queue_items-table.
- Koha::PrintProviderInterface-interface, allows consistent subclassing of various PrintProviders to deal with various ways of sending print-messages from Koha. Eg. sending notifications to be printed to a printing press using a special format using Koha::PrintProvider::Enfo (for Enfo Zender), or just using the old Koha-way with Koha::PrintProvider::Manual. The desired PrintProvider is configurable from the system preferences. PrintProvider also implemets a fine generation mechanism of adding a fine for the borrower based on the OverdueRule.