Bug 18398 - CHECKIN/CHECKOUT/RENEWAL don't use AutoEmailPrimaryAddress but first valid e-mail
Summary: CHECKIN/CHECKOUT/RENEWAL don't use AutoEmailPrimaryAddress but first valid e-...
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Martin Renvoize (ashimema)
QA Contact: Testopia
URL:
Keywords:
: 20228 (view as bug list)
Depends on:
Blocks: 33223
  Show dependency treegraph
 
Reported: 2017-04-07 13:08 UTC by Katrin Fischer
Modified: 2023-12-28 20:42 UTC (History)
11 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
This enhancement applies the EmailFieldPrimary (formerly AutoEmailPrimaryAddress) system preference choice to the CHECKIN, CHECKOUT, RENEWAL and various RECALL notices.
Version(s) released in:
23.05.00,22.11.06,22.05.13
Circulation function:


Attachments
Bug 18398: Update C4::Message enqueue to use $patron->notice_email_address (4.49 KB, patch)
2023-03-10 10:05 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 18398: Update C4::Message enqueue to use $patron->notice_email_address (4.56 KB, patch)
2023-03-13 16:36 UTC, Caroline Cyr La Rose
Details | Diff | Splinter Review
Bug 18398: Update C4::Message enqueue to use $patron->notice_email_address (4.56 KB, patch)
2023-03-28 12:36 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 18398: (follow-up) Update POD & Unit tests (3.52 KB, patch)
2023-03-28 12:36 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 18398: Update C4::Message enqueue to use $patron->notice_email_address (4.61 KB, patch)
2023-03-28 15:02 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 18398: (follow-up) Update POD & Unit tests (3.58 KB, patch)
2023-03-28 15:02 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Katrin Fischer 2017-04-07 13:08:04 UTC
If the system preference AutoEmailPrimaryAddress is set to alternate or work this e-mail addresses should be used to send out all emails.

This works for most notices, but sadly not for CHECKIN, CHECKOUT and RENEWAL notices. 

http://git.koha-community.org/gitweb/?p=koha.git;a=blob;f=C4/Message.pm;hb=7d35bdf58a0bcebab20df47b50b249cafe12ddb6#l178
sub _to_address is hardcoded to use the first e-mail field that is set in the patron record.

It should follow the AutoEmailPrimaryAddress setting instead.

Bug 12802 fixed it, but it's a new feature. Woudl still be good to fix this especially for stable releases.
Comment 1 Katrin Fischer 2019-03-12 07:07:24 UTC
Still valid, especially since bug 12802 is currently sitting in FQA.
Comment 3 Martin Renvoize (ashimema) 2023-03-10 09:48:39 UTC
*** Bug 20228 has been marked as a duplicate of this bug. ***
Comment 4 Martin Renvoize (ashimema) 2023-03-10 10:05:47 UTC
Created attachment 148053 [details] [review]
Bug 18398: Update C4::Message enqueue to use $patron->notice_email_address

This patch updates the enque method in C4::Message to expect a
Koha::Patron object in the parameters and then uses that patron object
to select the correct email address for notices as defined by
AutoEmailPrimaryAddress.
Comment 5 Martin Renvoize (ashimema) 2023-03-10 10:06:27 UTC
This affects the notices Katrin mentions and also Recalls notices as that module has since been pushed and also uses the C4::Message module.
Comment 6 Caroline Cyr La Rose 2023-03-13 16:32:21 UTC
Behold, the monstruous test plan! *thunder crackles*

To test CHECKIN/CHECKOUT/RENEWAL with AutoEmailPrimaryAddress

1. Set RenewalSendNotice to 'Send'

2. Change email addresses of a patron (I used Edna Acosta)
   - In the 'Primary email' field, enter something like primary@...
   - In the 'Secondary email' field, enter something like secondary@...
   - In the 'Email' field of the 'Alternate address' section, enter something like alternate@...
   
3. Change messaging preferences of the same patron
   - Item check-in = email
   - Item checkout and renewal = email
   
4. Set AutoEmailPrimaryAddress to primary email address (home)
   
5. Check out an item to the patron

6. Check the to_address in the message_queue table for CHECKOUT, it should be primary@...

select to_address, letter_code, time_queued from message_queue where date(time_queued) = curdate();

7. Renew the checkout

8. Check the to_address in the message_queue table for RENEWAL, it should be primary@...

select to_address, letter_code, time_queued from message_queue where date(time_queued) = curdate();

9. Check in the item

10. Check the to_address in the message_queue table for CHECKIN, it should be primary@...

select to_address, letter_code, time_queued from message_queue where date(time_queued) = curdate();

11. Delete the messages from the message_queue.

delete from message_queue where to_address like 'primary%';

12. Change AutoEmailPrimaryAddress to secondary email address (work)

13. Redo steps 5 to 10. The address in the message_queue table should now be secondary@...

14. Delete the messages from the message_queue.

delete from message_queue where to_address like 'secondary%';

15. Change AutoEmailPrimaryAddress to alternate email address (alternate)

16. Redo steps 5 to 10. The address in the message_queue table should now be alternate@...

17. Delete the messages from the message_queue.

delete from message_queue where to_address like 'alternate%';

18. Change AutoEmailPrimaryAddress to cardnumber as

19. Redo steps 5 to 10. The address in the message_queue table should now be the patron's cardnumber

20. Delete the messages from the message_queue.

delete from message_queue where to_address = '23529001000463';

21. Change AutoEmailPrimaryAddress to first valid

22. Redo steps 5 to 10. The address in the message_queue table should now be primary@...

23. Delete the messages from the message_queue.

delete from message_queue where to_address like 'primary%';

24. Remove the patron's primary email address

25. Redo steps 5 to 10. The address in the message_queue table should now be secondary@...

26. Delete the messages from the message_queue.

delete from message_queue where to_address like 'secondary%';

27. Remove the patron's secondary email address

28. Redo steps 5 to 10. The address in the message_queue table should now be alternate@...

29. Delete the messages from the message_queue.

delete from message_queue where to_address like 'alternate%';

30. Remove the patron's alternate email address

31. Redo steps 5 to 10. The address in the message_queue table should now be empty



To test RECALLS with AutoEmailPrimaryAddress

0. Set up recalls (see bug 19532)

1. Change email addresses of a patron (I used Edna Acosta)
   - In the 'Primary email' field, enter something like primary@...
   - In the 'Secondary email' field, enter something like secondary@...
   - In the 'Email' field of the 'Alternate address' section, enter something like alternate@...

2. Set AutoEmailPrimaryAddress to primary email address (home)

3. Place a recall from the patron's OPAC account

4. Check in the recalled item and confirm recall

5. Check the to_address in the message_queue table for CHECKIN, it should be primary@...

select to_address, letter_code, time_queued from message_queue where date(time_queued) = curdate();

6. Delete the messages from the message_queue.

delete from message_queue where to_address like 'primary%';

7. Change AutoEmailPrimaryAddress to secondary email address (work)

8. From the patron's recalls in the staff interface, click Actions > Revert waiting

9. Redo step 4 and 5. The address in the message_queue table should now be secondary@...

10. Delete the messages from the message_queue.

delete from message_queue where to_address like 'secondary%';

11. Change AutoEmailPrimaryAddress to alternate email address (alternate)

12. Redo step 4 and 5. The address in the message_queue table should now be alternate@...

13. Delete the messages from the message_queue.

delete from message_queue where to_address like 'alternate%';

14. Change AutoEmailPrimaryAddress to cardnumber as

15. Redo step 4 and 5. The address in the message_queue table should now be the patron's cardnumber

16. Delete the messages from the message_queue.

delete from message_queue where to_address = '23529001000463';

17. Change AutoEmailPrimaryAddress to first valid

18. Redo step 4 and 5. The address in the message_queue table should now be primary@...

19. Delete the messages from the message_queue.

delete from message_queue where to_address like 'primary%';

20. Remove the patron's primary email address

21. Redo step 4 and 5. The address in the message_queue table should now be secondary@...

22. Delete the messages from the message_queue.

delete from message_queue where to_address like 'secondary%';

23. Remove the patron's secondary email address

24. Redo steps 4 and 5. The address in the message_queue table should now be alternate@...

25. Delete the messages from the message_queue.

delete from message_queue where to_address like 'alternate%';

26. Remove the patron's alternate email address

27. Redo steps 4 and 5. The address in the message_queue table should now be empty
Comment 7 Caroline Cyr La Rose 2023-03-13 16:36:31 UTC
Created attachment 148130 [details] [review]
Bug 18398: Update C4::Message enqueue to use $patron->notice_email_address

This patch updates the enque method in C4::Message to expect a
Koha::Patron object in the parameters and then uses that patron object
to select the correct email address for notices as defined by
AutoEmailPrimaryAddress.

Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>
Comment 8 Martin Renvoize (ashimema) 2023-03-13 17:08:20 UTC
Wow, nice test plan Caroline.. Thankyou for being so vigorous and thorough :)
Comment 9 Nick Clemens (kidclamp) 2023-03-28 10:07:52 UTC
The POD needs an update for the changed parameter

Could you provide unit tests?
Comment 10 Martin Renvoize (ashimema) 2023-03-28 12:36:42 UTC
Created attachment 148816 [details] [review]
Bug 18398: Update C4::Message enqueue to use $patron->notice_email_address

This patch updates the enque method in C4::Message to expect a
Koha::Patron object in the parameters and then uses that patron object
to select the correct email address for notices as defined by
AutoEmailPrimaryAddress.

Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>
Comment 11 Martin Renvoize (ashimema) 2023-03-28 12:36:54 UTC
Created attachment 148817 [details] [review]
Bug 18398: (follow-up) Update POD & Unit tests

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 12 Martin Renvoize (ashimema) 2023-03-28 12:39:58 UTC
Thanks Nick :).. POD now updated and Unit tests added
Comment 13 Nick Clemens (kidclamp) 2023-03-28 15:02:18 UTC
Created attachment 148838 [details] [review]
Bug 18398: Update C4::Message enqueue to use $patron->notice_email_address

This patch updates the enque method in C4::Message to expect a
Koha::Patron object in the parameters and then uses that patron object
to select the correct email address for notices as defined by
AutoEmailPrimaryAddress.

Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 14 Nick Clemens (kidclamp) 2023-03-28 15:02:21 UTC
Created attachment 148839 [details] [review]
Bug 18398: (follow-up) Update POD & Unit tests

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 15 Tomás Cohen Arazi (tcohen) 2023-03-31 11:06:38 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 16 David Cook 2023-05-05 06:54:39 UTC
Backport to 22.11 would probably be good for this one
Comment 17 Jacob O'Mara 2023-05-09 20:52:26 UTC
Nice work, thanks everyone!

Pushed to 22.11.x for the next release.
Comment 18 Lucas Gass (lukeg) 2023-05-15 14:34:37 UTC
Backported to 22.05.x for upcoming 22.05.13
Comment 19 Arthur Suzuki 2023-05-23 14:23:38 UTC
doesn't apply to 21.11