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

(-)a/C4/Circulation.pm (+9 lines)
Lines 2585-2590 sub AddReturn { Link Here
2585
        ) if C4::Context->preference('RealTimeHoldsQueue');
2585
        ) if C4::Context->preference('RealTimeHoldsQueue');
2586
    }
2586
    }
2587
2587
2588
    if ( !$issue ) {
2589
        Koha::Plugins->call('after_circ_action', {
2590
            action  => 'checkin_no_issue',
2591
            payload => {
2592
                checkin => $item
2593
            }
2594
        });
2595
    }
2596
2588
    return ( $doreturn, $messages, $issue, ( $patron ? $patron->unblessed : {} ));
2597
    return ( $doreturn, $messages, $issue, ( $patron ? $patron->unblessed : {} ));
2589
}
2598
}
2590
2599
(-)a/t/db_dependent/Koha/Plugins/Circulation_hooks.t (-5 / +8 lines)
Lines 71-76 subtest 'after_circ_action() hook tests' => sub { Link Here
71
    my $biblio = $builder->build_sample_biblio();
71
    my $biblio = $builder->build_sample_biblio();
72
    my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } );
72
    my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } );
73
    my $item_2 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } );
73
    my $item_2 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } );
74
    my $item_no_issue = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } );
74
75
75
    subtest 'AddIssue' => sub {
76
    subtest 'AddIssue' => sub {
76
        plan tests => 2;
77
        plan tests => 2;
Lines 101-107 subtest 'after_circ_action() hook tests' => sub { Link Here
101
    };
102
    };
102
103
103
    subtest 'AddReturn' => sub {
104
    subtest 'AddReturn' => sub {
104
        plan tests => 2;
105
        plan tests => 3;
105
106
106
        t::lib::Mocks::mock_preference('BlockReturnOfWithdrawnItems', 1);
107
        t::lib::Mocks::mock_preference('BlockReturnOfWithdrawnItems', 1);
107
        $item_1->set({ withdrawn => 1 })->store;
108
        $item_1->set({ withdrawn => 1 })->store;
Lines 113-123 subtest 'after_circ_action() hook tests' => sub { Link Here
113
        t::lib::Mocks::mock_preference('BlockReturnOfWithdrawnItems', 0);
114
        t::lib::Mocks::mock_preference('BlockReturnOfWithdrawnItems', 0);
114
        $item_1->set({ withdrawn => 0 })->store;
115
        $item_1->set({ withdrawn => 0 })->store;
115
116
116
        warning_like {
117
        warning_like { AddReturn( $item_1->barcode, $patron->branchcode ); }
117
            AddReturn( $item_1->barcode, $patron->branchcode );
118
        }
119
        qr/after_circ_action called with action: checkin, ref: Koha::Old::Checkout/,
118
        qr/after_circ_action called with action: checkin, ref: Koha::Old::Checkout/,
120
          'AddReturn calls the after_circ_action hook';
119
        'AddReturn calls the after_circ_action hook';
120
121
        warning_like { AddReturn( $item_no_issue->barcode, $patron->branchcode ); }
122
        qr/after_circ_action called with action: checkin_no_issue, ref: Koha::Item/,
123
        'AddReturn calls the after_circ_action hook';
121
    };
124
    };
122
125
123
    $schema->storage->txn_rollback;
126
    $schema->storage->txn_rollback;
(-)a/t/lib/plugins/Koha/Plugin/Test.pm (-4 / +8 lines)
Lines 191-210 sub after_circ_action { Link Here
191
    my ( $self, $params ) = @_;
191
    my ( $self, $params ) = @_;
192
192
193
    my $action   = $params->{action};
193
    my $action   = $params->{action};
194
    my $checkout = $params->{payload}->{checkout};
195
    my $payload  = $params->{payload};
194
    my $payload  = $params->{payload};
196
195
197
    my $type = $payload->{type};
198
199
    if ( $action eq 'renewal' ) {
196
    if ( $action eq 'renewal' ) {
197
        my $checkout = $payload->{checkout};
200
        Koha::Exception->throw("after_circ_action called with action: $action, ref: " . ref($checkout));
198
        Koha::Exception->throw("after_circ_action called with action: $action, ref: " . ref($checkout));
201
    }
199
    }
202
    elsif ( $action eq 'checkout') {
200
    elsif ( $action eq 'checkout') {
201
        my $checkout = $payload->{checkout};
202
        my $type = $payload->{type};
203
        Koha::Exception->throw("after_circ_action called with action: $action, ref: " . ref($checkout) . " type: $type");
203
        Koha::Exception->throw("after_circ_action called with action: $action, ref: " . ref($checkout) . " type: $type");
204
    }
204
    }
205
    elsif ( $action eq 'checkin' ) {
205
    elsif ( $action eq 'checkin' ) {
206
        my $checkout = $payload->{checkout};
206
        Koha::Exception->throw("after_circ_action called with action: $action, ref: " . ref($checkout));
207
        Koha::Exception->throw("after_circ_action called with action: $action, ref: " . ref($checkout));
207
    }
208
    }
209
    elsif ( $action eq 'checkin_no_issue' ) {
210
        my $checkin = $payload->{checkin};
211
        Koha::Exception->throw("after_circ_action called with action: $action, ref: " . ref($checkin));
212
    }
208
}
213
}
209
214
210
sub after_hold_action {
215
sub after_hold_action {
211
- 

Return to bug 36303