Bug 14364: (QA follow-up) Generate message for transfers as well

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Kyle Hall 2021-05-13 12:04:41 -04:00 committed by Tomas Cohen Arazi
parent 6a770ace34
commit 6c75695542
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
2 changed files with 56 additions and 9 deletions

View file

@ -1243,12 +1243,14 @@ sub ModReserveAffect {
$hold->set_processing();
} else {
$hold->set_waiting($desk_id);
_koha_notify_reserve( $hold->reserve_id, $notify_library ) unless $already_on_shelf;
_koha_notify_reserve( $hold->reserve_id ) unless $already_on_shelf;
# Complete transfer if one exists
my $transfer = $hold->item->get_transfer;
$transfer->receive if $transfer;
}
_koha_notify_hold_changed( $hold ) if $notify_library;
_FixPriority( { biblionumber => $biblionumber } );
my $item = Koha::Items->find($itemnumber);
if ( $item->location && $item->location eq 'CART'
@ -1975,6 +1977,51 @@ sub _koha_notify_reserve {
}
}
=head2 _koha_notify_hold_changed
_koha_notify_hold_changed( $hold_object );
=cut
sub _koha_notify_hold_changed {
my $hold = shift;
my $patron = $hold->patron;
my $library = $hold->branch;
my $letter = C4::Letters::GetPreparedLetter(
module => 'reserves',
letter_code => 'HOLD_CHANGED',
branchcode => $hold->branchcode,
substitute => { today => output_pref( dt_from_string ) },
tables => {
'branches' => $library->unblessed,
'borrowers' => $patron->unblessed,
'biblio' => $hold->biblionumber,
'biblioitems' => $hold->biblionumber,
'reserves' => $hold->unblessed,
'items' => $hold->itemnumber,
},
);
return unless $letter;
my $email =
C4::Context->preference('ExpireReservesAutoFillEmail')
|| $library->branchemail
|| C4::Context->preference('KohaAdminEmailAddress');
C4::Letters::EnqueueLetter(
{
letter => $letter,
borrowernumber => $patron->id,
message_transport_type => 'email',
from_address => $email,
to_address => $email,
}
);
}
=head2 _ShiftPriority
$new_priority = _ShiftPriority( $biblionumber, $priority );

View file

@ -100,11 +100,11 @@ subtest 'Test automatically canceled expired waiting holds to fill the next hold
CancelExpiredReserves();
my @holds = Koha::Holds->search( {}, { order_by => 'priority' } );
$hold_2 = $holds[0];
$hold_3 = $holds[1];
my $holds = Koha::Holds->search( {}, { order_by => 'priority' } );
$hold_2 = $holds->next;
$hold_3 = $holds->next;
is( @holds, 2, 'Found 2 holds' );
is( $holds->count, 2, 'Found 2 holds' );
is( $hold_2->priority, 0, 'Next hold in line now has priority of 0' );
is( $hold_2->found, 'W', 'Next hold in line is now set to waiting' );
@ -117,10 +117,10 @@ subtest 'Test automatically canceled expired waiting holds to fill the next hold
CancelExpiredReserves();
@holds = Koha::Holds->search( {}, { order_by => 'priority' } );
$hold_3 = $holds[0];
$holds = Koha::Holds->search( {}, { order_by => 'priority' } );
$hold_3 = $holds->next;
is( @holds, 1, 'Found 1 hold' );
is( $holds->count, 1, 'Found 1 hold' );
is( $hold_3->priority, 0, 'Next hold in line now has priority of 0' );
is( $hold_3->found, 'W', 'Next hold in line is now set to waiting' );
@ -186,5 +186,5 @@ subtest 'Test automatically canceled expired waiting holds to fill the next hold
my @messages = $schema->resultset('MessageQueue')
->search( { letter_code => 'HOLD_CHANGED' } );
is( @messages, 0, 'No messages in the message queue when generating transfer' );
is( @messages, 1, 'Nessage is generated in the message queue when generating transfer' );
};