[Bug 26307] New: misc/cronjobs/update_patrons_category.pl --too_old acts a year too early
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 Bug ID: 26307 Summary: misc/cronjobs/update_patrons_category.pl --too_old acts a year too early Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: critical Priority: P5 - low Component: Command-line Utilities Assignee: koha-bugs@lists.koha-community.org Reporter: fridolin.somers@biblibre.com QA Contact: testopia@bugs.koha-community.org CC: robin@catalyst.net.nz misc/cronjobs/update_patrons_category.pl --too_old must change category when the age of the patron is greater than (exclusive) limit age of the category. Actually it changes a year too early : he goes to a min 18 years category having reached 17 years. Looks like the test suite is wrong not strong enought on Koha::Patrons->search_patrons_to_update_category(). -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 Fridolin SOMERS <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |fridolin.somers@biblibre.co |ity.org |m -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 Fridolin SOMERS <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED --- Comment #1 from Fridolin SOMERS <fridolin.somers@biblibre.com> --- We tested old script j2a.pl and seems this problem already existed. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 Fridolin SOMERS <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff Patch complexity|--- |Small patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 --- Comment #2 from Fridolin SOMERS <fridolin.somers@biblibre.com> --- Created attachment 109229 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=109229&action=edit Bug 26307: Reveal problem in unit test for too_old Logic : ======= Looking at Koha::Patron->get_age : At birthday aniversary, patron has aged 1 year more. For example : - today is 2020-08-27 - patron with date of birth 2000-08-28 is 19 year old - patron with date of birth 2000-08-27 is 20 year old Looking at Koha::Patron->is_valid_age : Category min and max limits are inclusive. For example max=17 means : - patron having 17 years old is valid - patron having 18 years old is not valid Test suite : =========== Changes child3 to have 18 years tomorrow. Adds a child4 with 18 years today. Test plan : Run prove t/db_dependent/Patrons.t See it fails on 'One under age patron in child category' -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 Fridolin SOMERS <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |17168 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17168 [Bug 17168] Add a command line script for updating patron category based on status -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 --- Comment #3 from Fridolin SOMERS <fridolin.somers@biblibre.com> --- Created attachment 109230 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=109230&action=edit Bug 26307: Fix misc/cronjobs/update_patrons_category.pl --too_old acts a year too early misc/cronjobs/update_patrons_category.pl --too_old must change category when the age of the patron is greater than (exclusive) limit age of the category. Actually it changes a year too early : he goes to a min 18 years category having reached 17 years. Patch also changes the compare to 'lower and equal' and uses date without time => so that update occures at birthday aniversary day See logic in previous patch. And code in Koha::Patron : get_age() and is_valid_age. Test plan : 1) Create a child patron category 'C' with upper limit 17 years 2) Create an adult patron category 'A' 3) Create a patron in child category with date of birth = today - 18 years + 1 day 4) Check patron as age : 17 years 11 months 5) Without patch run : misc/cronjobs/update_patrons_category.pl -f=ENF -t=ADULT --too_old -v => You see the patron 6) apply patch 7) Re-run 5) => You dont see the patron 8) Update database to change patron date of birth = today - 18 years mysql > update borrowers set dateofbirth='YYYY-MM-DD' where borrowernumber=XXX; 9) Run : misc/cronjobs/update_patrons_category.pl -f=ENF -t=ADULT --too_old -v --confirm 10) Check patron category is now 'A' 11) Check you dont see message "Patron's age is incorrect for their category" -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 --- Comment #4 from Fridolin SOMERS <fridolin.somers@biblibre.com> --- Created attachment 109231 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=109231&action=edit Bug 26307: Add a unit test for too_young In unit test for update patron categories : Changes $child1 to bee 4 years 11 month old => is under age Add $child1bis having exactly the lower age limit of 5 years => is not under age Run t/db_dependent/Patrons.t Test is to renforce the test suite, it is OK event without next patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 --- Comment #5 from Fridolin SOMERS <fridolin.somers@biblibre.com> --- Created attachment 109232 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=109232&action=edit Bug 26307: Use same syntax in --too_young In too_young use dt->strftime("%Y-%m-%d") like in too_old. This does not change the behavior. Test plan : Run prove t/db_dependent/Patrons.t -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 Fridolin SOMERS <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=26311 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |In Discussion CC| |nick@bywatersolutions.com --- Comment #6 from Nick Clemens <nick@bywatersolutions.com> --- I don't think this is a bug, or rather, I don't know I see your point, if you have categories: Child Upper Age Limit 17 Adult Minimum Age 18 You don't cross until you are 18, however, you can also read that there is a gap between 17 and 18 The way Koha has always worked you have: Child Upper Age Limit 18 Adult Minimum Age 18 Now there is no gap and you switch at 18 I think changing a long standing behaviour will affect many people, and that makes me nervous. I know that I have helped libraries set this up in the way that works. I think instead we need to clarify the explanation of the 'Limit' -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 --- Comment #7 from Fridolin SOMERS <fridolin.somers@biblibre.com> --- (In reply to Nick Clemens from comment #6)
I don't think this is a bug, or rather, I don't know
I see your point, if you have categories: Child Upper Age Limit 17 Adult Minimum Age 18
You don't cross until you are 18, however, you can also read that there is a gap between 17 and 18
The way Koha has always worked you have: Child Upper Age Limit 18 Adult Minimum Age 18
Now there is no gap and you switch at 18
I think changing a long standing behaviour will affect many people, and that makes me nervous. I know that I have helped libraries set this up in the way that works.
I think instead we need to clarify the explanation of the 'Limit'
OK this is the other solution ;) In your example, a 18 years old patron can be in Child or Adult category without breaking the limits ? For you limits are inclusive right ? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 --- Comment #8 from Nick Clemens <nick@bywatersolutions.com> --- (In reply to Fridolin SOMERS from comment #7)
(In reply to Nick Clemens from comment #6)
I don't think this is a bug, or rather, I don't know
I see your point, if you have categories: Child Upper Age Limit 17 Adult Minimum Age 18
You don't cross until you are 18, however, you can also read that there is a gap between 17 and 18
The way Koha has always worked you have: Child Upper Age Limit 18 Adult Minimum Age 18
Now there is no gap and you switch at 18
I think changing a long standing behaviour will affect many people, and that makes me nervous. I know that I have helped libraries set this up in the way that works.
I think instead we need to clarify the explanation of the 'Limit'
OK this is the other solution ;)
In your example, a 18 years old patron can be in Child or Adult category without breaking the limits ?
For you limits are inclusive right ?
I think the lower limit is inclusive, the upper is exclusive: At least X years old to Less than X years old However, in testing, it was found that the scripts work on way, and the interface another. Try to enter a patron into a category from 5-17. At 17 and 1 day they can still be entered, at 18 they are prohibited. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 --- Comment #9 from Fridolin SOMERS <fridolin.somers@biblibre.com> --- My colleges tell me that limits are inclusive and on purpose one must have one year in common between child and adult. For example : Child Upper Age Limit 18 Adult Minimum Age 18 So a patron having 18 is OK in both categories. This makes sens if you manually switch patron category. If you use update_patrons_category.pl patron will switch from child to adult the day he turns 18. So he is not really "too old" for the category : he is at the upper limit not over it. If this is the expected behaviour there is no bug ^^ -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 Magnus Enger <magnus@libriotech.no> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |magnus@libriotech.no --- Comment #10 from Magnus Enger <magnus@libriotech.no> --- After thinking about it for a bit, I think the current behaviour makes sense. If CHILD has an upper limit of 18, it means the patron should change category on the day she turns 18. And ADULT has a lower limit of 18, because the day the patron turns 18 they should be moved to this category. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 Fridolin SOMERS <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|critical |normal --- Comment #11 from Fridolin SOMERS <fridolin.somers@biblibre.com> --- Ok but still I'm going to work on script to avoid changing category if age is not valid in new category. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|In Discussion |ASSIGNED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #109229|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #109230|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #109231|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #109232|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=22920 CC| |andrew@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |27554 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27554 [Bug 27554] Wrong test for Koha::Patrons->update_category_to child to adult -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|misc/cronjobs/update_patron |Changind |s_category.pl --too_old |update_patrons_category |acts a year too early |should check age limits -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Changind |Changing patron category |update_patrons_category |should check age limits |should check age limits | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26307 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|ASSIGNED |RESOLVED --- Comment #12 from Fridolin Somers <fridolin.somers@biblibre.com> --- Forget about that too much work. Since we have Bug 26311 its OK. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org