Bug 31157 - overdue_notices.pl --frombranch option should be available as a system preference
Summary: overdue_notices.pl --frombranch option should be available as a system prefer...
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Martin Renvoize
QA Contact: Testopia
URL:
Keywords:
: 28549 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-07-14 15:36 UTC by Martin Renvoize
Modified: 2023-12-28 20:43 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact: Caroline Cyr La Rose
Documentation submission: https://gitlab.com/koha-community/koha-manual/-/merge_requests/586
Text to go in the release notes:
This patch adds a new system preference "OverdueNoticeFrom" that overrides the --frombranch parameter of the overdue_notices.pl cronjob. This allows systems librarians the option to pick which address to use for overdues notices. The default value is "command-line option", meaning if there is a branch specified in the cronjob, the behavior will not change. **Sponsored by** *PTFS Europe*
Version(s) released in:
22.11.00


Attachments
Bug 31157: Allow selection for overdue from address in the UI (4.71 KB, patch)
2022-07-14 16:14 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 31157: Allow selection for overdue from address in the UI (4.78 KB, patch)
2022-07-14 18:04 UTC, Caroline Cyr La Rose
Details | Diff | Splinter Review
Bug 31157: Allow selection for overdue from address in the UI (4.84 KB, patch)
2022-07-22 15:58 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 31157: (QA follow-up) Update descriptions and wording of configuration options (5.41 KB, patch)
2022-07-22 15:58 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize 2022-07-14 15:36:15 UTC
On a multi-tenant system it is understandable for one client to want one options for the --frombranch and another to want another.  However, as the overdue job is run under cron.daily it's not trivial to change it on a per instance basis.. We should expose this option at the UI level.
Comment 1 Martin Renvoize 2022-07-14 16:14:05 UTC
Created attachment 137734 [details] [review]
Bug 31157: Allow selection for overdue from address in the UI

This patch adds a new system preference to allow systems librarians the
option to pick wich address to use for overdues notices.

We default to 'cron' to allow existing uses of '--frombranch' on the
command line to continue to function but now allow end users to override
this option via the new OverdueNoticeFrom preference.
Comment 2 Caroline Cyr La Rose 2022-07-14 18:03:31 UTC
To test:
1) Apply patch
2) Put different email addresses in branch A and branch B (doesn't have to be real email addresses, I used centerville@centerville.com and midway@midway.com)
   2.1) Go to Administration > Libraries
   2.2) Edit branch A (e.g. Centerville)
   2.3) Enter an email address in 'Email'
   2.4) Save
   2.5) Repeat steps 2.1 to 2.4 for branch B (e.g. Midway), making sure it is a different email address
3) Set up overdue notice triggers
   3.1) Go to Tools > Overdue notice/status triggers
   3.2) Enter a number of days for a patron category (e.g. Patron)
   3.3) Choose a letter to be sent (e.g. Overdue notice)
   3.4) Check the 'Email' box
   3.5) Save
4) Checkout an item from branch A to a patron while logged in at branch B
   4.1) In the top right corner, make sure you are connected at branch B (if not, click the branch name and choose set library)
   4.1) Go to Patrons
   4.2) Search for or add a patron in the patron category from 3.2
   4.3) Go to 'Check out'
   4.4) Click 'Checkout settings' and select a due date in the past, equal or greater than the number of days from 3.2
   4.5) Enter a barcode from an item from branch A and check out
5) Generate overdue notice
   5.1) In a terminal, run overdue_notices.pl (without any options)
   5.2) Search the database for the from_address of the overdue notice
        SELECT from_address FROM message_queue WHERE borrowernumber = XX;
   --> It should be branch B (script defaults to item-issuebranch)
6) Change OverdueNoticeFrom system preference to item home library
   6.1) Go to Administration > Global system preferences
   6.2) Search for OverdueNoticeFrom
   6.3) Choose the 'item home library' option
   6.4) Save
7) Delete notice and repeat
   7.1) Delete the notice from the database 
        DELETE FROM message_queue WHERE borrowernumber = XX;
   7.2) Repeat step 5
   --> The from_address should be branch A
8) Change OverdueNoticeFrom system preference to 'checkout library'
9) Delete notice and repeat
   --> The from_address should be branch B
   

I tried the following combinations
Item home library A, Checkout library B, syspref = system default,    cron = no option                     --> from_address is branch B (script defaults to item-issuebranch)
Item home library A, Checkout library B, syspref = item home library, cron = no option                     --> from_address is branch A (item home library according to syspref)
Item home library A, Checkout library B, syspref = checkout library,  cron = no option                     --> from_address is branch B (checkout library according to syspref)
Item home library A, Checkout library B, syspref = system default,    cron = --frombranch item-homebranch  --> from_address is branch A (item home library according to cron)
Item home library A, Checkout library B, syspref = system default,    cron = --frombranch item-issuebranch --> from_address is branch B (checkout library according to cron)
Item home library A, Checkout library B, syspref = item home library, cron = --frombranch item-issuebranch --> from_address is branch A (syspref overrides cron)
Item home library A, Checkout library B, syspref = checkout library,  cron = --frombranch item-homebranch  --> from_address is branch B (syspref overrides cron)
Comment 3 Caroline Cyr La Rose 2022-07-14 18:04:34 UTC
Created attachment 137736 [details] [review]
Bug 31157: Allow selection for overdue from address in the UI

This patch adds a new system preference to allow systems librarians the
option to pick wich address to use for overdues notices.

We default to 'cron' to allow existing uses of '--frombranch' on the
command line to continue to function but now allow end users to override
this option via the new OverdueNoticeFrom preference.

Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>
Comment 4 Katrin Fischer 2022-07-22 15:20:42 UTC
I've tried to understand how the code works and I think this doesn't quite work the option and the pref describe it:

Set the from address for the notice to one of 'item-homebranch' or 'item-issuebranch'.

1) Option influences item selection

To test: 
* In Centerville, check out:
* 1 item from Centerville
* 1 item from Fairview

Run the overdue_notices script with default/item-issuebranch setting:
* checkout library is used, 1 notice, listing both items

Run the overdue_notices script with item-homebranch setting:
* home library is used, 2 notices, each listing 1 item

Conclusion: this is not only about the from address setting, but more importantly it influence how the overdue items are grouped/selected.

2) Email settings

item-issuebranch
CPL is used 

item-homebranch
CPL and FPL are used, as you'd expect.

I feel like this works, but the descriptions make you think it's only about a specific email header setting, which is not true. It will use the 'email configuration' of either the home library or checkout library and it will group the overdue items accordingly.

I'll try to provide a follow-up with a suggestion for a slightly different wording.
Comment 5 Katrin Fischer 2022-07-22 15:22:11 UTC
Note: To me it looks like there is something wrong with the returnpath/Sender in the emails, but this is out of scope here. Reply-To is set as expected.
Comment 6 Katrin Fischer 2022-07-22 15:58:42 UTC
Created attachment 138044 [details] [review]
Bug 31157: Allow selection for overdue from address in the UI

This patch adds a new system preference to allow systems librarians the
option to pick wich address to use for overdues notices.

We default to 'cron' to allow existing uses of '--frombranch' on the
command line to continue to function but now allow end users to override
this option via the new OverdueNoticeFrom preference.

Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 7 Katrin Fischer 2022-07-22 15:58:48 UTC
Created attachment 138045 [details] [review]
Bug 31157: (QA follow-up) Update descriptions and wording of configuration options

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 8 Tomás Cohen Arazi 2022-07-22 18:19:17 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 9 Lucas Gass 2022-09-02 18:03:07 UTC
Enhancement will not be backported to 22.05.x series
Comment 10 Martin Renvoize 2022-09-22 09:24:17 UTC
Docs reviewed and merged, thanks Caroline.
Comment 11 Magnus Enger 2022-12-22 14:17:35 UTC
*** Bug 28549 has been marked as a duplicate of this bug. ***