Normally, imports only update included columns, however, if we are asking Koha to calculate expiration dates we should update the value even if it is not passed
Created attachment 154816 [details] [review] Bug 34617: Unit tests
Created attachment 154817 [details] [review] Bug 34617: Preserve calculated expiration dates if set to update on import whether column included or not To test: 1 - Setup a csv with column headers: surname firstname branchcode categorycode cardnumber dateenrolled 2 - add values Acosta Edna CPL PT 23529001000463 02/01/2013 3 - Set PT catgeory enrollement period to a specific date in the future 4 - Import the file and overwrite patrons and update dateexpiration 5 - Check Edna, note her date is not correct 6 - Apply patch 7 - Repeat 8 - Expiration date is now set as expected
Note, a workaround is simply to include a dateexpiry column in the file
Created attachment 154867 [details] [review] Bug 34617: Unit tests Signed-off-by: David Nind <david@davidnind.com>
Created attachment 154868 [details] [review] Bug 34617: Preserve calculated expiration dates if set to update on import whether column included or not To test: 1 - Setup a csv with column headers: surname firstname branchcode categorycode cardnumber dateenrolled 2 - add values Acosta Edna CPL PT 23529001000463 02/01/2013 3 - Set PT catgeory enrollement period to a specific date in the future 4 - Import the file and overwrite patrons and update dateexpiration 5 - Check Edna, note her date is not correct 6 - Apply patch 7 - Repeat 8 - Expiration date is now set as expected Signed-off-by: David Nind <david@davidnind.com>
Note that tests failed if I left step 3 of the test plan in place, if I changed back to the default then they pass. prove t/db_dependent/Koha/Patrons/Import.t t/db_dependent/Koha/Patrons/Import.t .. 2/177 # Failed test 'Expiration date is correct with update_dateexpiry = true' # at t/db_dependent/Koha/Patrons/Import.t line 218. # got: '2024-01-31' # expected: '2031-11-28' t/db_dependent/Koha/Patrons/Import.t .. 175/177 Argument "" isn't numeric in numeric eq (==) at /usr/share/perl5/DBIx/Class/Row.pm line 1018, <$handle_1> line 2. Argument "" isn't numeric in numeric eq (==) at /usr/share/perl5/DBIx/Class/Row.pm line 1018, <$handle_1> line 2. # Looks like you failed 1 test of 177. t/db_dependent/Koha/Patrons/Import.t .. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/177 subtests Test Summary Report ------------------- t/db_dependent/Koha/Patrons/Import.t (Wstat: 256 Tests: 177 Failed: 1) Failed test: 60 Non-zero exit status: 1 Files=1, Tests=177, 2 wallclock secs ( 0.03 usr 0.00 sys + 1.75 cusr 0.26 csys = 2.04 CPU) Result: FAIL
Created attachment 155066 [details] [review] Bug 34617: Unit tests Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Created attachment 155067 [details] [review] Bug 34617: Preserve calculated expiration dates if set to update on import whether column included or not To test: 1 - Setup a csv with column headers: surname firstname branchcode categorycode cardnumber dateenrolled 2 - add values Acosta Edna CPL PT 23529001000463 02/01/2013 3 - Set PT catgeory enrollement period to a specific date in the future 4 - Import the file and overwrite patrons and update dateexpiration 5 - Check Edna, note her date is not correct 6 - Apply patch 7 - Repeat 8 - Expiration date is now set as expected Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Pushed to master for 23.11. Nice work everyone, thanks!
Pushed to 23.05.x for 23.05.04
Nice work everyone! Pushed to oldstable for 22.11.x