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

(-)a/C4/Circulation.pm (+1 lines)
Lines 2047-2052 sub AddIssue { Link Here
2047
                }
2047
                }
2048
            );
2048
            );
2049
2049
2050
            # Rebuilding holds queue here to ensure the item is removed from current queue
2050
            Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(
2051
            Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(
2051
                { biblio_ids => [ $item_object->biblionumber ] } )
2052
                { biblio_ids => [ $item_object->biblionumber ] } )
2052
                if C4::Context->preference('RealTimeHoldsQueue');
2053
                if C4::Context->preference('RealTimeHoldsQueue');
(-)a/C4/SIP/ILS/Transaction/Checkin.pm (+5 lines)
Lines 14-19 use C4::SIP::ILS::Transaction; Link Here
14
use C4::Circulation qw( AddReturn LostItem );
14
use C4::Circulation qw( AddReturn LostItem );
15
use C4::Items       qw( ModItemTransfer );
15
use C4::Items       qw( ModItemTransfer );
16
use C4::Reserves    qw( ModReserve ModReserveAffect CheckReserves );
16
use C4::Reserves    qw( ModReserve ModReserveAffect CheckReserves );
17
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
17
use Koha::DateUtils qw( dt_from_string );
18
use Koha::DateUtils qw( dt_from_string );
18
use Koha::Items;
19
use Koha::Items;
19
20
Lines 206-211 sub do_checkin { Link Here
206
        $self->alert( !$return || defined $self->alert_type );
207
        $self->alert( !$return || defined $self->alert_type );
207
    }
208
    }
208
209
210
    # If item has been returned let's update the queue after transfers/holds handled above
211
    Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => [ $item->biblionumber ] } )
212
        if $return && C4::Context->preference('RealTimeHoldsQueue');
213
209
    # Set sort bin based on info in the item associated with the issue, and the
214
    # Set sort bin based on info in the item associated with the issue, and the
210
    # mapping from SIP2SortBinMapping
215
    # mapping from SIP2SortBinMapping
211
    $self->sort_bin( _get_sort_bin( $item, $branch, $account ) );
216
    $self->sort_bin( _get_sort_bin( $item, $branch, $account ) );
(-)a/Koha/Checkouts.pm (-1 / +7 lines)
Lines 21-26 use Modern::Perl; Link Here
21
21
22
use C4::Context;
22
use C4::Context;
23
use C4::Circulation qw( AddReturn );
23
use C4::Circulation qw( AddReturn );
24
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
24
use Koha::Checkout;
25
use Koha::Checkout;
25
use Koha::Database;
26
use Koha::Database;
26
use Koha::DateUtils qw( dt_from_string );
27
use Koha::DateUtils qw( dt_from_string );
Lines 84-90 sub automatic_checkin { Link Here
84
85
85
    while ( my $checkout = $due_checkouts->next ) {
86
    while ( my $checkout = $due_checkouts->next ) {
86
        if ( $checkout->item->itemtype->automatic_checkin ) {
87
        if ( $checkout->item->itemtype->automatic_checkin ) {
87
            my ( undef, $messages ) = C4::Circulation::AddReturn(
88
            my ( $returned, $messages ) = C4::Circulation::AddReturn(
88
                $checkout->item->barcode, $checkout->branchcode, undef,
89
                $checkout->item->barcode, $checkout->branchcode, undef,
89
                dt_from_string( $checkout->date_due )
90
                dt_from_string( $checkout->date_due )
90
            );
91
            );
Lines 103-108 sub automatic_checkin { Link Here
103
                    }
104
                    }
104
                }
105
                }
105
            }
106
            }
107
108
            # If item is checked in let's update the holds queue, after hold/transfers handled above
109
            Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(
110
                { biblio_ids => [ $checkout->item->biblionumber ] } )
111
                if $returned && C4::Context->preference('RealTimeHoldsQueue');
106
        }
112
        }
107
    }
113
    }
108
}
114
}
(-)a/Koha/Item.pm (-1 / +8 lines)
Lines 2307-2313 sub add_to_bundle { Link Here
2307
2307
2308
                    my $branchcode = C4::Context->userenv->{'branch'};
2308
                    my $branchcode = C4::Context->userenv->{'branch'};
2309
                    my ($success) = C4::Circulation::AddReturn( $bundle_item->barcode, $branchcode );
2309
                    my ($success) = C4::Circulation::AddReturn( $bundle_item->barcode, $branchcode );
2310
                    unless ($success) {
2310
2311
                    if ($success) {
2312
2313
                        # HoldsQueue doesn't seem to mind bundles, not sure if this is correct, but rebuild for now
2314
                        Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(
2315
                            { biblio_ids => [ $self->biblionumber ] } )
2316
                            if C4::Context->preference('RealTimeHoldsQueue');
2317
                    } else {
2311
                        Koha::Exceptions::Checkin::FailedCheckin->throw();
2318
                        Koha::Exceptions::Checkin::FailedCheckin->throw();
2312
                    }
2319
                    }
2313
                }
2320
                }
(-)a/circ/circulation.pl (+3 lines)
Lines 44-49 use Koha::Holds; Link Here
44
use C4::Context;
44
use C4::Context;
45
use CGI::Session;
45
use CGI::Session;
46
use Koha::AuthorisedValues;
46
use Koha::AuthorisedValues;
47
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
47
use Koha::Checkouts::ReturnClaims;
48
use Koha::Checkouts::ReturnClaims;
48
use Koha::CsvProfiles;
49
use Koha::CsvProfiles;
49
use Koha::Patrons;
50
use Koha::Patrons;
Lines 379-384 if ( @$barcodes && $op eq 'cud-checkout' ) { Link Here
379
            my ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower ) =
380
            my ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower ) =
380
                AddReturn( $item->barcode, C4::Context->userenv->{'branch'}, undef, undef, 1 );
381
                AddReturn( $item->barcode, C4::Context->userenv->{'branch'}, undef, undef, 1 );
381
382
383
            # No rebuild of holds queue here as the item hasn't really moved, just a stat checkout
384
382
            $template->param(
385
            $template->param(
383
                STATS     => 1,
386
                STATS     => 1,
384
                CHECKEDIN => $stats_return,
387
                CHECKEDIN => $stats_return,
(-)a/circ/returns.pl (-2 / +8 lines)
Lines 44-49 use C4::Reserves qw( ModReserve ModReserveAffect CheckReserves ); Link Here
44
use C4::RotatingCollections;
44
use C4::RotatingCollections;
45
use C4::Log qw( logaction );
45
use C4::Log qw( logaction );
46
use Koha::AuthorisedValues;
46
use Koha::AuthorisedValues;
47
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
47
use Koha::BiblioFrameworks;
48
use Koha::BiblioFrameworks;
48
use Koha::Calendar;
49
use Koha::Calendar;
49
use Koha::Checkouts;
50
use Koha::Checkouts;
Lines 387-394 if ( $barcode && ( $op eq 'cud-checkin' || $op eq 'cud-affect_reserve' ) ) { Link Here
387
    }
388
    }
388
389
389
    # do the return
390
    # do the return
390
    ( $returned, $messages, $issue, $borrower ) = AddReturn( $barcode, $userenv_branch, $exemptfine, $return_date )
391
    unless ( $needs_confirm || $bundle_confirm ) {
391
        unless ( $needs_confirm || $bundle_confirm );
392
        ( $returned, $messages, $issue, $borrower ) = AddReturn( $barcode, $userenv_branch, $exemptfine, $return_date );
393
394
        # Rebuild the queue only after handling confirmations
395
        Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => [ $item->biblionumber ] } )
396
            if $returned && C4::Context->preference('RealTimeHoldsQueue');
397
    }
392
398
393
    if ($returned) {
399
    if ($returned) {
394
        my $date_due_dt = dt_from_string( $issue->date_due, 'sql' );
400
        my $date_due_dt = dt_from_string( $issue->date_due, 'sql' );
(-)a/opac/sci/sci-main.pl (+6 lines)
Lines 22-27 use CGI qw ( -utf8 ); Link Here
22
use C4::Auth        qw( get_template_and_user );
22
use C4::Auth        qw( get_template_and_user );
23
use C4::Circulation qw( AddReturn );
23
use C4::Circulation qw( AddReturn );
24
use C4::Output      qw( output_html_with_http_headers );
24
use C4::Output      qw( output_html_with_http_headers );
25
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
25
use Koha::Items;
26
use Koha::Items;
26
27
27
use List::MoreUtils qw( uniq );
28
use List::MoreUtils qw( uniq );
Lines 86-91 if ( $op eq 'cud-check_in' ) { Link Here
86
                    checkout => $checkout,
87
                    checkout => $checkout,
87
                    patron   => $patron
88
                    patron   => $patron
88
                    };
89
                    };
90
91
                # Rebuild holds queue on checkin
92
                Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(
93
                    { biblio_ids => [ $item->biblionumber ] } )
94
                    if C4::Context->preference('RealTimeHoldsQueue');
89
            } else {
95
            } else {
90
                push @errors,
96
                push @errors,
91
                    {
97
                    {
(-)a/svc/checkin (+4 lines)
Lines 26-31 use JSON qw(to_json); Link Here
26
use C4::Circulation qw( AddReturn );
26
use C4::Circulation qw( AddReturn );
27
use C4::Context;
27
use C4::Context;
28
use C4::Auth qw(check_cookie_auth);
28
use C4::Auth qw(check_cookie_auth);
29
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
29
use Koha::Checkouts;
30
use Koha::Checkouts;
30
use Koha::Items;
31
use Koha::Items;
31
32
Lines 68-72 my $checkout = Koha::Checkouts->find( { itemnumber => $itemnumber } ); Link Here
68
$data->{patronnote} = $checkout ? $checkout->note : q||;
69
$data->{patronnote} = $checkout ? $checkout->note : q||;
69
70
70
( $data->{returned} ) = AddReturn( $barcode, $branchcode, $exempt_fine );
71
( $data->{returned} ) = AddReturn( $barcode, $branchcode, $exempt_fine );
72
# Rebuild holds queue if item returns
73
Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => [ $item->biblionumber ] } )
74
    if C4::Context->preference('RealTimeHoldsQueue');
71
75
72
print to_json($data);
76
print to_json($data);
(-)a/svc/recall (-1 lines)
Lines 24-30 use JSON qw(encode_json); Link Here
24
use C4::Context;
24
use C4::Context;
25
use C4::Auth        qw(check_cookie_auth);
25
use C4::Auth        qw(check_cookie_auth);
26
use C4::Output      qw(output_with_http_headers);
26
use C4::Output      qw(output_with_http_headers);
27
use C4::Circulation qw(AddReturn);
28
use Koha::Recalls;
27
use Koha::Recalls;
29
28
30
my $input = CGI->new;
29
my $input = CGI->new;
(-)a/tools/inventory.pl (-1 / +6 lines)
Lines 36-41 use C4::Reports::Guided qw( ); Link Here
36
use C4::Charset         qw( NormalizeString );
36
use C4::Charset         qw( NormalizeString );
37
37
38
use Koha::I18N qw(__);
38
use Koha::I18N qw(__);
39
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
39
use Koha::Biblios;
40
use Koha::Biblios;
40
use Koha::DateUtils qw( dt_from_string );
41
use Koha::DateUtils qw( dt_from_string );
41
use Koha::Database::Columns;
42
use Koha::Database::Columns;
Lines 269-274 if ( $op eq 'cud-inventory' Link Here
269
                    if ($doreturn) {
270
                    if ($doreturn) {
270
                        $item_unblessed->{onloan}       = undef;
271
                        $item_unblessed->{onloan}       = undef;
271
                        $item_unblessed->{datelastseen} = dt_from_string;
272
                        $item_unblessed->{datelastseen} = dt_from_string;
273
274
                        # Rebuild the holds queue when item found on shelf
275
                        Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(
276
                            { biblio_ids => [ $item->biblionumber ] } )
277
                            if C4::Context->preference('RealTimeHoldsQueue');
272
                    } else {
278
                    } else {
273
                        push @errorloop, { barcode => $barcode, ERR_ONLOAN_NOT_RET => 1 };
279
                        push @errorloop, { barcode => $barcode, ERR_ONLOAN_NOT_RET => 1 };
274
                    }
280
                    }
275
- 

Return to bug 34596