From ffd60727f104fd2ea12f02e75701d7e19a7c518d Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 16 Oct 2024 16:45:18 +0100 Subject: [PATCH] Bug 37204: (QA follow-up) Consistently pick notice library MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We should use the notice from the library that initiated the action that triggered the notice. This should be available to us always in the userenv. Signed-off-by: Martin Renvoize Sponsored-by: Büchereizentrale Schleswig-Holstein Signed-off-by: Katrin Fischer --- Koha/Booking.pm | 6 ++++-- t/db_dependent/Koha/Booking.t | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Koha/Booking.pm b/Koha/Booking.pm index f3376af918..c849c07e9e 100644 --- a/Koha/Booking.pm +++ b/Koha/Booking.pm @@ -160,12 +160,13 @@ sub store { { my $patron = $self->patron; my $pickup_library = $self->pickup_library; + my $branch = C4::Context->userenv->{'branch'}; my $letter = C4::Letters::GetPreparedLetter( module => 'bookings', letter_code => 'BOOKING_MODIFICATION', message_transport_type => 'email', - branchcode => $pickup_library->branchcode, + branchcode => $branch, lang => $patron->lang, objects => { old_booking => $old_booking, @@ -286,6 +287,7 @@ sub to_api_mapping { sub delete { my ($self) = @_; + my $branch = C4::Context->userenv->{'branch'}; my $patron = $self->patron; my $pickup_library = $self->pickup_library; @@ -293,7 +295,7 @@ sub delete { module => 'bookings', letter_code => 'BOOKING_CANCELLATION', message_transport_type => 'email', - branchcode => $pickup_library->branchcode, + branchcode => $branch, lang => $patron->lang, objects => { booking => $self } ); diff --git a/t/db_dependent/Koha/Booking.t b/t/db_dependent/Koha/Booking.t index 9eef67069d..cfb9764a6e 100755 --- a/t/db_dependent/Koha/Booking.t +++ b/t/db_dependent/Koha/Booking.t @@ -126,7 +126,8 @@ subtest 'store() tests' => sub { plan tests => 14; $schema->storage->txn_begin; - my $patron = $builder->build_object( { class => "Koha::Patrons" } ); + my $patron = $builder->build_object( { class => "Koha::Patrons" } ); + t::lib::Mocks::mock_userenv( { patron => $patron } ); my $biblio = $builder->build_sample_biblio(); my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); my $start_0 = dt_from_string->subtract( days => 2 )->truncate( to => 'day' ); @@ -412,7 +413,8 @@ subtest 'delete() tests' => sub { $schema->storage->txn_begin; - my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); + my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); + t::lib::Mocks::mock_userenv( { patron => $patron } ); my $biblio = $builder->build_sample_biblio; my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); my $start_0 = dt_from_string->subtract( days => 2 )->truncate( to => 'day' ); -- 2.39.5