Bug 30901 - Add template method to be able to look up renewal data in Koha slips and notices
Summary: Add template method to be able to look up renewal data in Koha slips and notices
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Kyle M Hall
QA Contact: Testopia
URL:
Keywords:
: 33301 (view as bug list)
Depends on:
Blocks: 31048
  Show dependency treegraph
 
Reported: 2022-06-03 17:34 UTC by Kyle M Hall
Modified: 2023-11-29 14:25 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission: https://wiki.koha-community.org/wiki/Notices_with_Template_Toolkit#Example:_CirculationRules.Renewals
Text to go in the release notes:
This adds a way to print information about renewals to notices with Template Toolkit. This includes the numbers for used renewals, allowed renewals and remaining renewals and more. Documentation: https://wiki.koha-community.org/wiki/Notices_with_Template_Toolkit#Example:_CirculationRules.Renewals
Version(s) released in:
22.11.00


Attachments
Bug 30901: Add Renewals method to CirculationRules template plugin (1.80 KB, patch)
2022-06-03 17:43 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 30901: Add POD for Koha::Template::Plugin::CirculationRules (2.40 KB, patch)
2022-06-03 17:43 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 30901: Add POD for Koha::Template::Plugin::CirculationRules (2.39 KB, patch)
2022-06-03 17:47 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 30901: Add Renewals method to CirculationRules template plugin (1.79 KB, patch)
2022-06-03 18:10 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 30901: Add POD for Koha::Template::Plugin::CirculationRules (2.39 KB, patch)
2022-06-03 18:11 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 30901: Add Renewals method to CirculationRules template plugin (1.84 KB, patch)
2022-06-03 18:17 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 30901: Add POD for Koha::Template::Plugin::CirculationRules (2.44 KB, patch)
2022-06-03 18:17 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 30901: Add Unit Tests (3.45 KB, patch)
2022-06-29 19:02 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 30901: Add Renewals method to CirculationRules template plugin (1.90 KB, patch)
2022-08-13 06:25 UTC, Fridolin Somers
Details | Diff | Splinter Review
Bug 30901: Add POD for Koha::Template::Plugin::CirculationRules (2.50 KB, patch)
2022-08-13 06:25 UTC, Fridolin Somers
Details | Diff | Splinter Review
Bug 30901: Add Unit Tests (3.51 KB, patch)
2022-08-13 06:25 UTC, Fridolin Somers
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle M Hall 2022-06-03 17:34:26 UTC
It would be useful to be able to report renewals used/remaining in some notices and slips.
Comment 1 Kyle M Hall 2022-06-03 17:43:12 UTC
Created attachment 135687 [details] [review]
Bug 30901: Add Renewals method to CirculationRules template plugin

It would be useful to be able to report renewals used/remaining in some notices and slips.

Test Plan:
1) Apply this patch
2) Add the following to the RENEWAL notices:
--
[% USE CirculationRules %]
[% SET renewals = CirculationRules.Renewals( borrower.id, item.id ) %]
You have used [% renewals.count %] of [% renewals.allowed %], you have [% renewals.remaining %] renewals left.
--
3) Trigger a renewal notice
4) Verify the text is correct!
Comment 2 Kyle M Hall 2022-06-03 17:43:25 UTC
Created attachment 135688 [details] [review]
Bug 30901: Add POD for Koha::Template::Plugin::CirculationRules
Comment 3 Kyle M Hall 2022-06-03 17:47:56 UTC
Created attachment 135689 [details] [review]
Bug 30901: Add POD for Koha::Template::Plugin::CirculationRules
Comment 4 Kyle M Hall 2022-06-03 18:10:54 UTC
Created attachment 135690 [details] [review]
Bug 30901: Add Renewals method to CirculationRules template plugin

It would be useful to be able to report renewals used/remaining in some notices and slips.

Test Plan:
1) Apply this patch
2) Add the following to the RENEWAL notices:
--
[% USE CirculationRules %]
[% SET renewals = CirculationRules.Renewals( borrower.id, item.id ) %]
You have used [% renewals.count %] of [% renewals.allowed %], you have [% renewals.remaining %] renewals left.
--
3) Trigger a renewal notice
4) Verify the text is correct!
Comment 5 Kyle M Hall 2022-06-03 18:11:06 UTC
Created attachment 135691 [details] [review]
Bug 30901: Add POD for Koha::Template::Plugin::CirculationRules
Comment 6 Lucas Gass 2022-06-03 18:17:05 UTC
Created attachment 135692 [details] [review]
Bug 30901: Add Renewals method to CirculationRules template plugin

It would be useful to be able to report renewals used/remaining in some notices and slips.

Test Plan:
1) Apply this patch
2) Add the following to the RENEWAL notices:
--
[% USE CirculationRules %]
[% SET renewals = CirculationRules.Renewals( borrower.id, item.id ) %]
You have used [% renewals.count %] of [% renewals.allowed %], you have [% renewals.remaining %] renewals left.
--
3) Trigger a renewal notice
4) Verify the text is correct!

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 7 Lucas Gass 2022-06-03 18:17:08 UTC
Created attachment 135693 [details] [review]
Bug 30901: Add POD for Koha::Template::Plugin::CirculationRules

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 8 Katrin Fischer 2022-06-06 13:14:50 UTC
Could you please add some documentation for this? 

I think the wiki page would be a good place:
https://wiki.koha-community.org/wiki/Notices_with_Template_Toolkit
Comment 9 Kyle M Hall 2022-06-06 13:40:21 UTC
(In reply to Katrin Fischer from comment #8)
> Could you please add some documentation for this? 
> 
> I think the wiki page would be a good place:
> https://wiki.koha-community.org/wiki/Notices_with_Template_Toolkit

Done! https://wiki.koha-community.org/wiki/Notices_with_Template_Toolkit#Using_filters
Comment 10 Jonathan Druart 2022-06-07 12:00:57 UTC
It's handy but cannot we already provide the same output without this patch?
From the patron object you can get the number of renews, the CirculationRules will give you the values for the renewal rules, and then it's a subtraction.
Comment 11 Katrin Fischer 2022-06-07 16:04:38 UTC
(In reply to Jonathan Druart from comment #10)
> It's handy but cannot we already provide the same output without this patch?
> From the patron object you can get the number of renews, the
> CirculationRules will give you the values for the renewal rules, and then
> it's a subtraction.

I think it sounds more complicated for users, tbh. 

Could you write up a working example to document? I think patron object is not correct or we need another step to the issue and then calculate a lot of things.

At the moment the main issue using TT notices is that you practically need to read and understand the code for anything a little out of the ordinary :(
Comment 12 Sally 2022-06-14 13:49:55 UTC
(In reply to Jonathan Druart from comment #10)
> It's handy but cannot we already provide the same output without this patch?
> From the patron object you can get the number of renews, the
> CirculationRules will give you the values for the renewal rules, and then
> it's a subtraction.

I would love to know how to do this.  Would it be possible to document it?
Comment 13 Katrin Fischer 2022-06-25 13:54:32 UTC
I think we needs ways to make TT in the templates easier to use. This is handy, easy to read and well documented now. 

Only: unit tests please!
Comment 14 Kyle M Hall 2022-06-29 19:02:13 UTC
Created attachment 136748 [details] [review]
Bug 30901: Add Unit Tests
Comment 15 Fridolin Somers 2022-08-13 06:23:35 UTC
Looks great, very useful.
I QA
Comment 16 Fridolin Somers 2022-08-13 06:25:25 UTC
Created attachment 139086 [details] [review]
Bug 30901: Add Renewals method to CirculationRules template plugin

It would be useful to be able to report renewals used/remaining in some notices and slips.

Test Plan:
1) Apply this patch
2) Add the following to the RENEWAL notices:
--
[% USE CirculationRules %]
[% SET renewals = CirculationRules.Renewals( borrower.id, item.id ) %]
You have used [% renewals.count %] of [% renewals.allowed %], you have [% renewals.remaining %] renewals left.
--
3) Trigger a renewal notice
4) Verify the text is correct!

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Comment 17 Fridolin Somers 2022-08-13 06:25:30 UTC
Created attachment 139087 [details] [review]
Bug 30901: Add POD for Koha::Template::Plugin::CirculationRules

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Comment 18 Fridolin Somers 2022-08-13 06:25:34 UTC
Created attachment 139088 [details] [review]
Bug 30901: Add Unit Tests

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Comment 19 Tomás Cohen Arazi 2022-08-16 13:53:44 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 20 Lucas Gass 2022-10-03 22:13:56 UTC
Enhancement will not be backported to 22.05.x series
Comment 21 Andrew Fuerste-Henry 2023-11-29 14:25:58 UTC
*** Bug 33301 has been marked as a duplicate of this bug. ***