Bug 40960: Print notification only if selected type is impossible

Test plan (ktd):
1 - Have henry acevedo have no mail and set messaging preference "Hold filled to sms"
2 - Have edna acosta have not messaging preference
3 - Place an hold on two books for edna acosta and henry acevedo, check in both books and select the button to fill the hold
4 - Check in notices and see that both received a notice
5 - Apply tests and run tests -> they should fail
6 - Apply patch, run rest -> they should pass
7 - Unfill both holds and fill them back. Henry should keep receiving notices while Edna should not anymore.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
(cherry picked from commit 505e58d1d2)
Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com>
This commit is contained in:
Baptiste 2025-10-06 11:45:10 +02:00 committed by Baptiste Wojtkowski
parent 782a5a7ca5
commit 815fd5baf2
No known key found for this signature in database
GPG Key ID: 47A8A13E10BC0D40
1 changed files with 8 additions and 7 deletions

View File

@ -1834,21 +1834,22 @@ sub _koha_notify_reserve {
};
while ( my ( $mtt, $letter_code ) = each %{ $messagingprefs->{transports} } ) {
next if (
if (
( $mtt eq 'email' and not $to_address ) # No email address
or ( $mtt eq 'sms' and not $patron->smsalertnumber ) # No SMS number
or ( $mtt eq 'itiva' and C4::Context->preference('TalkingTechItivaPhoneNotification') ) # Notice is handled by TalkingTech_itiva_outbound.pl
or ( $mtt eq 'phone' and not $patron->phone ) # No phone number to call
);
&$send_notification($mtt, $letter_code, $messagingprefs->{wants_digest});
)
{
unless ($notification_sent) {
$notification_sent++;
}
#Making sure that a print notification is sent if no other transport types can be utilized.
if (! $notification_sent) {
&$send_notification('print', 'HOLD');
}
next;
}
&$send_notification( $mtt, $letter_code, $messagingprefs->{wants_digest} );
}
}
=head2 _koha_notify_hold_changed