https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39756
--- Comment #14 from ChloƩ Zermatten <[email protected]> --- Created attachment 208170 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208170&action=edit Bug 39756: feat: enact notices - prepare and add to message queue Part three of the process_circulation_triggers.pl script. This processes the notice queue built in part two: for each patron it establishes once which transports can reach them, renders one letter per notice, transport and delay listing every item in it, and queues that letter in message_queue for SendQueuedMessages to send. Email and SMS notices for a patron who cannot receive them fall back to print, and only one print letter is produced per delay, in keep with overdue_notices.pl's behaviour. A notice already queued for the patron on the trigger date is not queued again, so a re-run on the same day is safe. With --date - the missed run recovery option - notices are dated to the day being replayed. Because we still rely on process_message_queue.pl to send out notices, you will need to wait for that script to run if you would like to see the notices being actually sent. Nothing is enacted in this patch: actions are routed but not yet carried out. Test plan: Preparation: pick a patron P with an email address, an item I, and check I out to P. Move the due date so that it is overdue by 7 days. Create a circulation trigger for P's library and category, and I's itemtype, and set: - delay to 7 - notice to ODUE - transport to email Run every step with: perl misc/cronjobs/process_circulation_triggers.pl --verbose Steps 1 and 2 add --dry-run: a notice queued today blocks the same notice for the rest of the day, so nothing is kept until step 3. Note: for simplicity, this assumes a test instance with no pre-existing overdues. 1. Test notices are added to the message queue: a. Check out an item I to a patron P1 with an email address, and move the due date so that it is overdue by 7 days b. Run the script. c. In the script output, under NOTICES ENQUEUED, notice one line: letter_code=ODUE mtt=email borrower=<P1> days_overdue=7 items=1 d. In the summary, notice: notices 1 queued, 0 suppressed e. On P1's record, Notices tab, notice one pending ODUE email listing I 2. Test a same-day re-run (expected outcome: no duplicates): a. Run the script again. b. In the script output, notice no line under NOTICES ENQUEUED c. In the summary, notice: notices 0 queued, 1 suppressed d. On P1's record, Notices tab, notice there is still only one ODUE email 3. Test one letter per notice, transport and delay: a. Create a second trigger in the same context: delay notice ODUE, transport email b. Check out three items to a patron P2 with an email I2 and I3 due 7 days ago, I4 due 14 days ago c. Run the script. d. In the script output, under NOTICES ENQUEUED, notice two lines for P2: letter_code=ODUE mtt=email borrower=<P2> days_overdue=7 items=2 letter_code=ODUE mtt=email borrower=<P2> days_over e. On P2's record, Notices tab, notice two pending ODUE emails: one listing I2 and I3, one listing I4 4. Test transport fallback: a. Edit trigger 1 so transport is both email and sms b. Check out an item I5 to a patron P3 with no email address and no SMS number, due 7 days ago c. Run the script. d. In the script output, under NOTICES ENQUEUED, notice a single line for P3: letter_code=ODUE mtt=print borrower=<P3> days_overdue=7 items=1 Email and sms both fall back to print, and only one print letter is produced per delay. (Print lines for P1 also appear: they have no SMS number either.) e. On P3's record, Notices tab, notice one pending ODUE print notice listing I5 f. Set trigger 1's transport back to email 5. Test a missed run (--date): a. Check out an item I6 to a patron P4 with an email address, due 10 days ago b. Run the script with --date set to 3 days ago (YYYY-MM-DD) c. In the script output, under NOTICES ENQUEUED, notice one line: letter_code=ODUE mtt=email borrower=<P4> days_over d. In the summary, notice: Trigger date: <the date you passed> notices 1 queued, 0 suppressed e. On P4's record, Notices tab, notice one pending ODUE email listing I6, dated 3 days ago f. Run the same command again g. In the summary, notice: notices 0 queued, 1 suppressed 6. Run the relevant test suites: prove t/db_dependent/Koha/Overdues/ 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/
