Bugzilla – Attachment 183776 Details for
Bug 39820
Items with hold cancellation requests should have the hold cancelled when checked in via SIP
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39820: Add cancellation reason and clean up cancellation request
Bug-39820-Add-cancellation-reason-and-clean-up-can.patch (text/plain), 3.82 KB, created by
Lucas Gass (lukeg)
on 2025-07-03 20:27:58 UTC
(
hide
)
Description:
Bug 39820: Add cancellation reason and clean up cancellation request
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-07-03 20:27:58 UTC
Size:
3.82 KB
patch
obsolete
>From e6c31093a4bdd774df880d8197e91bf0ec6ee7c5 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Thu, 3 Jul 2025 20:26:36 +0000 >Subject: [PATCH] Bug 39820: Add cancellation reason and clean up cancellation > request > >--- > C4/SIP/ILS/Transaction/Checkin.pm | 5 ++++- > t/db_dependent/SIP/Transaction.t | 31 +++++++++++++++++++++---------- > 2 files changed, 25 insertions(+), 11 deletions(-) > >diff --git a/C4/SIP/ILS/Transaction/Checkin.pm b/C4/SIP/ILS/Transaction/Checkin.pm >index 516e141d576..94087723a84 100644 >--- a/C4/SIP/ILS/Transaction/Checkin.pm >+++ b/C4/SIP/ILS/Transaction/Checkin.pm >@@ -94,7 +94,10 @@ sub do_checkin { > if ($item) { > my $waiting_holds_to_be_cancelled = $item->holds->waiting->filter_by_has_cancellation_requests; > while ( my $hold = $waiting_holds_to_be_cancelled->next ) { >- $hold->cancel; >+ my $cancellation_request = $hold->cancellation_requests; >+ $cancellation_request->delete; >+ my $cancel_params->{cancellation_reason} = "Cancelled by SIP"; >+ $hold->cancel($cancel_params); > } > } > >diff --git a/t/db_dependent/SIP/Transaction.t b/t/db_dependent/SIP/Transaction.t >index 8482d3c3ce1..16487922cac 100755 >--- a/t/db_dependent/SIP/Transaction.t >+++ b/t/db_dependent/SIP/Transaction.t >@@ -711,7 +711,7 @@ subtest do_checkin => sub { > }; > > subtest 'cancel_waiting_holds_with_cancellation_requests at checkin' => sub { >- plan tests => 5; >+ plan tests => 6; > > my $library = $builder->build_object( { class => 'Koha::Libraries' } ); > my $patron1 = $builder->build_object( >@@ -758,6 +758,19 @@ subtest 'cancel_waiting_holds_with_cancellation_requests at checkin' => sub { > 'Hold has a cancellation request' > ); > >+ #Create a HOLD_CANCELLATION notice >+ my $template = Koha::Notice::Template->new( >+ { >+ module => 'reserves', >+ code => 'HOLD_CANCELLATION', >+ branchcode => '', >+ message_transport_type => 'email', >+ title => 'Hold Cancellation', >+ content => 'Your hold has been cancelled.', >+ is_html => 0, >+ } >+ )->store; >+ > my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); > my $transaction = C4::SIP::ILS::Transaction::Checkin->new(); > >@@ -766,17 +779,15 @@ subtest 'cancel_waiting_holds_with_cancellation_requests at checkin' => sub { > > # Check if the hold still exists > $hold_obj = Koha::Holds->find($hold); >- ok( !defined( $hold_obj ), 'Hold has been cancelled and deleted' ); >+ ok( !defined($hold_obj), 'Hold has been cancelled and deleted' ); > > my $old_hold = Koha::Old::Holds->find($hold); >- ok( $old_hold, 'Hold was moved to old reserves'); >- # QUESTION: Should the cancellation reason be set to "Cancelled by SIP"? >- is( $old_hold->cancellation_reason, undef, 'No cancellation reason was set' ); >- >- # FIXME: What should happen to the cancellation request? >- # Check that the cancellation request is deleted >- # my $existing_cancellation_requests = Koha::Hold::CancellationRequests->search( { hold_id => $hold } ); >- # is( $existing_cancellation_requests->count, 0, 'Cancellation request is deleted after processing' ); >+ ok( $old_hold, 'Hold was moved to old reserves' ); >+ is( $old_hold->cancellation_reason, "Cancelled by SIP", 'Cancellation reason set to Cancelled by SIP' ); >+ >+ #Check that the cancellation request is deleted >+ my $existing_cancellation_requests = Koha::Hold::CancellationRequests->search( { hold_id => $hold } ); >+ is( $existing_cancellation_requests->count, 0, 'Cancellation request is deleted after processing' ); > > # Verify the item's hold count > is( $item->holds->count, 0, 'No holds remain on the item after cancellation' ); >-- >2.39.5
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 39820
:
181999
|
182105
|
182276
|
182277
| 183776