Bugzilla – Attachment 189833 Details for
Bug 36303
Add after_circ_action hook action for checking in item that was not checked out
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36303: Add after_circ_action hook action for checking in item that was not checked out
Bug-36303-Add-aftercircaction-hook-action-for-chec.patch (text/plain), 4.20 KB, created by
David Gustafsson
on 2025-11-21 09:27:21 UTC
(
hide
)
Description:
Bug 36303: Add after_circ_action hook action for checking in item that was not checked out
Filename:
MIME Type:
Creator:
David Gustafsson
Created:
2025-11-21 09:27:21 UTC
Size:
4.20 KB
patch
obsolete
>From af14f257e928a5e6cd845b813d40321075c0395e Mon Sep 17 00:00:00 2001 >From: Stefan Berndtsson <stefan.berndtsson@gmail.com> >Date: Thu, 27 Oct 2022 09:22:56 +0200 >Subject: [PATCH] Bug 36303: Add after_circ_action hook action for checking in > item that was not checked out > >To test: > >1) Run tests in t/db_dependent/Koha/Plugins/Circulation_hooks.t > >Sponsored-by: Gothenburg University Library >--- > C4/Circulation.pm | 8 ++++++++ > t/db_dependent/Koha/Plugins/Circulation_hooks.t | 11 +++++++---- > t/lib/plugins/Koha/Plugin/Test.pm | 11 ++++++++--- > 3 files changed, 23 insertions(+), 7 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 0a8df342638..f288923f533 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2767,6 +2767,14 @@ sub AddReturn { > > } > >+ if ( !$issue ) { >+ Koha::Plugins->call( 'after_circ_action', { >+ action => 'checkin_no_issue', >+ payload => { >+ checkin => $item >+ } >+ }); >+ } > return ( $doreturn, $messages, $issue, ( $patron ? $patron->unblessed : {} ) ); > } > >diff --git a/t/db_dependent/Koha/Plugins/Circulation_hooks.t b/t/db_dependent/Koha/Plugins/Circulation_hooks.t >index 21880062993..e17d777bbcc 100755 >--- a/t/db_dependent/Koha/Plugins/Circulation_hooks.t >+++ b/t/db_dependent/Koha/Plugins/Circulation_hooks.t >@@ -72,6 +72,7 @@ subtest 'after_circ_action() hook tests' => sub { > my $biblio = $builder->build_sample_biblio(); > my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); > my $item_2 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); >+ my $item_no_issue = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); > > subtest 'AddIssue' => sub { > plan tests => 2; >@@ -102,7 +103,7 @@ subtest 'after_circ_action() hook tests' => sub { > }; > > subtest 'AddReturn' => sub { >- plan tests => 2; >+ plan tests => 3; > > t::lib::Mocks::mock_preference( 'BlockReturnOfWithdrawnItems', 1 ); > $item_1->set( { withdrawn => 1 } )->store; >@@ -115,11 +116,13 @@ subtest 'after_circ_action() hook tests' => sub { > t::lib::Mocks::mock_preference( 'BlockReturnOfWithdrawnItems', 0 ); > $item_1->set( { withdrawn => 0 } )->store; > >- warning_like { >- AddReturn( $item_1->barcode, $patron->branchcode ); >- } >+ warning_like { AddReturn( $item_1->barcode, $patron->branchcode ); } > qr/after_circ_action called with action: checkin, ref: Koha::Old::Checkout/, > 'AddReturn calls the after_circ_action hook'; >+ >+ warning_like { AddReturn( $item_no_issue->barcode, $patron->branchcode ); } >+ qr/after_circ_action called with action: checkin_no_issue, ref: Koha::Item/, >+ 'AddReturn calls the after_circ_action hook'; > }; > > Koha::Plugins->RemovePlugins; >diff --git a/t/lib/plugins/Koha/Plugin/Test.pm b/t/lib/plugins/Koha/Plugin/Test.pm >index 4d6bd517f69..88e091f4d6a 100644 >--- a/t/lib/plugins/Koha/Plugin/Test.pm >+++ b/t/lib/plugins/Koha/Plugin/Test.pm >@@ -227,19 +227,24 @@ sub after_circ_action { > my ( $self, $params ) = @_; > > my $action = $params->{action}; >- my $checkout = $params->{payload}->{checkout}; > my $payload = $params->{payload}; > >- my $type = $payload->{type}; >- > if ( $action eq 'renewal' ) { >+ my $checkout = $payload->{checkout}; > Koha::Exception->throw( "after_circ_action called with action: $action, ref: " . ref($checkout) ); > } elsif ( $action eq 'checkout' ) { >+ my $checkout = $payload->{checkout}; >+ my $type = $payload->{type}; > Koha::Exception->throw( > "after_circ_action called with action: $action, ref: " . ref($checkout) . " type: $type" ); > } elsif ( $action eq 'checkin' ) { >+ my $checkout = $payload->{checkout}; > Koha::Exception->throw( "after_circ_action called with action: $action, ref: " . ref($checkout) ); > } >+ elsif ( $action eq 'checkin_no_issue' ) { >+ my $checkin = $payload->{checkin}; >+ Koha::Exception->throw("after_circ_action called with action: $action, ref: " . ref($checkin)); >+ } > } > > sub after_hold_action { >-- >2.51.2
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 36303
:
163097
| 189833