Bugzilla – Attachment 170805 Details for
Bug 37204
Add a booking has changed notice to update a patron should a booking be updated
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37204: Add a booking has changed notice to update a patron should a booking be updated
Bug-37204-Add-a-booking-has-changed-notice-to-upda.patch (text/plain), 7.70 KB, created by
Paul Derscheid
on 2024-08-28 11:31:30 UTC
(
hide
)
Description:
Bug 37204: Add a booking has changed notice to update a patron should a booking be updated
Filename:
MIME Type:
Creator:
Paul Derscheid
Created:
2024-08-28 11:31:30 UTC
Size:
7.70 KB
patch
obsolete
>From b4167f8b8aeb37a3502f2c1301361c1fb6c01623 Mon Sep 17 00:00:00 2001 >From: Paul Derscheid <paul.derscheid@lmscloud.de> >Date: Wed, 28 Aug 2024 13:22:00 +0200 >Subject: [PATCH] Bug 37204: Add a booking has changed notice to update a > patron should a booking be updated > >This is a first draft. When reading your initial statement again I'm asking myself whether >a changed itemnumber is relevant to the patron. >The way I see it, the relevant fields are: >- pickup_library_id >- start_date >- end_date > >But maybe I'm not seeing it. > >To test: >1) Apply the patch >2) Make an item bookable >3) Add a booking for a given patron >4) Check the patron notices tab, should not contain any notices >5) Change either start date, end date or pickup library and save >6) Check the patron notices tab, should contain a notice with the updated details >7) Run the tests under t/db_dependent/Koha/Booking.t >8) Sign off >--- > Koha/Booking.pm | 32 ++++++- > .../mysql/en/mandatory/sample_notices.yml | 24 ++++++ > t/db_dependent/Koha/Booking.t | 84 ++++++++++++++++++- > 3 files changed, 138 insertions(+), 2 deletions(-) > >diff --git a/Koha/Booking.pm b/Koha/Booking.pm >index e5297d8d17..c16ae91c4f 100644 >--- a/Koha/Booking.pm >+++ b/Koha/Booking.pm >@@ -27,6 +27,8 @@ use Koha::Libraries; > > use C4::Letters; > >+use List::Util qw(any); >+ > use base qw(Koha::Object); > > =head1 NAME >@@ -149,7 +151,35 @@ sub store { > $self->_assign_item_for_booking; > } > >- $self = $self->SUPER::store; >+ my $is_modification = $self->in_storage; >+ my $old_booking = $self->get_from_storage; >+ if ( $self = >+ $self->SUPER::store >+ and $is_modification >+ and any { $old_booking->$_ ne $self->$_ } qw(pickup_library_id start_date end_date) ) >+ { >+ my $patron = $self->patron; >+ my $pickup_library = $self->pickup_library; >+ >+ my $letter = C4::Letters::GetPreparedLetter( >+ module => 'bookings', >+ letter_code => 'BOOKING_MODIFICATION', >+ message_transport_type => 'email', >+ branchcode => $pickup_library->branchcode, >+ lang => $patron->lang, >+ objects => { booking => $self }, >+ ); >+ >+ if ($letter) { >+ C4::Letters::EnqueueLetter( >+ { >+ letter => $letter, >+ borrowernumber => $patron->borrowernumber, >+ message_transport_type => 'email', >+ } >+ ); >+ } >+ } > } > ); > >diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml >index ec0e2386da..3896b90974 100644 >--- a/installer/data/mysql/en/mandatory/sample_notices.yml >+++ b/installer/data/mysql/en/mandatory/sample_notices.yml >@@ -66,6 +66,30 @@ tables: > - "<br>" > - "[% booking.pickup_library.branchname %]" > >+ - module: bookings >+ code: BOOKING_MODIFICATION >+ branchcode: "" >+ name: "Booking modification notice" >+ is_html: 1 >+ title: "A library booking was modified" >+ message_transport_type: email >+ lang: default >+ content: >+ - "[%- PROCESS 'html_helpers.inc' -%]" >+ - "[%- USE KohaDates -%]" >+ - "Dear [%- INCLUDE 'patron-title.inc' patron => booking.patron -%],<br>" >+ - "<br>" >+ - "Your booking of [%- INCLUDE 'biblio-title.inc' biblio=booking.biblio link = 0 -%] has been modified.<br>" >+ - "<br>" >+ - "The new details are:<br>" >+ - "<br>" >+ - "Dates: [% booking.start_date | $KohaDates %] to [% booking.end_date | $KohaDates %]<br>" >+ - "<br>" >+ - "Pickup at: [% booking.pickup_library.branchname %]<br>" >+ - "Kind regards<br>" >+ - "<br>" >+ - "[% booking.pickup_library.branchname %]" >+ > - module: catalogue > code: TICKET_ACKNOWLEDGE > branchcode: "" >diff --git a/t/db_dependent/Koha/Booking.t b/t/db_dependent/Koha/Booking.t >index a0805a6a14..9eef67069d 100755 >--- a/t/db_dependent/Koha/Booking.t >+++ b/t/db_dependent/Koha/Booking.t >@@ -123,7 +123,7 @@ subtest 'Relation accessor tests' => sub { > }; > > subtest 'store() tests' => sub { >- plan tests => 13; >+ plan tests => 14; > $schema->storage->txn_begin; > > my $patron = $builder->build_object( { class => "Koha::Patrons" } ); >@@ -322,6 +322,88 @@ subtest 'store() tests' => sub { > # รข Any (1) |--| > }; > >+ subtest 'notice trigger' => sub { >+ plan tests => 3; >+ >+ my $original_notices_count = Koha::Notice::Messages->search( >+ { >+ letter_code => 'BOOKING_MODIFICATION', >+ borrowernumber => $patron->borrowernumber, >+ } >+ )->count; >+ >+ $start_1 = dt_from_string->add( months => 1 )->truncate( to => 'day' ); >+ $end_1 = $start_1->clone()->add( days => 1 ); >+ >+ # Use datetime formatting so that we don't get DateTime objects >+ $booking = Koha::Booking->new( >+ { >+ patron_id => $patron->borrowernumber, >+ biblio_id => $biblio->biblionumber, >+ pickup_library_id => $item_2->homebranch, >+ start_date => $start_1->datetime(q{ }), >+ end_date => $end_1->datetime(q{ }), >+ } >+ )->store; >+ >+ my $post_notices_count = Koha::Notice::Messages->search( >+ { >+ letter_code => 'BOOKING_MODIFICATION', >+ borrowernumber => $patron->borrowernumber, >+ } >+ )->count; >+ is( >+ $post_notices_count, >+ $original_notices_count, >+ 'Koha::Booking->store should not have enqueued a BOOKING_MODIFICATION email for a new booking' >+ ); >+ >+ my $item_4 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, bookable => 1 } ); >+ >+ $booking->update( >+ { >+ item_id => $item_4->itemnumber, >+ } >+ ); >+ >+ $post_notices_count = Koha::Notice::Messages->search( >+ { >+ letter_code => 'BOOKING_MODIFICATION', >+ borrowernumber => $patron->borrowernumber, >+ } >+ )->count; >+ is( >+ $post_notices_count, >+ $original_notices_count, >+ 'Koha::Booking->store should not have enqueued a BOOKING_MODIFICATION email for a booking with modified item_id' >+ ); >+ >+ $booking->update( >+ { >+ start_date => $start_1->clone()->add( days => 1 )->datetime(q{ }), >+ } >+ ); >+ >+ # start_date, end_date and pickup_library_id should behave identical >+ $post_notices_count = Koha::Notice::Messages->search( >+ { >+ letter_code => 'BOOKING_MODIFICATION', >+ borrowernumber => $patron->borrowernumber, >+ } >+ )->count; >+ is( >+ $post_notices_count, >+ $original_notices_count + 1, >+ 'Koha::Booking->store should have enqueued a BOOKING_MODIFICATION email for a booking with modified start_date' >+ ); >+ >+ $booking->update( >+ { >+ end_date => $end_1->clone()->add( days => 1 )->datetime(q{ }), >+ } >+ ); >+ }; >+ > $schema->storage->txn_rollback; > }; > >-- >2.46.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 37204
:
170805
|
170939
|
172824
|
172825
|
172826
|
172827
|
172828
|
173283
|
173284
|
173285