Bug 41073

Summary: Import users expiry date default does not apply
Product: Koha Reporter: Bernard <bernard.scaife>
Component: PatronsAssignee: Bugs List <koha-bugs>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: gmcharlt, kyle
Version: 24.11   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=34883
GIT URL: https://github.com/Koha-Community/Koha/commit/f4f77357f63013a21e700f14df82ca9261403310 Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 41073

Description Bernard 2025-10-22 15:59:43 UTC
You can no longer set an expiry date into the past. Test file:

userid,cardnumber,branchcode,categorycode,surname
"12345","65432","LONDON","STANDARD","Smith"

1. User should exist and have expiry date in future (say 2099-12-31)
2. Save above as file
3. Tools > Import users 
4. Choose file saved in 2
5. Field to use for record matching: cardnumber
6. In default values set expiration date to a date in past (say 2025-10-19) using date picker
7. Select overwrite the existing one with this
8. Leave renew existing patrons as "use the expiration date in the file if present"
9. Run
10. Observe user expiry date is still 2099-12-31

NB/ Tested in 23.11.10 where the date was correctly set to the default value chosen
Comment 1 Bernard 2025-10-24 15:10:35 UTC
I think the problem occurs in Koha/Patrons/Import.pm at line 295-6

$borrower{$col} = $member->{$col}
                    if $col eq 'dateexpiry' && ( !$csvkeycol{$col} || !$columns[ $csvkeycol{$col} ] );

The above evaluates to TRUE and resets the expiry date to its database value rather than the default that was set previously and has persisted until here. Hence it is not modified as requested.

Note other default values (eg City) work fine.
Comment 2 Bernard 2025-11-03 15:16:53 UTC
Created attachment 188976 [details] [review]
Bug 41073

Brief Description: Fixes regression in which default expiry date is ignored due to regression fix in bug 34483

Test plan:
1. User should exist and have expiry date in future (say 2099-12-31)
2. Save above as file
3. Tools > Import users
4. Choose file saved in 2
5. Field to use for record matching: cardnumber
6. In default values set expiration date to a date in past (say 2025-10-19) using date picker
7. Select overwrite the existing one with this
8. Leave renew existing patrons as "use the expiration date in the file if present"
9. Run
10. Observe user expiry date is still 2099-12-31
11. Apply patch / restart_all
12. Repeat 4 - 9 above
13. Observe user expiry date is now 2025-10-19