From 9cad4c5c8de1eaac90cce3de94d39e399cafddde Mon Sep 17 00:00:00 2001 From: Emily Lamancusa Date: Wed, 1 Jul 2026 14:46:14 -0400 Subject: [PATCH] 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 Signed-off-by: Andrew Fuerste Henry Signed-off-by: Pedro Amorim --- Koha/Patron.pm | 2 +- t/db_dependent/Koha/Patrons.t | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 37d1e63b96..8b4a4c7e8f 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -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; } diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index db23712491..b9ec7fa500 100755 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -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;