Bug 36915 - Send email notification when a booking is cancelled
Summary: Send email notification when a booking is cancelled
Status: Needs Signoff
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Thibaud Guillot
QA Contact: Martin Renvoize
URL:
Keywords:
Depends on: 29002
Blocks: 36666 36789 37034
  Show dependency treegraph
 
Reported: 2024-05-22 08:11 UTC by Thibaud Guillot
Modified: 2024-06-26 15:07 UTC (History)
4 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 36915: Send email notification when a booking is cancelled (5.79 KB, patch)
2024-05-22 08:13 UTC, Thibaud Guillot
Details | Diff | Splinter Review
Bug 36915: Send email notification when a booking is cancelled (5.62 KB, patch)
2024-05-22 09:05 UTC, Thibaud Guillot
Details | Diff | Splinter Review
Bug 36915: Send email notification when a booking is cancelled (5.68 KB, patch)
2024-06-26 14:39 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 36915: (follow-up) Pass object to GetPreparedLetter (2.86 KB, patch)
2024-06-26 14:39 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 36915: (follow-up) Basic sample notice (1.60 KB, patch)
2024-06-26 14:57 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Thibaud Guillot 2024-05-22 08:11:14 UTC
Hello :)

I purpose to add an email notification to patron when a booking is cancelled.
Comment 1 Thibaud Guillot 2024-05-22 08:13:14 UTC
Created attachment 167010 [details] [review]
Bug 36915: Send email notification when a booking is cancelled

When a booking is cancelled, patron received an email based on specific
letter.

Test plan:

1) Create a letter with code "BOOKING_CANCELLATION" on "Notices and
   slips" tool.
2) Add booking or go on item already booked in advance.
3) Cancel it
4) Verify in message_queue table directly or go on patron page and click
   on "Notices" tab section.

Sponsored by: Association de Gestion des Œuvres Sociales d'Inria (AGOS)
Comment 2 Jonathan Druart 2024-05-22 08:34:47 UTC
Shouldn't this be in $booking->delete instead?
Comment 3 Thibaud Guillot 2024-05-22 09:05:24 UTC
Created attachment 167013 [details] [review]
Bug 36915: Send email notification when a booking is cancelled

When a booking is cancelled, patron received an email based on specific
letter.

Test plan:

1) Create a letter with code "BOOKING_CANCELLATION" on "Notices and
   slips" tool.
2) Add booking or go on item already booked in advance.
3) Cancel it
4) Verify in message_queue table directly or go on patron page and click
   on "Notices" tab section.

Sponsored by: Association de Gestion des Œuvres Sociales d'Inria (AGOS)
Comment 4 Thibaud Guillot 2024-05-22 09:06:25 UTC
(In reply to Jonathan Druart from comment #2)
> Shouldn't this be in $booking->delete instead?

Thanks for your feedback, you're right.. I was wrong :)
Comment 5 Jonathan Druart 2024-05-22 09:11:55 UTC
And please provide tests ;)
Comment 6 Martin Renvoize 2024-06-20 10:50:08 UTC
I like this, and it was indeed on my enhancements list ;)

Couple of comments, however.. 

1) Could we pass the bookings object into GetPreparedLetter instead of passing various individual pieces. (Bug 19966 adds this functionality to GetPreperaredLetter, you'd want to pass the object and then call delete at the end of the method after GetPreparredLetter has returned)
2) Could we add a sample notice template too.
Comment 7 Martin Renvoize 2024-06-26 14:39:03 UTC
Created attachment 168149 [details] [review]
Bug 36915: Send email notification when a booking is cancelled

When a booking is cancelled, patron received an email based on specific
letter.

Test plan:

1) Create a letter with code "BOOKING_CANCELLATION" on "Notices and
   slips" tool.
2) Add booking or go on item already booked in advance.
3) Cancel it
4) Verify in message_queue table directly or go on patron page and click
   on "Notices" tab section.

Sponsored by: Association de Gestion des Œuvres Sociales d'Inria (AGOS)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 8 Martin Renvoize 2024-06-26 14:39:06 UTC
Created attachment 168150 [details] [review]
Bug 36915: (follow-up) Pass object to GetPreparedLetter

This patch updates the logic to pass the object to be deleted through to
GetPreparedLetter.

This way, as we add fields and accessors to the object in the future,
they will automatically become available to the notices.
Comment 9 Martin Renvoize 2024-06-26 14:42:24 UTC
I added the suggested follow-up to utilise the 'objects' option in GetPreparedLetter.

Still needs unit tests.. I'll try to take a look at adding those when I can.

I'm also working on a default notice template to ship.

I do wonder if we really want to tie this to 'delete'.. I'd be tempted to introduce a 'cancel' method to be more explicit. Then if we later introduce database cleanup or other workflows that include deletions we can call the standard delete method without having to work around the cancellation message handling.
Comment 10 Martin Renvoize 2024-06-26 14:57:30 UTC
Created attachment 168155 [details] [review]
Bug 36915: (follow-up) Basic sample notice