Bug 20573: Make NotifyBorrowerDeparture's date math consistent with MembershipExpiryDaysNotice

To test:
1. Set both system preferences NotifyBorrowerDeparture and
   MembershipExpiryDaysNotice to 10 days
2. Create or edit a patron account with the following settings:
    - expiry date is exactly 10 days in the future
    - add an email address on the patron account
    - set messaging preferences to receive email notices for Patron
      account expiry
3. Run the membership expiry cron job to generate a notice:
   ktd --shell
   perl misc/cronjobs/membership_expiry.pl -c
4. Check notices tab on patron account
--> A membership expiry notice has been queued for the patron
5. Click back to the patron details
--> Note that there is no alert that the patron account will be expiring
    soon
6. Apply patch and restart_all
7. Refresh the patron details page
--> You should now see an alert that the account will be expiring soon

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Emily Lamancusa 2026-07-01 14:46:14 -04:00 committed by Lucas Gass
parent 1ed715b009
commit d4fa6c54c9
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 3 additions and 3 deletions

View File

@ -1038,7 +1038,7 @@ sub is_going_to_expire {
return 0 unless $self->dateexpiry;
return 0 if $self->dateexpiry =~ '^9999';
return 1
if dt_from_string( $self->dateexpiry, undef, 'floating' )->subtract( days => $delay ) <
if dt_from_string( $self->dateexpiry, undef, 'floating' )->subtract( days => $delay ) <=
dt_from_string( undef, undef, 'floating' )->truncate( to => 'day' );
return 0;
}

View File

@ -417,8 +417,8 @@ subtest 'is_going_to_expire' => sub {
t::lib::Mocks::mock_preference( 'NotifyBorrowerDeparture', 10 );
$patron->dateexpiry( $today->clone->add( days => 10 ) )->store->discard_changes;
is(
$patron->is_going_to_expire, 0,
'Patron should not be considered going to expire if dateexpiry is 10 days ahead and pref is 10'
$patron->is_going_to_expire, 1,
'Patron should be considered going to expire if dateexpiry is 10 days ahead and pref is 10'
);
$patron->delete;