}
}
- _after_circ_actions(
- {
- action => 'checkout',
- payload => {
- type => ( $onsite_checkout ? 'onsite_checkout' : 'issue' ),
- library_id => C4::Context->userenv->{'branch'},
- charge => $charge,
- item_id => $item_object->itemnumber,
- item_type => $item_object->effective_itemtype,
- shelving_location => $item_object->location // q{},
- patron_id => $borrower->{'borrowernumber'},
- collection_code => $item_object->ccode // q{},
- date_due => $datedue
- }
- }
- ) if C4::Context->config("enable_plugins");
-
# Record the fact that this book was issued.
&UpdateStats(
{
$borrower->{'borrowernumber'},
$item_object->itemnumber,
) if C4::Context->preference("IssueLog");
+
+ _after_circ_actions(
+ {
+ action => 'checkout',
+ payload => {
+ type => ( $onsite_checkout ? 'onsite_checkout' : 'issue' ),
+ checkout => $issue->get_from_storage
+ }
+ }
+ ) if C4::Context->config("enable_plugins");
}
}
return $issue;
$messages->{'ResFound'} = $resrec;
}
- _after_circ_actions(
- {
- action => 'checkin',
- payload => {
- library_id => C4::Context->userenv->{'branch'},
- item_id => $item->itemnumber,
- item_type => $item->effective_itemtype,
- shelving_location => $item->location // q{},
- patron_id => $borrowernumber,
- collection_code => $item->ccode // q{},
- date_returned => $return_date,
- date_due => $issue ? $issue->date_due : q{}
- }
- }
- ) if C4::Context->config("enable_plugins");
-
# Record the fact that this book was returned.
UpdateStats({
branch => $branch,
}
}
+ my $checkin = Koha::Old::Checkouts->find($issue->id);
+
+ _after_circ_actions(
+ {
+ action => 'checkin',
+ payload => {
+ checkout=> $checkin
+ }
+ }
+ ) if C4::Context->config("enable_plugins");
+
return ( $doreturn, $messages, $issue, ( $patron ? $patron->unblessed : {} ));
}
$test_plugin->mock( 'after_biblio_action', undef );
my $biblio = $builder->build_sample_biblio();
- my $item =
- $builder->build_sample_item( { biblionumber => $biblio->biblionumber } );
+ my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } );
+ my $item_2 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } );
subtest 'AddIssue' => sub {
- plan tests => 1;
+ plan tests => 2;
- warning_like { AddIssue( $patron->unblessed, $item->barcode ); }
- qr/after_circ_action called with action: checkout, ref: DateTime/,
+ warning_like { AddIssue( $patron->unblessed, $item_1->barcode ); }
+ qr/after_circ_action called with action: checkout, ref: Koha::Checkout type: issue/,
'AddIssue calls the after_circ_action hook';
+ warning_like { AddIssue( $patron->unblessed, $item_2->barcode, undef, undef, undef, undef, { onsite_checkout => 1 } ); }
+ qr/after_circ_action called with action: checkout, ref: Koha::Checkout type: onsite_checkout/,
+ 'AddIssue calls the after_circ_action hook (onsite_checkout case)';
};
subtest 'AddRenewal' => sub {
plan tests => 1;
- warning_like { AddRenewal( $patron->borrowernumber, $item->id, $patron->branchcode ); }
+ warning_like { AddRenewal( $patron->borrowernumber, $item_1->id, $patron->branchcode ); }
qr/after_circ_action called with action: renewal, ref: Koha::Checkout/,
'AddRenewal calls the after_circ_action hook';
};
plan tests => 1;
warning_like {
- AddReturn( $item->barcode, $patron->branchcode );
+ AddReturn( $item_1->barcode, $patron->branchcode );
}
- qr/after_circ_action called with action: checkin, ref: DateTime/,
+ qr/after_circ_action called with action: checkin, ref: Koha::Old::Checkout/,
'AddReturn calls the after_circ_action hook';
};
my $checkout = $params->{payload}->{checkout};
my $payload = $params->{payload};
- my $renewal_library_id = $payload->{renewal_library_id};
- my $charge = $payload->{charge};
- my $item_id = $payload->{item_id};
- my $item_type = $payload->{item_type};
- my $shelving_location = $payload->{shelving_location};
- my $patron_id = $payload->{patron_id};
- my $collection_code = $payload->{collection_code};
- my $date_due = $payload->{date_due};
- my $date_returned = $payload->{date_returned};
+ my $type = $payload->{type};
if ( $action eq 'renewal' ) {
Koha::Exceptions::Exception->throw("after_circ_action called with action: $action, ref: " . ref($checkout));
}
elsif ( $action eq 'checkout') {
- Koha::Exceptions::Exception->throw("after_circ_action called with action: $action, ref: " . ref($date_due));
+ Koha::Exceptions::Exception->throw("after_circ_action called with action: $action, ref: " . ref($checkout) . " type: $type");
}
elsif ( $action eq 'checkin' ) {
- Koha::Exceptions::Exception->throw("after_circ_action called with action: $action, ref: " . ref($date_returned));
+ Koha::Exceptions::Exception->throw("after_circ_action called with action: $action, ref: " . ref($checkout));
}
}