Bug 22774

Summary: Limit purchase suggestion in a specified time period
Product: Koha Reporter: Joy Nelson <joy>
Component: AcquisitionsAssignee: Devinim <kohadevinim>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: andrew, jonathan.druart, katrin.fischer, kelly, lisetteslatah, rkuiper, tomascohen
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Who signed the patch off: Text to go in the release notes:
Version(s) released in:
Attachments: Bug 22774: New systempreferences for suggestions
Bug 22774: Limit Purchase Suggestion in a specified Time period
Bug 22774: (follow-up) Limit Purchase Suggestion in a specified Time period
Bug 22774: New systempreferences for suggestions
Bug 22774: (follow-up) Limit Purchase Suggestion in a specified Time period
Bug 22774: New systempreferences for suggestions
Bug 22774: (follow-up) Limit Purchase Suggestion in a specified Time period
New systempreferences for suggestions added to sysprefs.sql
Bug 22774: New systempreferences for suggestions added to sysprefs.sql
Bug 22774: (follow-up) New systempreferences for suggestions

Description Joy Nelson 2019-04-25 15:36:07 UTC
Many libraries would like the ability to limit purchase suggestions made by a patron to a certain number over a specified period.  i.e. 3 suggestions every 30 days.  The MaxOpenSuggestions works to limit 'open' suggestions, but does not take into account the total suggestions made by patrons. We need the ability to limit the number of suggestions a patron can make in a "rolling number of weeks" (over last X weeks). 

The variables for this would be the number of suggestions and the number of rolling weeks.

Suggested system preference "MaxTotalSuggestions" with two variables.  First is the number of total suggestions and the second is the number of days.

e.g. MaxTotalSuggestion Allow 3 total suggestions over 30 days.  (user configures the numbers to suit their policy)

Result: Users are prevented from making any suggestions if the total suggestions (pending/checked/accepted/rejected) they've made over the last X days is equal to the max specified.
Comment 1 Lisette Scheer 2019-04-26 15:22:35 UTC
This would be very helpful for a number of libraries I've talked with about purchase suggestions. 
Lisette
Comment 2 Devinim 2019-12-03 10:52:53 UTC
Created attachment 95940 [details] [review]
Bug 22774: New systempreferences for suggestions
Comment 3 Devinim 2019-12-03 10:54:05 UTC
Created attachment 95941 [details] [review]
Bug 22774: Limit Purchase Suggestion in a specified Time period

Test plan:
1- Apply this patch
2- Run updatedatabase.pl
3- By default you may have max. 3 suggestions in last 30 days.
4- Go to purchase suggestion page from OPAC
5- If you exceed limits of suggestions in step 3 you will not able to add new suggestions.
6- If you want to change the limits go to systempreferences and change  MaxTotalSuggestions and NumberOfSuggestionDays parameters.
7- Test again from step 4.
Comment 4 Kelly McElligott 2020-01-07 13:49:53 UTC
Hi,
Upon testing this, I received this error when trying to place a hold on the OPAC side.

Could not compile /kohadevbox/koha/opac/opac-suggestions.pl: Global symbol "$suggestions_loop" requires explicit package name (did you forget to declare "my $suggestions_loop"?) at /kohadevbox/koha/opac/opac-suggestions.pl line 144
Comment 5 Devinim 2020-01-09 10:50:59 UTC
Created attachment 97061 [details] [review]
Bug 22774: (follow-up) Limit Purchase Suggestion in a specified Time period

This was resolved. Fail occured because of some changes after we commit the patch
Comment 6 ByWater Sandboxes 2020-01-09 12:33:33 UTC
Created attachment 97070 [details] [review]
Bug 22774: New systempreferences for suggestions

Signed-off-by: Kelly McElligott <kelly@bywatersolutions.com>
Comment 7 ByWater Sandboxes 2020-01-09 12:33:35 UTC
Created attachment 97071 [details] [review]
Bug 22774: (follow-up) Limit Purchase Suggestion in a specified Time period

Signed-off-by: Kelly McElligott <kelly@bywatersolutions.com>
Comment 8 Jonathan Druart 2020-02-05 10:45:30 UTC
I do not think it is correct to have the condition check in the controller. I am pretty sure Tomas will disagree with that as we will want the API taking into account those new sysprefs.

CCing Tomas to get his opinion on this.
Comment 9 ByWater Sandboxes 2020-02-14 21:13:50 UTC
Created attachment 99045 [details] [review]
Bug 22774: New systempreferences for suggestions

Signed-off-by: Kelly McElligott <kelly@bywatersolutions.com>

Signed-off-by: Rhonda Kuiper <rkuiper@roundrocktexas.gov>
Comment 10 ByWater Sandboxes 2020-02-14 21:13:53 UTC
Created attachment 99046 [details] [review]
Bug 22774: (follow-up) Limit Purchase Suggestion in a specified Time period

Signed-off-by: Kelly McElligott <kelly@bywatersolutions.com>

Signed-off-by: Rhonda Kuiper <rkuiper@roundrocktexas.gov>
Comment 11 Katrin Fischer 2020-02-15 08:48:34 UTC
1) The database update will limit the number of suggestions for existing installations:

+    $dbh->do( q{
+            INSERT IGNORE INTO systempreferences (variable,value,explanation,type) VALUES
+                ('MaxTotalSuggestions','3','Number of total suggestions','free'),
+                ('NumberOfSuggestionDays','30','days','free')
+            });

This is against the "rules" as we always aim for having no change of behaviour on update. We should set them to empty (unlimited)

2) For the same reason I am wondering about the default settings in the YAML file, I don't think they are needed.

3) This patch set misses the change to sysprefs.sql for setting up new installations. While we could do the 3 and 30 there, I wonder if we should be a little less restrictive there as well?

4) Please (re)add descriptions of the changes and test plans to the commit messages. I've seen quite a lot of them showing here but not being part of the attached files. Make sure you write them up in your git commit step, not when using git bz attach, as the latter won't change the files.
Comment 12 Devinim 2020-02-21 13:56:07 UTC
Created attachment 99380 [details] [review]
New systempreferences for suggestions added to sysprefs.sql

New patch added for new installations
Comment 13 Devinim 2020-02-21 14:09:16 UTC
Created attachment 99381 [details] [review]
Bug 22774: New systempreferences for suggestions added to sysprefs.sql

New patch added for new installations
Comment 14 Devinim 2020-02-21 14:14:42 UTC
Created attachment 99382 [details] [review]
Bug 22774: (follow-up) New systempreferences for suggestions