https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39756
--- Comment #16 from ChloƩ Zermatten <[email protected]> --- Created attachment 208187 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208187&action=edit Bug 39756: feat: enact actions Part four of the process_circulation_triggers.pl script. This carries out the actions routed in part one, for each overdue loan, in a fixed order when more than one exist for a given delay, for a given context. The order is specified as restrict, forgive the overdue fine, set lost, charge the replacement cost, mark returned. Actions run after notices are queued, so a letter on a trigger that also acts describes the loan as it stood before the action: the fine still outstanding, the item not yet lost. Lost is set through a new Koha::Item->mark_lost: it sets the item's lost status, moves the loan's accruing overdue fine to LOST (deleting it if it is a zero-amount line with no credits), and cancels any outstanding transfers. Since this is only useful to this script at this time, it is submitted as part of 39756 rather than as its own bug (not testable if extracted). Once a patron's loans have been marked returned, their OVERDUES restriction is lifted where AutoRemoveOverduesRestrictions allows, once per patron. Re-runs are safe: a patron holds a single OVERDUES restriction, and an item is charged its replacement cost once per loan. With --dry-run everything is rolled back, and no search index update or holds queue job is triggered. Test plan: Preparation: ensure OverdueTriggersCalendar is off and C is set to PatronLibrary. Every trigger below is created for the patrons' library and category, and the items' itemtype. Each step uses its own patron and its own delay, so steps do not interfere. Run every step with: perl misc/cronjobs/process_circulation_triggers.pl --verbose Results are read in three places: - the script output, under ACTION ENACTED: one line per action - the summary at the end of the script output - the staff interface, on the patron's and item's records Each run acts on every matching loan, so lines for patrons from earlier steps may also appear: look for the step's own patron. Note: for simplicity, this assumes a test instance with pre-existing overdues. 1. Test restrict: a. Create a default trigger: delay 7, restrict 'yes' b. Check out an item I1 to a patron P1, due 7 days ag c. Run the script d. In the script output, under ACTION ENACTED, notice: type=restrict value=1 borrower=<P1> item=<I1> days e. In the summary, notice: restricted 1 patrons f. On P1's record, notice one OVERDUES restriction g. Run the script again, and notice P1 still has a single OVERDUES restriction 2. Test lost and charge: a. Create a default trigger: delay 14, lost value 'Lost', charge 'yes' b. Give an item I2 a replacement price of 5.00, check it out to a patron P2, due 14 days ago c. Run the script d. In the script output, under ACTION ENACTED, notice, in this order: type=lost value=1 borrower=<P2> item=<I2> days_ove type=charge value=1 borrower=<P2> item=<I2> days_overdue=14 e. In the summary, notice: lost 1 items charged 1 items f. On I2's record, notice it is lost; on P2's record, Accounting tab, notice one lost item fee of 5.00 g. Run the script again, and notice P2 still has a single lost item fee, and the summary has no 'charged' line 3. Test forgiving the overdue fine: a. Make sure the circulation rules for this context charge fines (fine amount and fine charging interval set) b. Create a trigger: delay 21, forgive fine 'yes' c. Check out an item I3 to a patron P3, due 21 days ago d. Run misc/cronjobs/fines.pl, and notice an accruing overdue fine on P3's record, Accounting tab e. Run the script f. In the script output, under ACTION ENACTED, notice: type=forgive_fine value=1 borrower=<P3> item=<I3> days_overdue=21 g. In the summary, notice: forgiven 1 fines h. On P3's record, Accounting tab, notice the overdue fine is forgiven and nothing is outstanding 4. Test mark returned and restriction lifting: a. Set AutoRemoveOverduesRestrictions to 'if patron has no remaining overdue items' b. Create a trigger: delay 28, mark returned 'yes' c. Check out an item I4 to a patron P4, due 7 days ago d. Run the script, and notice P4 now has an OVERDUES restriction (from the trigger in step 1) e. Update the loan to set the due date 28 days ago f. Run the script g. In the script output, under ACTION ENACTED, notice: type=mark_returned value=1 borrower=<P4> item=<I4> h. In the summary, notice: returned 1 items lifted 1 restrictions i. On P4's record, notice I4 is no longer checked out, and the OVERDUES restriction is gone j. Set AutoRemoveOverduesRestrictions back to "don't" 5. Test notices are processed before actions: a. Edit the delay 14 trigger to also set notice ODUE, transport email b. Give an item I5 a replacement price, check it out to a patron P5 with an email address, due 14 days ago c. Run the script d. In the script output, notice the NOTICES ENQUEUED section, with a line for P5, comes before ACTION ENACTED e. On P5's record, Notices tab, notice one pending ODUE email listing I5 6. Test a dry run: a. Give an item I6 a replacement price, check it out P6, due 14 days ago b. Run the script with --dry-run c. In the script output, notice the DRY RUN header, and lost and charge lines for P6 under ACTION ENACTED d. On I6's record, notice it is not lost; on P6's record, Accounting tab, notice no lost item fee 7. Run the relevant test suites: prove t/db_dependent/Koha/Overdues/ prove t/db_dependent/Koha/Item.t Sponsored-by: Black Hills Library Consortium- http://www.rcgov.org/Library/ Assisted-by: Claude Opus 5 (Anthropic) -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list -- [email protected] To unsubscribe send an email to [email protected] website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
