Bugzilla – Attachment 170933 Details for
Bug 37803
Add patron notification when a new booking has been created successfully
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37803: Add patron notification when a new booking has been created successfully
Bug-37803-Add-patron-notification-when-a-new-booki.patch (text/plain), 8.41 KB, created by
Paul Derscheid
on 2024-09-02 10:43:27 UTC
(
hide
)
Description:
Bug 37803: Add patron notification when a new booking has been created successfully
Filename:
MIME Type:
Creator:
Paul Derscheid
Created:
2024-09-02 10:43:27 UTC
Size:
8.41 KB
patch
obsolete
>From 99cff755f2d31211198a22b9b997999c1c50c52e Mon Sep 17 00:00:00 2001 >From: Paul Derscheid <paul.derscheid@lmscloud.de> >Date: Mon, 2 Sep 2024 12:42:11 +0200 >Subject: [PATCH] Bug 37803: Add patron notification when a new booking has > been created successfully > >--- > Koha/Booking.pm | 68 ++++++++++++------- > .../mysql/en/mandatory/sample_notices.yml | 24 +++++++ > t/db_dependent/Koha/Booking.t | 55 ++++++++++++++- > 3 files changed, 122 insertions(+), 25 deletions(-) > >diff --git a/Koha/Booking.pm b/Koha/Booking.pm >index c16ae91c4f..8d7b728d46 100644 >--- a/Koha/Booking.pm >+++ b/Koha/Booking.pm >@@ -153,31 +153,53 @@ sub 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 ( $self = $self->SUPER::store ) { >+ if ( $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', >- } >+ if ($letter) { >+ C4::Letters::EnqueueLetter( >+ { >+ letter => $letter, >+ borrowernumber => $patron->borrowernumber, >+ message_transport_type => 'email', >+ } >+ ); >+ } >+ } elsif ( !$is_modification ) { >+ my $patron = $self->patron; >+ my $pickup_library = $self->pickup_library; >+ >+ my $letter = C4::Letters::GetPreparedLetter( >+ module => 'bookings', >+ letter_code => 'BOOKING_CONFIRMATION', >+ 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 3896b90974..aca2c31a10 100644 >--- a/installer/data/mysql/en/mandatory/sample_notices.yml >+++ b/installer/data/mysql/en/mandatory/sample_notices.yml >@@ -90,6 +90,30 @@ tables: > - "<br>" > - "[% booking.pickup_library.branchname %]" > >+ - module: bookings >+ code: BOOKING_CONFIRMATION >+ branchcode: "" >+ name: "Booking confirmation notice" >+ is_html: 1 >+ title: "A library booking was confirmed" >+ 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 confirmed.<br>" >+ - "<br>" >+ - "The 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 9eef67069d..e8d745ba80 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 => 14; >+ plan tests => 15; > $schema->storage->txn_begin; > > my $patron = $builder->build_object( { class => "Koha::Patrons" } ); >@@ -322,7 +322,7 @@ subtest 'store() tests' => sub { > # รข Any (1) |--| > }; > >- subtest 'notice trigger' => sub { >+ subtest 'modification notice trigger' => sub { > plan tests => 3; > > my $original_notices_count = Koha::Notice::Messages->search( >@@ -404,6 +404,57 @@ subtest 'store() tests' => sub { > ); > }; > >+ subtest 'confirmation notice trigger' => sub { >+ plan tests => 2; >+ >+ my $original_notices_count = Koha::Notice::Messages->search( >+ { >+ letter_code => 'BOOKING_CONFIRMATION', >+ borrowernumber => $patron->borrowernumber, >+ } >+ )->count; >+ >+ # Reuse previous booking to produce a clash >+ eval { $booking = Koha::Booking->new( $booking->unblessed )->store }; >+ >+ my $post_notices_count = Koha::Notice::Messages->search( >+ { >+ letter_code => 'BOOKING_CONFIRMATION', >+ borrowernumber => $patron->borrowernumber, >+ } >+ )->count; >+ is( >+ $post_notices_count, >+ $original_notices_count, >+ 'Koha::Booking->store should not have enqueued a BOOKING_CONFIRMATION email if booking creation fails' >+ ); >+ >+ $start_1 = dt_from_string->add( months => 1 )->truncate( to => 'day' ); >+ $end_1 = $start_1->clone()->add( days => 1 ); >+ >+ $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; >+ >+ $post_notices_count = Koha::Notice::Messages->search( >+ { >+ letter_code => 'BOOKING_CONFIRMATION', >+ borrowernumber => $patron->borrowernumber, >+ } >+ )->count; >+ is( >+ $post_notices_count, >+ $original_notices_count + 1, >+ 'Koha::Booking->store should have enqueued a BOOKING_CONFIRMATION email for a new booking' >+ ); >+ }; >+ > $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 37803
:
170933
|
170934
|
170935
|
171066
|
172829
|
173286