https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39756

--- Comment #12 from ChloĆ© Zermatten <[email protected]> ---
Created attachment 208168
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208168&action=edit
Bug 39756: feat: route actions to processing queue

Part one of the process_circulation_triggers.pl script,
this retrieves overdue loans that are relevant to a given
script run, retrieves relevant overdue circulation rules,
and enqueue the actions to be taken when the processing
starts.

Nothing is enacted in this patch: we are only testing
that the script is detecting the right overdue loans,
and retrieving the correct rules.

Test plan:

Preparation: pick a patron P, an item I (note its home
library, itemtype), and check I out to P. Move the due date
so that it is overdue by 7 days.

For each scenario below, run the script with:
  perl misc/cronjobs/process_circulation_triggers.pl --debug

Note: for simplicity, this assumes a test instance with no
pre-existing overdues.

1. Test the default scenario:
   a. Ensure OverdueTriggersCalendar is off
   b. Check that CircControl is set to PatronLibrary
   c. Create a circulation trigger for P's library and category,
      and I's itemtype and set:
      - delay to 7
      - lost value to LOST,
      - restrict to 'yes'
   d. run the process_circulation_triggers script.
   e. notice the following results:
      Matched: 1; action_batch_queue has one entry, delay 7,
      actions { lost, restrict }
   f. Update your loan to set the due date 6 days ago
   g. run the script once again.
   i. Notice the following result:
      Matched: 0, no dump

2. Test a missed run (--date):
   a. Update your loan to set the due date 10 days ago
   b. Run the script.
   c. Notice the following result:
      Matched: 0
   d. Run the script again with --date set to 3 days ago
      (YYYY-MM-DD)
   e. Notice the following results:
      Trigger date: <the date you passed>
      Matched: 1; action_batch_queue has one entry, delay 7,
      actions { lost, restrict }

3. Test the calendar-adjusted delay:
   a. Turn OverdueTriggersCalendar on
   b. Set useDaysMode to 'Calendar'
   c. In Tools > Calendar, close P's library on each of
      the last 3 days (yesterday, 2 days ago, 3 days ago)
   d. Keep the due date at 10 days ago
   e. Run the script.
   f. Notice the following results:
      Matched: 1; action_batch_queue has one entry, delay 10,
      actions { lost, restrict }
      (7 open days back from today lands 10 calendar day)
   g. Turn OverdueTriggersCalendar off, run the script again
   h. Notice the following result:
      Matched: 0, action_batch_queue empty

4. Test a library closed on the run date:
   a. Turn OverdueTriggersCalendar on
   b. Update your loan to set the due date 7 days ago
   c. In Tools > Calendar, close P's library today
   d. Run the script.
   e. Notice the following result:
      Matched: 0, no dump

5. Test itemtype resolution under item-level_itypes:
   a. Set item-level_itypes to 'bibliographic record'
   b. Edit I's bibliographic record so its itemtype (942$c)
      differs from I's item type
   c. Create a circulation trigger specific to this new
      item type. Configure it with
      - restrict set to 'no'
      - delay set to 7
      - lost value to 'Lost'
   d. Run the script.
   e. Notice the following result:
      Matched: 1, action_batch_queue contains 'lost'
      and crucially, restrict => 0. This shows the correct
      rule set was applied - the one matching the biblio
      item type. (Otherwise we would have seen
      restrict => 1.)

6. Test rule resolution under CircControl:
   a. Reset item-level_itypes to 'specific item'
   b. Ensure I's home library is not P's library
   c. Set CircControl to 'the library the item is from',
      and HomeOrHoldingBranch to 'the item's home library
      (homebranch)'.
   d. Run the script
   e. Notice the following result:
      Matched: 1, action_batch_queue empty
      (the trigger is on P's library; rules now resolve on
      I's home library)
   f. Create a circulation trigger for I's home library, P's
      category,
      and I's itemtype, and set:
      - delay to 7
      - lost value to LOST
   g. Run the script.
   h. Notice the following result:
      action_batch_queue has one entry, delay 7, actions
      { lost }
   i. Set CircControl back to 'the library the patron is from'
   j. Run the script
   k. Notice the following result:
      action_batch_queue has one entry, delay 7, actions
      { lost, restrict }

7. Run the script with --dry-run --verbose
   a. Notice the DRY RUN header; nothing else differs from a
      normal run just yet.

Also run relevant test suite, including:
   prove t/db_dependent/Koha/Overdues/
   prove t/db_dependent/Koha/Library/Calendar.t
   prove t/db_dependent/Koha/CirculationRules.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/

Reply via email to