Bug 28556 - Make guarantor information available in notices
Summary: Make guarantor information available in notices
Status: RESOLVED WORKSFORME
Alias: None
Product: Koha
Classification: Unclassified
Component: Notices (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: The Minh Luong
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-11 21:45 UTC by Caroline Cyr La Rose
Modified: 2023-12-18 22:47 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 28556: Guarantor's information is available in notice (2.95 KB, patch)
2022-02-08 22:23 UTC, The Minh Luong
Details | Diff | Splinter Review
Bug 28556: Guarantor's information is available in notice (2.97 KB, patch)
2022-02-08 22:26 UTC, The Minh Luong
Details | Diff | Splinter Review
Bug 28556: Guarantor's information is available in notice (4.09 KB, patch)
2022-05-19 19:07 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 28556: Guarantor's information is available in notice (4.22 KB, patch)
2023-02-08 16:14 UTC, Marius
Details | Diff | Splinter Review
Bug 28556: Guarantor's information is available in notice (6.57 KB, patch)
2023-02-08 16:20 UTC, Marius
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Caroline Cyr La Rose 2021-06-11 21:45:23 UTC
Since the change to accommodate multiple guarantees per borrower, it is impossible to get the garantor's information in notices.

It is customary here to send things to the parent as C/O (care of), especially if it's by the mail. 

I was wondering if it was possible to make the guarantor information available in notices. 

Thanks!
Comment 1 The Minh Luong 2022-02-08 22:23:31 UTC
Created attachment 130339 [details] [review]
Bug 28556: Guarantor's information is available in notice

This patch adds the guarantor's information when sending sending overdue
notice.

To test:
1. Make sure that there is an overdue letter.
 a) Go in Tools/Notices & Slips.
 b) Search for the code "ODUE" and note the "Name" of the letter.
 c) Click on "Edit".
 d) Click on "Email" and make sure that there is text inside the box.
 e) Add the following code in the textbox:
    C/O <<guarantor.firstname>> <<guarantor.surname>> <br/>
 f) Click on "Save".

2. Set up the status trigger.
 a) Go in Tools/Overdue notice/status triggers.
 b) In "First" tab, put a number of days in the "Delay" column (ex: 1).
 c) In the column "Letter", put the "Name" of the letter of step 1a) .
 d) Check "Email".
 e) Click "Save".

3. Create a patron with a guarantor.
 a) Go in Administration/Patron categories.
 b) Create a child category AND a adult category.
 c) Create an adult patron.
 d) Create a child patron.
 e) Go in the child patron's page and click "Edit".
 f) In the "Patron guarantor" section, click add guarantor.
 g) Search for your adult patron and click "Select".
 h) Select a relationship for the guarantor (ex: Mother).
 i) Click on "Save".

4. Borrow an overdue item.
 a) Click on the arrow next to "Search button" (Top of the screen).
 b) Click on "Items search".
 c) Click on search.
 d) Copy a barcode in the list.
 e) Search for your child patron.
 f) Go in his page and click on "Checkout".
 g) Paste the barcode copied at step 4d) .
 h) Click on "Checkout settings".
 i) Put a date in the past greater than the number of days that you put
    on step 2b).
 j) Click on "Check out".
 k) Click on "Yes" Notice tht there is a message saying that Patron has
    ITEMS OVERDUE.

5. Test the patch.
 a) In the terminal, run ./misc/cronjobs/overdue_notices.pl
 b) Return in your child patron's page.
 c) Click on "Notice" and you should see a letter.
 d) Click on the letter to see the content.
 c) Notice that you can't see the guarantor's informations (Adult patron).
 d) Apply the patch.
 e) Notice that you can see the guarantor's informations.

NOTE: If you want to delete the letters, do in your terminal:
- my
- delete from message_queue;
Comment 2 The Minh Luong 2022-02-08 22:26:44 UTC
Created attachment 130340 [details] [review]
Bug 28556: Guarantor's information is available in notice

This patch adds the guarantor's information when sending sending overdue
notice.

To test:
1. Make sure that there is an overdue letter.
 a) Go in Tools/Notices & Slips.
 b) Search for the code "ODUE" and note the "Name" of the letter.
 c) Click on "Edit".
 d) Click on "Email" and make sure that there is text inside the box.
 e) Add the following code in the textbox:
    C/O <<guarantor.firstname>> <<guarantor.surname>> <br/>
 f) Click on "Save".

2. Set up the status trigger.
 a) Go in Tools/Overdue notice/status triggers.
 b) In "First" tab, put a number of days in the "Delay" column (ex: 1).
 c) In the column "Letter", put the "Name" of the letter of step 1a) .
 d) Check "Email".
 e) Click "Save".

3. Create a patron with a guarantor.
 a) Go in Administration/Patron categories.
 b) Create a child category AND a adult category.
 c) Create an adult patron.
 d) Create a child patron.
 e) Go in the child patron's page and click "Edit".
 f) In the "Patron guarantor" section, click add guarantor.
 g) Search for your adult patron and click "Select".
 h) Select a relationship for the guarantor (ex: Mother).
 i) Click on "Save".

4. Borrow an overdue item.
 a) Click on the arrow next to "Search button" (Top of the screen).
 b) Click on "Items search".
 c) Click on search.
 d) Copy a barcode in the list.
 e) Search for your child patron.
 f) Go in his page and click on "Checkout".
 g) Paste the barcode copied at step 4d) .
 h) Click on "Checkout settings".
 i) Put a date in the past greater than the number of days that you put
    on step 2b).
 j) Click on "Check out".
 k) Click on "Yes" Notice tht there is a message saying that Patron has
    ITEMS OVERDUE.

5. Test the patch.
 a) In the terminal, run ./misc/cronjobs/overdue_notices.pl
 b) Return in your child patron's page.
 c) Click on "Notice" and you should see a letter.
 d) Click on the letter to see the content.
 c) Notice that you can't see the guarantor's informations (Adult patron).
 d) Apply the patch.
 e) Reapeat steps a) to d)
 f) Notice that you can see the guarantor's informations.

NOTE: If you want to delete the letters, do in your terminal:
- my
- delete from message_queue;
Comment 3 Lucas Gass 2022-05-18 22:26:25 UTC
When I set my guarantor as a Non-patron guarantor and run the overdue_notices cron the job fails and I get this error:

Can't call method "unblessed" on an undefined value at /kohadevbox/koha/C4/Letters.pm line 652
Comment 4 Shi Yao Wang 2022-05-19 19:07:47 UTC
Created attachment 135214 [details] [review]
Bug 28556: Guarantor's information is available in notice

This patch adds the guarantor's information when sending overdue
notice.

To test:
1. Make sure that there is an overdue letter.
 a) Go in Tools/Notices & Slips.
 b) Search for the code "ODUE" and note the "Name" of the letter.
 c) Click on "Edit".
 d) Click on "Email" and make sure that there is text inside the box.
 e) Add the following code in the textbox:
    C/O <<guarantor.firstname>> <<guarantor.surname>> <br/>
 f) Click on "Save".

2. Set up the status trigger.
 a) Go in Tools/Overdue notice/status triggers.
 b) In "First" tab, put a number of days in the "Delay" column (ex: 1).
 c) In the column "Letter", put the "Name" of the letter of step 1a) .
 d) Check "Email".
 e) Click "Save".

3. Create a patron with a guarantor.
 a) Go in Administration/Patron categories.
 b) Create a child category AND a adult category.
 c) Create an adult patron.
 d) Create a child patron.
 e) Go in the child patron's page and click "Edit".
 f) In the "Patron guarantor" section, click add guarantor.
 g) Search for your adult patron and click "Select".
 h) Select a relationship for the guarantor (ex: Mother).
 i) Click on "Save".

4. Borrow an overdue item.
 a) Click on the arrow next to "Search button" (Top of the screen).
 b) Click on "Items search".
 c) Click on search.
 d) Copy a barcode in the list.
 e) Search for your child patron.
 f) Go in his page and click on "Checkout".
 g) Paste the barcode copied at step 4d) .
 h) Click on "Checkout settings".
 i) Put a date in the past greater than the number of days that you put
    on step 2b).
 j) Click on "Check out".
 k) Click on "Yes" Notice tht there is a message saying that Patron has
    ITEMS OVERDUE.

5. Test the patch.
 a) In the terminal, run ./misc/cronjobs/overdue_notices.pl
 b) Return in your child patron's page.
 c) Click on "Notice" and you should see a letter.
 d) Click on the letter to see the content.
 c) Notice that you can't see the guarantor's informations (Adult patron).
 d) Apply the patch.
 e) Repeat steps a) to d)
 f) Notice that you can see the guarantor's informations.

This also works if you decide to add a non-patron guarantor instead of a
patron guarantor at step 3.

NOTE: If you want to delete the letters, go in your database and run:
- delete from message_queue;
Comment 5 Lucas Gass 2023-01-31 15:37:59 UTC
I think there will need to be updated unit tests here. If I apply the patch and run 'prove -v t/db_dependent/Letters.t' the tests fail:

Can't call method "guarantor_relationships" on an undefined value at /kohadevbox/koha/C4/Letters.pm line 651.
Comment 6 Marius 2023-02-08 16:14:13 UTC
Created attachment 146397 [details] [review]
Bug 28556: Guarantor's information is available in notice

This patch adds the guarantor's information when sending overdue
notice.

To test:
1. Make sure that there is an overdue letter.
 a) Go in Tools/Notices & Slips.
 b) Search for the code "ODUE" and note the "Name" of the letter.
 c) Click on "Edit".
 d) Click on "Email" and make sure that there is text inside the box.
 e) Add the following code in the textbox:
    C/O <<guarantor.firstname>> <<guarantor.surname>> <br/>
    Or add another guarantor. in the textbox from the select list.
 f) Click on "Save".

2. Set up the status trigger.
 a) Go in Tools/Overdue notice/status triggers.
 b) In "First" tab, put a number of days in the "Delay" column (ex: 1).
 c) In the column "Letter", put the "Name" of the letter of step 1a) .
 d) Check "Email".
 e) Click "Save".

3. Create a patron with a guarantor.
 a) Go in Administration/Patron categories.
 b) Create a child category AND a adult category.
 c) Create an adult patron.
 d) Create a child patron.
 e) Go in the child patron's page and click "Edit".
 f) In the "Patron guarantor" section, click add guarantor.
 g) Search for your adult patron and click "Select".
 h) Select a relationship for the guarantor (ex: Mother).
 i) Click on "Save".

4. Borrow an overdue item.
 a) Click on the arrow next to "Search button" (Top of the screen).
 b) Click on "Items search".
 c) Click on search.
 d) Copy a barcode in the list.
 e) Search for your child patron.
 f) Go in his page and click on "Checkout".
 g) Paste the barcode copied at step 4d) .
 h) Click on "Checkout settings".
 i) Put a date in the past greater than the number of days that you put
    on step 2b).
 j) Click on "Check out".
 k) Click on "Yes" Notice tht there is a message saying that Patron has
    ITEMS OVERDUE.

5. Test the patch.
 a) In the terminal, run ./misc/cronjobs/overdue_notices.pl
 b) Return in your child patron's page.
 c) Click on "Notice" and you should see a letter.
 d) Click on the letter to see the content.
 c) Notice that you can't see the guarantor's informations (Adult patron).
 d) Apply the patch.
 e) Repeat steps a) to d)
 f) Notice that you can see the guarantor's informations.

This also works if you decide to add a non-patron guarantor instead of a
patron guarantor at step 3.

NOTE: If you want to delete the letters, go in your database and run:
- delete from message_queue;

Signed-off-by: Marius Mandrescu <marius.mandrescu@inLibro.com>



 Current patch-complexity: Small patch
Comment 7 Marius 2023-02-08 16:20:10 UTC
Created attachment 146398 [details] [review]
Bug 28556: Guarantor's information is available in notice

This patch adds the guarantor's information when sending overdue
notice.

To test:
1. Make sure that there is an overdue letter.
 a) Go in Tools/Notices & Slips.
 b) Search for the code "ODUE" and note the "Name" of the letter.
 c) Click on "Edit".
 d) Click on "Email" and make sure that there is text inside the box.
 e) Add the following code in the textbox:
    C/O <<guarantor.firstname>> <<guarantor.surname>> <br/>
    Or add another guarantor. in the textbox from the select list.
 f) Click on "Save".

2. Set up the status trigger.
 a) Go in Tools/Overdue notice/status triggers.
 b) In "First" tab, put a number of days in the "Delay" column (ex: 1).
 c) In the column "Letter", put the "Name" of the letter of step 1a) .
 d) Check "Email".
 e) Click "Save".

3. Create a patron with a guarantor.
 a) Go in Administration/Patron categories.
 b) Create a child category AND a adult category.
 c) Create an adult patron.
 d) Create a child patron.
 e) Go in the child patron's page and click "Edit".
 f) In the "Patron guarantor" section, click add guarantor.
 g) Search for your adult patron and click "Select".
 h) Select a relationship for the guarantor (ex: Mother).
 i) Click on "Save".

4. Borrow an overdue item.
 a) Click on the arrow next to "Search button" (Top of the screen).
 b) Click on "Items search".
 c) Click on search.
 d) Copy a barcode in the list.
 e) Search for your child patron.
 f) Go in his page and click on "Checkout".
 g) Paste the barcode copied at step 4d) .
 h) Click on "Checkout settings".
 i) Put a date in the past greater than the number of days that you put
    on step 2b).
 j) Click on "Check out".
 k) Click on "Yes" Notice tht there is a message saying that Patron has
    ITEMS OVERDUE.

5. Test the patch.
 a) In the terminal, run ./misc/cronjobs/overdue_notices.pl
 b) Return in your child patron's page.
 c) Click on "Notice" and you should see a letter.
 d) Click on the letter to see the content.
 c) Notice that you can't see the guarantor's informations (Adult patron).
 d) Apply the patch.
 e) Repeat steps a) to d)
 f) Notice that you can see the guarantor's informations.

This also works if you decide to add a non-patron guarantor instead of a
patron guarantor at step 3.

NOTE: If you want to delete the letters, go in your database and run:
- delete from message_queue;

Signed-off-by: Marius Mandrescu <marius.mandrescu@inLibro.com>



 Current patch-complexity: Small patch
Comment 8 Martin Renvoize 2023-05-10 18:43:25 UTC
You realise you can already use ALL object methods in TT based notices right?  So anywhere you have a patron in a notice you can use the relations to get at the guarantors.

I'm not sure we need to add the boiler code here to support this.. we're trying to clean up these scripts and then simplify/clarify the pickers in the medium to long term.
Comment 9 Martin Renvoize 2023-05-10 18:54:51 UTC
[% FOREACH guarantor_relation IN patron.guarantor_relatuonships %]
    [% SET guarantor = guarantor_relation.guarantor %]
    [% guarantor.firstname | html %]
[% END %]
Comment 10 Martin Renvoize 2023-05-11 07:28:58 UTC
Improving the notice creation tools and migrating all notices to TT so we can deprecate the older custom syntaxes was on the roadmaps for at least three cycles, but it's not a one person job and didn't get the uptake from people... I'd rather see effort shared and pushed in that direction that adding more old style code and hacks on top like this I'm afraid.

This gets a downvote from me.
Comment 11 Lucas Gass 2023-12-18 22:47:12 UTC
After testing I can confirm that Martin is correct, this is alreay doable. Have a look these 2 subroutines in Patron.pm to see how:

sub guarantor_relationships
sub guarantee_relationships


and if you want to get fines for guarantors or guarantees see:


sub relationships_debt


I am marking this one as RESOLVED = WORKSFORME