Bug 34621

Summary: Patron import option to 'Renew existing patrons' 'from the current membership expiry date' not implemented
Product: Koha Reporter: Nick Clemens (kidclamp) <nick>
Component: ToolsAssignee: Kyle M Hall <kyle>
Status: Pushed to main --- QA Contact: Marcel de Rooy <m.de.rooy>
Severity: normal    
Priority: P5 - low CC: david, kyle, m.de.rooy, martin.renvoize, victor
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=34617
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=34883
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This fixes the option when importing patrons so that the expiry date is updated for existing patrons (Tools > Patrons > Import patrons > Preserve existing values > Overwrite the existing one with this > Renew existing patrons - from the current membership expiry date).
Version(s) released in:
24.05.00
Bug Depends on: 27920    
Bug Blocks:    
Attachments: Bug 34621: implement Patron import option to 'Renew existing patrons' 'from the current membership expiry date'
Bug 34621: implement Patron import option to 'Renew existing patrons' 'from the current membership expiry date'
Bug 34621: implement Patron import option to 'Renew existing patrons' 'from the current membership expiry date'
Bug 34621: implement Patron import option to 'Renew existing patrons' 'from the current membership expiry date'
Bug 34621: implement Patron import option to 'Renew existing patrons' 'from the current membership expiry date'
Bug 34621: implement Patron import option to 'Renew existing patrons' 'from the current membership expiry date'
Bug 34621: Tidy Import.t
Bug 34621: Tidy import_patrons.pl
Bug 34621: implement Patron import option to 'Renew existing patrons' 'from the current membership expiry date'
Bug 34621: Tidy Import.t
Bug 34621: Tidy import_patrons.pl

Description Nick Clemens (kidclamp) 2023-08-25 16:20:19 UTC
On bug 27920 the interface got a new option to extend the patron's renewal from the current membership expiry date by setting the variable 'update_dateexpiry' to 'dateexpiry'

The code in tools/import_borrowers.pl however only checks for value 'now':
127             update_dateexpiry            => $update_dateexpiry ? 1 : 0,


And in Koha/Patrons/Import.pm - we either use the value from the import file, or today's date:
176         my $expiration_start_date = $update_dateexpiry_from_today ? dt_from_string : $borrower{dateenrolled};

We should either implement or remove this option
Comment 1 Kyle M Hall 2023-08-25 17:39:22 UTC
Created attachment 154841 [details] [review]
Bug 34621: implement Patron import option to 'Renew existing patrons' 'from the current membership expiry date'
Comment 2 Kyle M Hall 2023-08-25 17:47:26 UTC
Created attachment 154842 [details] [review]
Bug 34621: implement Patron import option to 'Renew existing patrons' 'from the current membership expiry date'

Test Plan:
1) Test importing a patron with the "from the current membership expiry date" option,
   note it does not work
2) Apply this patch
3) Restart all the things!
4) Re-test, note the expiration was renewed from the patron's current
   expiration date!
Comment 3 David Nind 2023-08-25 23:40:35 UTC
Created attachment 154853 [details] [review]
Bug 34621: implement Patron import option to 'Renew existing patrons' 'from the current membership expiry date'

Test Plan:
1) Test importing a patron with the "from the current membership expiry date" option,
   note it does not work
2) Apply this patch
3) Restart all the things!
4) Re-test, note the expiration was renewed from the patron's current
   expiration date!

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 David Nind 2023-08-26 00:06:09 UTC
Testing notes using KTD:

1. I used this data, saved as a CSV file, to test:

cardnumber	surname	branchcode	categorycode
23529000651225	Burton	CPL	PT

2. Before the patch was applied and after importing the patron data, the expiry date remained as 12/31/2099.

3. After the patch was applied and after importing the patron data, the expiry date was 03/31/2108 - adding 99 months (8 years and 3 months) for the Patron (PT) category.
Comment 5 Marcel de Rooy 2023-09-01 09:38:49 UTC
What is the effect of this on bug 34617 ?
Comment 6 Victor Grousset/tuxayo 2023-09-05 19:56:10 UTC
Created attachment 155235 [details] [review]
Bug 34621: implement Patron import option to 'Renew existing patrons' 'from the current membership expiry date'

Test Plan:
1) Test importing a patron with the "from the current membership expiry date" option,
   note it does not work
2) Apply this patch
3) Restart all the things!
4) Re-test, note the expiration was renewed from the patron's current
   expiration date!

Signed-off-by: David Nind <david@davidnind.com>
Rebased-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 7 Marcel de Rooy 2023-09-29 06:21:07 UTC
Please reply on questions asked.
Comment 8 Nick Clemens (kidclamp) 2023-12-19 16:57:01 UTC
(In reply to Marcel de Rooy from comment #5)
> What is the effect of this on bug 34617 ?

On the staff interface there is an option to "Renew existing patrons" - "from the current membership expiry date" - we implement that

Bug 34617 made sure that we do update the dateexpiry per any setting when there was no dateexpiry column in the file.

So if a patron import doesn't have a dateexpiry column, and we select "Renew existing patrons" - "from the current membership expiry date" it will work

If the patron import does have a dateexpiry column and we select "Renew existing patrons" - "from the current membership expiry date" - it will ignore the imported date and use the calculated date - as expected

If you select 'Ignore' or 'Renew using the dateexpiry in the file' then it will do that
Comment 9 Victor Grousset/tuxayo 2024-01-14 17:43:31 UTC
Created attachment 161027 [details] [review]
Bug 34621: implement Patron import option to 'Renew existing patrons' 'from the current membership expiry date'

Test Plan:
1) Test importing a patron with the "from the current membership expiry date" option,
   note it does not work
2) Apply this patch
3) Restart all the things!
4) Re-test, note the expiration was renewed from the patron's current
   expiration date!

Signed-off-by: David Nind <david@davidnind.com>
Rebased-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 10 Victor Grousset/tuxayo 2024-01-14 17:50:36 UTC
Rebased (was not applying) and fixed POD of --expiration-from-existing having -et instead of -ee
Comment 11 Marcel de Rooy 2024-03-15 10:12:43 UTC
 WARN   misc/import_patrons.pl
   WARN   tidiness
                The file is less tidy than before (bad/messy lines before: 7, now: 8)

 FAIL   t/db_dependent/Koha/Patrons/Import.t
   FAIL   critic
                # Variables::ProhibitUnusedVariables: Got 1 violation(s).
   WARN   tidiness
                The file is less tidy than before (bad/messy lines before: 477, now: 482)

 OK     tools/import_borrowers.pl
Comment 12 Kyle M Hall 2024-03-18 11:01:13 UTC
Created attachment 163304 [details] [review]
Bug 34621: implement Patron import option to 'Renew existing patrons' 'from the current membership expiry date'

Test Plan:
1) Test importing a patron with the "from the current membership expiry date" option,
   note it does not work
2) Apply this patch
3) Restart all the things!
4) Re-test, note the expiration was renewed from the patron's current
   expiration date!

Signed-off-by: David Nind <david@davidnind.com>
Rebased-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 13 Kyle M Hall 2024-03-18 11:01:20 UTC
Created attachment 163305 [details] [review]
Bug 34621: Tidy Import.t
Comment 14 Kyle M Hall 2024-03-18 11:04:54 UTC
Created attachment 163306 [details] [review]
Bug 34621: Tidy import_patrons.pl
Comment 15 Marcel de Rooy 2024-04-12 09:02:49 UTC
Created attachment 164808 [details] [review]
Bug 34621: implement Patron import option to 'Renew existing patrons' 'from the current membership expiry date'

Test Plan:
1) Test importing a patron with the "from the current membership expiry date" option,
   note it does not work
2) Apply this patch
3) Restart all the things!
4) Re-test, note the expiration was renewed from the patron's current
   expiration date!

Signed-off-by: David Nind <david@davidnind.com>
Rebased-by: Victor Grousset/tuxayo <victor@tuxayo.net>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 16 Marcel de Rooy 2024-04-12 09:02:52 UTC
Created attachment 164809 [details] [review]
Bug 34621: Tidy Import.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 17 Marcel de Rooy 2024-04-12 09:02:54 UTC
Created attachment 164810 [details] [review]
Bug 34621: Tidy import_patrons.pl

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 18 Katrin Fischer 2024-04-12 12:06:21 UTC
Pushed for 24.05!

Well done everyone, thank you!