Bugzilla – Attachment 163097 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.29 KB, created by
David Gustafsson
on 2024-03-12 18:20:47 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:
2024-03-12 18:20:47 UTC
Size:
4.29 KB
patch
obsolete
>From 2d6fb6cdc42282a38ad227a1a3c7e34894e24694 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 | 9 +++++++++ > t/db_dependent/Koha/Plugins/Circulation_hooks.t | 13 ++++++++----- > t/lib/plugins/Koha/Plugin/Test.pm | 11 ++++++++--- > 3 files changed, 25 insertions(+), 8 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 109809d4b99..b2c6a4305c2 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2585,6 +2585,15 @@ sub AddReturn { > ) if C4::Context->preference('RealTimeHoldsQueue'); > } > >+ 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 89587f5de74..a7213408ef6 100755 >--- a/t/db_dependent/Koha/Plugins/Circulation_hooks.t >+++ b/t/db_dependent/Koha/Plugins/Circulation_hooks.t >@@ -71,6 +71,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; >@@ -101,7 +102,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; >@@ -113,11 +114,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'; >+ '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'; > }; > > $schema->storage->txn_rollback; >diff --git a/t/lib/plugins/Koha/Plugin/Test.pm b/t/lib/plugins/Koha/Plugin/Test.pm >index 1012663cdfe..bb4bbf005f1 100644 >--- a/t/lib/plugins/Koha/Plugin/Test.pm >+++ b/t/lib/plugins/Koha/Plugin/Test.pm >@@ -191,20 +191,25 @@ 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.43.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 36303
: 163097