Bug 31610

Summary: When creating a guarantee, patron messaging preferences should be copied to this account from the category
Product: Koha Reporter: Kelly McElligott <kelly>
Component: PatronsAssignee: Julian Maurice <julian.maurice>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: gmcharlt, jdemuth, julian.maurice, kyle.m.hall, lisettepalouse+koha, mary.woodward, ovezina
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 31610: Set messaging preferences in the new guarantee form
Bug 31610: Set messaging preferences only on "add_form"
Bug 31610: Set messaging preferences in the new guarantee form
Bug 31610: Set messaging preferences only on "add_form"

Description Kelly McElligott 2022-09-22 21:53:20 UTC
When creating a guarantee, patron messaging preferences should be copied to this account from the category.

Steps:
Have a guarantor.
Create a guarantee.
Koha will use the CHILD patron category to assign this guarantee, but will not copy over the message preferences from this CHILD patron category.
Comment 1 Mwoo 2022-09-23 13:57:30 UTC
YES Please!!!!
Comment 2 Julian Maurice 2024-01-29 13:32:59 UTC
Created attachment 161595 [details] [review]
Bug 31610: Set messaging preferences in the new guarantee form

On patron detail page, if the patron is an adult, there is a button "Add
guarantee". It takes you to the patron creation form. In this form one
of the "can be guarantee" category will be automatically selected, but
the messaging preferences will not be automatically set to the default
messaging preferences for this category.
This patch fixes that.

Test plan:
1. Make sure all the "can be guarantee" categories have default
   messaging preferences. The category dropdown list is not sorted so
   it's not always the same category that appear first and is
   automatically selected.
   Also make sure that preference borrowerRelationship is not empty
2. Find a patron whose category's type is Adult and go to its detail
   page
3. Click on "Add guarantee" in the toolbar
4. Verify that the messaging preferences are automatically set and match
   the selected category.
Comment 3 Kelly McElligott 2024-01-30 14:05:23 UTC
I tested this and I am not finding this to work.  I create a patron that has default messaging preferences (Adult), and then I create a guarantee (kid) for this account.  Now in Koha Admin, Patron Categories, the Kid category has specific messaging preferences as does the adult, and these messaging preferences are not the same. 

When I create the guarantee, no messaging preferences copy over.

When I go back and edit the guarantee, after saving it, I do get a popup message asking if I want to copy messaging preferences over, I clicked ok.  Nothing happens. 

Even if I go into an already created Adult patron, I get the same popup to update/copy messaging preferences, nothing updates.
Comment 4 Julian Maurice 2024-01-30 14:33:03 UTC
Did you clean your browser cache before testing ?
As the patch only changes a JS file, it's possible that the browser loaded the old version.
Comment 5 Kelly McElligott 2024-01-30 15:07:03 UTC
I am using the sandbox- refreshed my cache- no luck. I logged out and logged back in, no luck. I also tried another browser, no luck.
Comment 6 Julian Maurice 2024-06-25 07:42:12 UTC
Created attachment 168051 [details] [review]
Bug 31610: Set messaging preferences only on "add_form"
Comment 7 Julian Maurice 2024-06-25 07:50:23 UTC
> Even if I go into an already created Adult patron, I get the same popup to
> update/copy messaging preferences, nothing updates.

The popup should not appear. This is a bug caused by the first patch and fixed by the 2nd patch.

However, the fact that nothing updates when you click 'OK' in the popup probably means that there is something wrong in the AJAX request, but I think it's not caused by patches on this bug.
Can you try on master (without patches of this bug): edit a borrower, change it's category (popup should appear, click OK), and verify if the category preferences were applied ?
Comment 8 Olivier Vezina 2024-09-12 19:49:56 UTC
Created attachment 171427 [details] [review]
Bug 31610: Set messaging preferences in the new guarantee form

On patron detail page, if the patron is an adult, there is a button "Add
guarantee". It takes you to the patron creation form. In this form one
of the "can be guarantee" category will be automatically selected, but
the messaging preferences will not be automatically set to the default
messaging preferences for this category.
This patch fixes that.

Test plan:
1. Make sure all the "can be guarantee" categories have default
   messaging preferences. The category dropdown list is not sorted so
   it's not always the same category that appear first and is
   automatically selected.
   Also make sure that preference borrowerRelationship is not empty
2. Find a patron whose category's type is Adult and go to its detail
   page
3. Click on "Add guarantee" in the toolbar
4. Verify that the messaging preferences are automatically set and match
   the selected category.

Signed-off-by: Olivier V <olivier.vezina@inLibro.com>
Comment 9 Olivier Vezina 2024-09-12 19:49:58 UTC
Created attachment 171428 [details] [review]
Bug 31610: Set messaging preferences only on "add_form"

Signed-off-by: Olivier V <olivier.vezina@inLibro.com>