Bug 28924 - Allow NoIssuesCharge to be determined by patron category
Summary: Allow NoIssuesCharge to be determined by patron category
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Matt Blenkinsop
QA Contact: Testopia
URL: https://github.com/PTFS-Europe/koha/c...
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-30 21:05 UTC by Donna
Modified: 2024-05-06 06:17 UTC (History)
5 users (show)

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


Attachments
Bug 28924: Add 3 new columns to categories table (3.45 KB, patch)
2024-04-30 12:40 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 28924: Add DBIC file (1.97 KB, patch)
2024-04-30 12:40 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 28924: Add new columns to UI and controller (11.94 KB, patch)
2024-04-30 12:40 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 28924: Add can_borrow and is_patron_inside_charge_limits methods (7.18 KB, patch)
2024-04-30 12:40 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 28924: Update all usages of the current sysprefs (19.98 KB, patch)
2024-04-30 12:40 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 28924: Add a template method and update template usages (3.77 KB, patch)
2024-04-30 12:40 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 28924: Add unit tests for new methods and update existing tests (19.31 KB, patch)
2024-04-30 12:41 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 28924: Add 3 new columns to categories table (3.45 KB, patch)
2024-05-02 09:55 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 28924: Add DBIC file (1.97 KB, patch)
2024-05-02 09:55 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 28924: Add new columns to UI and controller (940.45 KB, patch)
2024-05-02 09:55 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 28924: Add can_borrow and is_patron_inside_charge_limits methods (7.18 KB, patch)
2024-05-02 09:55 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 28924: Update all usages of the current sysprefs (19.98 KB, patch)
2024-05-02 09:55 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 28924: Add a template method and update template usages (3.77 KB, patch)
2024-05-02 09:55 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 28924: Add unit tests for new methods and update existing tests (19.31 KB, patch)
2024-05-02 09:55 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 28924: Add 3 new columns to categories table (3.48 KB, patch)
2024-05-06 00:29 UTC, David Nind
Details | Diff | Splinter Review
Bug 28924: Add DBIC file (2.00 KB, patch)
2024-05-06 00:30 UTC, David Nind
Details | Diff | Splinter Review
Bug 28924: Add new columns to UI and controller (940.48 KB, patch)
2024-05-06 00:30 UTC, David Nind
Details | Diff | Splinter Review
Bug 28924: Add can_borrow and is_patron_inside_charge_limits methods (7.21 KB, patch)
2024-05-06 00:30 UTC, David Nind
Details | Diff | Splinter Review
Bug 28924: Update all usages of the current sysprefs (20.00 KB, patch)
2024-05-06 00:30 UTC, David Nind
Details | Diff | Splinter Review
Bug 28924: Add a template method and update template usages (3.80 KB, patch)
2024-05-06 00:30 UTC, David Nind
Details | Diff | Splinter Review
Bug 28924: Add unit tests for new methods and update existing tests (19.33 KB, patch)
2024-05-06 00:30 UTC, David Nind
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Donna 2021-08-30 21:05:05 UTC
Currently, all patron categories have the NoIssuesCharge system preference amount applied uniformly.  However there are situations where one patron category should have a higher (or lower) threshold, and it would be helpful to set this by patron category.  For instance, for libraries that do ILL, items will frequently be marked as long overdue/lost due to the length of time they are checked out, and ILL account will be blocked from use.  Being able to set specific patron categories to different NoIssuesCharge would resolve this.
Comment 1 Kristi 2023-09-19 13:02:33 UTC
This would be particularly helpful for some of our unique patron categories.
Comment 2 Martin Renvoize 2024-03-27 11:12:27 UTC
Branch available at https://github.com/PTFS-Europe/koha/commits/bug_28924/.
Comment 3 Lucas Gass 2024-04-19 21:01:54 UTC
We were wondering if there is a test plan for this one?
Comment 4 Matt Blenkinsop 2024-04-30 12:39:48 UTC
Test plan added to latest commit on the branch for future reference and also here for testing

Patron category level noissuescharge

Test plan:
1. Choose a patron and note their patron category
2. Create a manual invoice on that patron for 6.00
3. Try to check an item out to the patron and it will show a message saying that checkout is blocked because the fine balance is over the limit.
4. This is because the default global value for the ‘noissuescharge’ is 5.00 and we are now over that limit
5. Navigate to Administration > Patron categories and click to edit the category relevant to your patron
6. At the bottom of the form will be fields called No Issues Charge, No Issues Charge Guarantees and No Issues Charge Guarantors With Guarantees. Set those fields to 7
7. Now try and checkout again - this time you will be allowed to checkout as the category level limit is higher than the fine we set.
8. Choose a different patron (patron 2) with a category that is different to the first patron (patron 1).
9. Repeat steps 2 and 3. This time checkout will be blocked again because the limit for this patron category is still the global value of 5.00
10. Choose a third patron with a category of child or similar (patron 3)
11. Make patron 1 a guarantor for patron 3
12. Edit patron 3’s patron category and set the limit for No Issues Charge, No Issues Charge Guarantees and No Issues Charge Guarantors With Guarantees to 5. 
13. Try to check out to patron 3 and it will be blocked due to the fines on patron 1’s account
14. Try to checkout to patron 1 - it should still be possible
15. Add a fine to patron 3’s account for 2.00
16. Try to check out to patron 1 - the checkout will be blocked due to the total of 8 now owed by the patron and its guarantees

    prove t/db_dependent/SIP/Transaction.t
    prove t/db_dependent/SIP/Patron.t
    prove t/db_dependent/Circulation/NoIssuesChargeGuarantees.t
    prove t/db_dependent/Koha/Patron.t
Comment 5 Matt Blenkinsop 2024-04-30 12:40:46 UTC
Created attachment 165870 [details] [review]
Bug 28924: Add 3 new columns to categories table

This patch adds three new columns to the patron categories table:
noissuescharge
noissueschargegurantees
noissueschargeguarantorswithguarantees

These values will allow charge limits to be set at category level rather than globally for all patrons. If the values are not set at category level then the system will use the global level values
Comment 6 Matt Blenkinsop 2024-04-30 12:40:48 UTC
Created attachment 165871 [details] [review]
Bug 28924: Add DBIC file
Comment 7 Matt Blenkinsop 2024-04-30 12:40:50 UTC
Created attachment 165872 [details] [review]
Bug 28924: Add new columns to UI and controller

This patch adds the columns in the table and also updates the controller to allow these fields to be updated in the database from the UI form
Comment 8 Matt Blenkinsop 2024-04-30 12:40:53 UTC
Created attachment 165873 [details] [review]
Bug 28924: Add can_borrow and is_patron_inside_charge_limits methods

This patch adds two new methods. can_borrow is a top-level method for determining whether a patron is able to borrow. Currently this logic is repeataed in multiple methods and shuld be more DRY. This bug is specific to patron charge limits so that is the focus but the method can be developed in follow-up bugs to cover all areas.
The is_patron_inside_charge_limits method is now to be used where any of the three noissuescharge sysprefs are used. It will look at the patron category based on either a borrowernumber or patron object and return a hash detailing the charges, the charge limit and whether the patron is over the limit

Test plan:
1. Choose a patron and note their patron category
2. Create a manual invoice on that patron for 6.00
3. Try to check an item out to the patron and it will show a message saying that checkout is blocked because the fine balance is over the limit.
4. This is because the default global value for the ‘noissuescharge’ is 5.00 and we are now over that limit
5. Navigate to Administration > Patron categories and click to edit the category relevant to your patron
6. At the bottom of the form will be fields called No Issues Charge, No Issues Charge Guarantees and No Issues Charge Guarantors With Guarantees. Set those fields to 7
7. Now try and checkout again - this time you will be allowed to checkout as the category level limit is higher than the fine we set.
8. Choose a different patron (patron 2) with a category that is different to the first patron (patron 1).
9. Repeat steps 2 and 3. This time checkout will be blocked again because the limit for this patron category is still the global value of 5.00
10. Choose a third patron with a category of child or similar (patron 3)
11. Make patron 1 a guarantor for patron 3
12. Edit patron 3’s patron category and set the limit for No Issues Charge, No Issues Charge Guarantees and No Issues Charge Guarantors With Guarantees to 5.
13. Try to check out to patron 3 and it will be blocked due to the fines on patron 1’s account
14. Try to checkout to patron 1 - it should still be possible
15. Add a fine to patron 3’s account for 2.00
16. Try to check out to patron 1 - the checkout will be blocked due to the total of 8 now owed by the patron and its guarantees
Comment 9 Matt Blenkinsop 2024-04-30 12:40:55 UTC
Created attachment 165874 [details] [review]
Bug 28924: Update all usages of the current sysprefs

This patch updates all instances where the current noissuescharge sysprefs are used. They will now use the is_patron_inside_charge_limits method to handle the patron category level limits
Comment 10 Matt Blenkinsop 2024-04-30 12:40:57 UTC
Created attachment 165875 [details] [review]
Bug 28924: Add a template method and update template usages

This patch adds a method to be used in the template where currently the Koha.Preference('noissuescharge') method is used. This currently does not take into account the new patron category level limits and so needs to be updated to its own method to handle these.
Comment 11 Matt Blenkinsop 2024-04-30 12:41:00 UTC
Created attachment 165876 [details] [review]
Bug 28924: Add unit tests for new methods and update existing tests

This commit adds unit tests for the two new methods introduced and also updates all unit tests that use the noissuecharge sysprefs

Test plan:
1. Choose a patron and note their patron category
2. Create a manual invoice on that patron for 6.00
3. Try to check an item out to the patron and it will show a message saying that checkout is blocked because the fine balance is over the limit.
4. This is because the default global value for the ‘noissuescharge’ is 5.00 and we are now over that limit
5. Navigate to Administration > Patron categories and click to edit the category relevant to your patron
6. At the bottom of the form will be fields called No Issues Charge, No Issues Charge Guarantees and No Issues Charge Guarantors With Guarantees. Set those fields to 7
7. Now try and checkout again - this time you will be allowed to checkout as the category level limit is higher than the fine we set.
8. Choose a different patron (patron 2) with a category that is different to the first patron (patron 1).
9. Repeat steps 2 and 3. This time checkout will be blocked again because the limit for this patron category is still the global value of 5.00
10. Choose a third patron with a category of child or similar (patron 3)
11. Make patron 1 a guarantor for patron 3
12. Edit patron 3’s patron category and set the limit for No Issues Charge, No Issues Charge Guarantees and No Issues Charge Guarantors With Guarantees to 5.
13. Try to check out to patron 3 and it will be blocked due to the fines on patron 1’s account
14. Try to checkout to patron 1 - it should still be possible
15. Add a fine to patron 3’s account for 2.00
16. Try to check out to patron 1 - the checkout will be blocked due to the total of 8 now owed by the patron and its guarantees

Test plan:
prove t/db_dependent/SIP/Transaction.t
prove t/db_dependent/SIP/Patron.t
prove t/db_dependent/Circulation/NoIssuesChargeGuarantees.t
prove t/db_dependent/Koha/Patron.t
Comment 12 Kristi 2024-04-30 18:25:11 UTC
I am using a ByWater sandbox to go through the test plan, and at step 6, the  No Issues Charge, No Issues Charge Guarantees and No Issues Charge Guarantors With Guarantees are not present when I edit a patron type. Would I need to have taken other steps than using one of these test sandboxes?
Comment 13 Katrin Fischer 2024-05-01 10:53:44 UTC
Hi Kristi, from looking at the patches I think they should be there. Maybe the patches didn't apply cleanly. Maybe try again on another sandbox?

@Matt: Please fix capitalization! No Issues Charge Guarantors With Guarantees: etc.
Comment 14 Matt Blenkinsop 2024-05-02 09:55:18 UTC
Created attachment 166042 [details] [review]
Bug 28924: Add 3 new columns to categories table

This patch adds three new columns to the patron categories table:
noissuescharge
noissueschargegurantees
noissueschargeguarantorswithguarantees

These values will allow charge limits to be set at category level rather than globally for all patrons. If the values are not set at category level then the system will use the global level values
Comment 15 Matt Blenkinsop 2024-05-02 09:55:21 UTC
Created attachment 166043 [details] [review]
Bug 28924: Add DBIC file
Comment 16 Matt Blenkinsop 2024-05-02 09:55:25 UTC
Created attachment 166044 [details] [review]
Bug 28924: Add new columns to UI and controller

This patch adds the columns in the table and also updates the controller to allow these fields to be updated in the database from the UI form
Comment 17 Matt Blenkinsop 2024-05-02 09:55:28 UTC
Created attachment 166045 [details] [review]
Bug 28924: Add can_borrow and is_patron_inside_charge_limits methods

This patch adds two new methods. can_borrow is a top-level method for determining whether a patron is able to borrow. Currently this logic is repeataed in multiple methods and shuld be more DRY. This bug is specific to patron charge limits so that is the focus but the method can be developed in follow-up bugs to cover all areas.
The is_patron_inside_charge_limits method is now to be used where any of the three noissuescharge sysprefs are used. It will look at the patron category based on either a borrowernumber or patron object and return a hash detailing the charges, the charge limit and whether the patron is over the limit

Test plan:
1. Choose a patron and note their patron category
2. Create a manual invoice on that patron for 6.00
3. Try to check an item out to the patron and it will show a message saying that checkout is blocked because the fine balance is over the limit.
4. This is because the default global value for the ‘noissuescharge’ is 5.00 and we are now over that limit
5. Navigate to Administration > Patron categories and click to edit the category relevant to your patron
6. At the bottom of the form will be fields called No Issues Charge, No Issues Charge Guarantees and No Issues Charge Guarantors With Guarantees. Set those fields to 7
7. Now try and checkout again - this time you will be allowed to checkout as the category level limit is higher than the fine we set.
8. Choose a different patron (patron 2) with a category that is different to the first patron (patron 1).
9. Repeat steps 2 and 3. This time checkout will be blocked again because the limit for this patron category is still the global value of 5.00
10. Choose a third patron with a category of child or similar (patron 3)
11. Make patron 1 a guarantor for patron 3
12. Edit patron 3’s patron category and set the limit for No Issues Charge, No Issues Charge Guarantees and No Issues Charge Guarantors With Guarantees to 5.
13. Try to check out to patron 3 and it will be blocked due to the fines on patron 1’s account
14. Try to checkout to patron 1 - it should still be possible
15. Add a fine to patron 3’s account for 2.00
16. Try to check out to patron 1 - the checkout will be blocked due to the total of 8 now owed by the patron and its guarantees
Comment 18 Matt Blenkinsop 2024-05-02 09:55:31 UTC
Created attachment 166046 [details] [review]
Bug 28924: Update all usages of the current sysprefs

This patch updates all instances where the current noissuescharge sysprefs are used. They will now use the is_patron_inside_charge_limits method to handle the patron category level limits
Comment 19 Matt Blenkinsop 2024-05-02 09:55:34 UTC
Created attachment 166047 [details] [review]
Bug 28924: Add a template method and update template usages

This patch adds a method to be used in the template where currently the Koha.Preference('noissuescharge') method is used. This currently does not take into account the new patron category level limits and so needs to be updated to its own method to handle these.
Comment 20 Matt Blenkinsop 2024-05-02 09:55:36 UTC
Created attachment 166048 [details] [review]
Bug 28924: Add unit tests for new methods and update existing tests

This commit adds unit tests for the two new methods introduced and also updates all unit tests that use the noissuecharge sysprefs

Test plan:
1. Choose a patron and note their patron category
2. Create a manual invoice on that patron for 6.00
3. Try to check an item out to the patron and it will show a message saying that checkout is blocked because the fine balance is over the limit.
4. This is because the default global value for the ‘noissuescharge’ is 5.00 and we are now over that limit
5. Navigate to Administration > Patron categories and click to edit the category relevant to your patron
6. At the bottom of the form will be fields called No Issues Charge, No Issues Charge Guarantees and No Issues Charge Guarantors With Guarantees. Set those fields to 7
7. Now try and checkout again - this time you will be allowed to checkout as the category level limit is higher than the fine we set.
8. Choose a different patron (patron 2) with a category that is different to the first patron (patron 1).
9. Repeat steps 2 and 3. This time checkout will be blocked again because the limit for this patron category is still the global value of 5.00
10. Choose a third patron with a category of child or similar (patron 3)
11. Make patron 1 a guarantor for patron 3
12. Edit patron 3’s patron category and set the limit for No Issues Charge, No Issues Charge Guarantees and No Issues Charge Guarantors With Guarantees to 5.
13. Try to check out to patron 3 and it will be blocked due to the fines on patron 1’s account
14. Try to checkout to patron 1 - it should still be possible
15. Add a fine to patron 3’s account for 2.00
16. Try to check out to patron 1 - the checkout will be blocked due to the total of 8 now owed by the patron and its guarantees

Test plan:
prove t/db_dependent/SIP/Transaction.t
prove t/db_dependent/SIP/Patron.t
prove t/db_dependent/Circulation/NoIssuesChargeGuarantees.t
prove t/db_dependent/Koha/Patron.t
Comment 21 David Nind 2024-05-06 00:29:58 UTC
Created attachment 166171 [details] [review]
Bug 28924: Add 3 new columns to categories table

This patch adds three new columns to the patron categories table:
noissuescharge
noissueschargegurantees
noissueschargeguarantorswithguarantees

These values will allow charge limits to be set at category level rather than globally for all patrons. If the values are not set at category level then the system will use the global level values

Signed-off-by: David Nind <david@davidnind.com>
Comment 22 David Nind 2024-05-06 00:30:01 UTC
Created attachment 166172 [details] [review]
Bug 28924: Add DBIC file

Signed-off-by: David Nind <david@davidnind.com>
Comment 23 David Nind 2024-05-06 00:30:05 UTC
Created attachment 166173 [details] [review]
Bug 28924: Add new columns to UI and controller

This patch adds the columns in the table and also updates the controller to allow these fields to be updated in the database from the UI form

Signed-off-by: David Nind <david@davidnind.com>
Comment 24 David Nind 2024-05-06 00:30:08 UTC
Created attachment 166174 [details] [review]
Bug 28924: Add can_borrow and is_patron_inside_charge_limits methods

This patch adds two new methods. can_borrow is a top-level method for determining whether a patron is able to borrow. Currently this logic is repeataed in multiple methods and shuld be more DRY. This bug is specific to patron charge limits so that is the focus but the method can be developed in follow-up bugs to cover all areas.
The is_patron_inside_charge_limits method is now to be used where any of the three noissuescharge sysprefs are used. It will look at the patron category based on either a borrowernumber or patron object and return a hash detailing the charges, the charge limit and whether the patron is over the limit

Test plan:
1. Choose a patron and note their patron category
2. Create a manual invoice on that patron for 6.00
3. Try to check an item out to the patron and it will show a message saying that checkout is blocked because the fine balance is over the limit.
4. This is because the default global value for the ‘noissuescharge’ is 5.00 and we are now over that limit
5. Navigate to Administration > Patron categories and click to edit the category relevant to your patron
6. At the bottom of the form will be fields called No Issues Charge, No Issues Charge Guarantees and No Issues Charge Guarantors With Guarantees. Set those fields to 7
7. Now try and checkout again - this time you will be allowed to checkout as the category level limit is higher than the fine we set.
8. Choose a different patron (patron 2) with a category that is different to the first patron (patron 1).
9. Repeat steps 2 and 3. This time checkout will be blocked again because the limit for this patron category is still the global value of 5.00
10. Choose a third patron with a category of child or similar (patron 3)
11. Make patron 1 a guarantor for patron 3
12. Edit patron 3’s patron category and set the limit for No Issues Charge, No Issues Charge Guarantees and No Issues Charge Guarantors With Guarantees to 5.
13. Try to check out to patron 3 and it will be blocked due to the fines on patron 1’s account
14. Try to checkout to patron 1 - it should still be possible
15. Add a fine to patron 3’s account for 2.00
16. Try to check out to patron 1 - the checkout will be blocked due to the total of 8 now owed by the patron and its guarantees

Signed-off-by: David Nind <david@davidnind.com>
Comment 25 David Nind 2024-05-06 00:30:12 UTC
Created attachment 166175 [details] [review]
Bug 28924: Update all usages of the current sysprefs

This patch updates all instances where the current noissuescharge sysprefs are used. They will now use the is_patron_inside_charge_limits method to handle the patron category level limits

Signed-off-by: David Nind <david@davidnind.com>
Comment 26 David Nind 2024-05-06 00:30:14 UTC
Created attachment 166176 [details] [review]
Bug 28924: Add a template method and update template usages

This patch adds a method to be used in the template where currently the Koha.Preference('noissuescharge') method is used. This currently does not take into account the new patron category level limits and so needs to be updated to its own method to handle these.

Signed-off-by: David Nind <david@davidnind.com>
Comment 27 David Nind 2024-05-06 00:30:17 UTC
Created attachment 166177 [details] [review]
Bug 28924: Add unit tests for new methods and update existing tests

This commit adds unit tests for the two new methods introduced and also updates all unit tests that use the noissuecharge sysprefs

Test plan:
1. Choose a patron and note their patron category
2. Create a manual invoice on that patron for 6.00
3. Try to check an item out to the patron and it will show a message saying that checkout is blocked because the fine balance is over the limit.
4. This is because the default global value for the ‘noissuescharge’ is 5.00 and we are now over that limit
5. Navigate to Administration > Patron categories and click to edit the category relevant to your patron
6. At the bottom of the form will be fields called No Issues Charge, No Issues Charge Guarantees and No Issues Charge Guarantors With Guarantees. Set those fields to 7
7. Now try and checkout again - this time you will be allowed to checkout as the category level limit is higher than the fine we set.
8. Choose a different patron (patron 2) with a category that is different to the first patron (patron 1).
9. Repeat steps 2 and 3. This time checkout will be blocked again because the limit for this patron category is still the global value of 5.00
10. Choose a third patron with a category of child or similar (patron 3)
11. Make patron 1 a guarantor for patron 3
12. Edit patron 3’s patron category and set the limit for No Issues Charge, No Issues Charge Guarantees and No Issues Charge Guarantors With Guarantees to 5.
13. Try to check out to patron 3 and it will be blocked due to the fines on patron 1’s account
14. Try to checkout to patron 1 - it should still be possible
15. Add a fine to patron 3’s account for 2.00
16. Try to check out to patron 1 - the checkout will be blocked due to the total of 8 now owed by the patron and its guarantees

Test plan:
prove t/db_dependent/SIP/Transaction.t
prove t/db_dependent/SIP/Patron.t
prove t/db_dependent/Circulation/NoIssuesChargeGuarantees.t
prove t/db_dependent/Koha/Patron.t

Signed-off-by: David Nind <david@davidnind.com>
Comment 28 Katrin Fischer 2024-05-06 06:17:52 UTC
I know I am late to this... but I've been thinking how "noissue" has never been a terribly good name. Wouldn't this be a chance to improve on it? Especially since "issue" is on the terminology list as no-use. But I see a point in consistency as the old prefs remain. (I hope I will survive this comment)