View | Details | Raw Unified | Return to bug 36303
Collapse All | Expand All

(-)a/C4/Circulation.pm (+8 lines)
Lines 2767-2772 sub AddReturn { Link Here
2767
2767
2768
    }
2768
    }
2769
2769
2770
    if ( !$issue ) {
2771
        Koha::Plugins->call( 'after_circ_action', {
2772
            action  => 'checkin_no_issue',
2773
            payload => {
2774
                checkin => $item
2775
            }
2776
        });
2777
    }
2770
    return ( $doreturn, $messages, $issue, ( $patron ? $patron->unblessed : {} ) );
2778
    return ( $doreturn, $messages, $issue, ( $patron ? $patron->unblessed : {} ) );
2771
}
2779
}
2772
2780
(-)a/t/db_dependent/Koha/Plugins/Circulation_hooks.t (-4 / +7 lines)
Lines 72-77 subtest 'after_circ_action() hook tests' => sub { Link Here
72
    my $biblio = $builder->build_sample_biblio();
72
    my $biblio = $builder->build_sample_biblio();
73
    my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } );
73
    my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } );
74
    my $item_2 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } );
74
    my $item_2 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } );
75
    my $item_no_issue = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } );
75
76
76
    subtest 'AddIssue' => sub {
77
    subtest 'AddIssue' => sub {
77
        plan tests => 2;
78
        plan tests => 2;
Lines 102-108 subtest 'after_circ_action() hook tests' => sub { Link Here
102
    };
103
    };
103
104
104
    subtest 'AddReturn' => sub {
105
    subtest 'AddReturn' => sub {
105
        plan tests => 2;
106
        plan tests => 3;
106
107
107
        t::lib::Mocks::mock_preference( 'BlockReturnOfWithdrawnItems', 1 );
108
        t::lib::Mocks::mock_preference( 'BlockReturnOfWithdrawnItems', 1 );
108
        $item_1->set( { withdrawn => 1 } )->store;
109
        $item_1->set( { withdrawn => 1 } )->store;
Lines 115-125 subtest 'after_circ_action() hook tests' => sub { Link Here
115
        t::lib::Mocks::mock_preference( 'BlockReturnOfWithdrawnItems', 0 );
116
        t::lib::Mocks::mock_preference( 'BlockReturnOfWithdrawnItems', 0 );
116
        $item_1->set( { withdrawn => 0 } )->store;
117
        $item_1->set( { withdrawn => 0 } )->store;
117
118
118
        warning_like {
119
        warning_like { AddReturn( $item_1->barcode, $patron->branchcode ); }
119
            AddReturn( $item_1->barcode, $patron->branchcode );
120
        }
121
        qr/after_circ_action called with action: checkin, ref: Koha::Old::Checkout/,
120
        qr/after_circ_action called with action: checkin, ref: Koha::Old::Checkout/,
122
            'AddReturn calls the after_circ_action hook';
121
            'AddReturn calls the after_circ_action hook';
122
123
        warning_like { AddReturn( $item_no_issue->barcode, $patron->branchcode ); }
124
        qr/after_circ_action called with action: checkin_no_issue, ref: Koha::Item/,
125
            'AddReturn calls the after_circ_action hook';
123
    };
126
    };
124
127
125
    Koha::Plugins->RemovePlugins;
128
    Koha::Plugins->RemovePlugins;
(-)a/t/lib/plugins/Koha/Plugin/Test.pm (-4 / +8 lines)
Lines 227-245 sub after_circ_action { Link Here
227
    my ( $self, $params ) = @_;
227
    my ( $self, $params ) = @_;
228
228
229
    my $action   = $params->{action};
229
    my $action   = $params->{action};
230
    my $checkout = $params->{payload}->{checkout};
231
    my $payload  = $params->{payload};
230
    my $payload  = $params->{payload};
232
231
233
    my $type = $payload->{type};
234
235
    if ( $action eq 'renewal' ) {
232
    if ( $action eq 'renewal' ) {
233
        my $checkout = $payload->{checkout};
236
        Koha::Exception->throw( "after_circ_action called with action: $action, ref: " . ref($checkout) );
234
        Koha::Exception->throw( "after_circ_action called with action: $action, ref: " . ref($checkout) );
237
    } elsif ( $action eq 'checkout' ) {
235
    } elsif ( $action eq 'checkout' ) {
236
        my $checkout = $payload->{checkout};
237
        my $type = $payload->{type};
238
        Koha::Exception->throw(
238
        Koha::Exception->throw(
239
            "after_circ_action called with action: $action, ref: " . ref($checkout) . " type: $type" );
239
            "after_circ_action called with action: $action, ref: " . ref($checkout) . " type: $type" );
240
    } elsif ( $action eq 'checkin' ) {
240
    } elsif ( $action eq 'checkin' ) {
241
        my $checkout = $payload->{checkout};
241
        Koha::Exception->throw( "after_circ_action called with action: $action, ref: " . ref($checkout) );
242
        Koha::Exception->throw( "after_circ_action called with action: $action, ref: " . ref($checkout) );
242
    }
243
    }
244
    elsif ( $action eq 'checkin_no_issue' ) {
245
        my $checkin = $payload->{checkin};
246
        Koha::Exception->throw("after_circ_action called with action: $action, ref: " . ref($checkin));
247
    }
243
}
248
}
244
249
245
sub after_hold_action {
250
sub after_hold_action {
246
- 

Return to bug 36303