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

(-)a/C4/Circulation.pm (-4 / +3 lines)
Lines 2065-2075 sub AddReturn { Link Here
2065
    ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->itemnumber, undef, $lookahead ) unless ( $item->withdrawn );
2065
    ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->itemnumber, undef, $lookahead ) unless ( $item->withdrawn );
2066
    # if a hold is found and is waiting at another branch, change the priority back to 1 and trigger the hold (this will trigger a transfer and update the hold status properly)
2066
    # if a hold is found and is waiting at another branch, change the priority back to 1 and trigger the hold (this will trigger a transfer and update the hold status properly)
2067
    if ( $resfound eq "Waiting" and $branch ne $resrec->{branchcode} ) {
2067
    if ( $resfound eq "Waiting" and $branch ne $resrec->{branchcode} ) {
2068
        C4::Reserves::RevertWaitingStatus( { itemnumber => $item->itemnumber } );
2068
        my $hold = C4::Reserves::RevertWaitingStatus( { itemnumber => $item->itemnumber } );
2069
        #If the hold is reverted we need to refetch for the return values
2069
        $resfound = 'Reserved';
2070
        ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->itemnumber, undef, $lookahead ) unless ( $item->withdrawn );
2070
        $resrec = $hold->unblessed;
2071
    }
2071
    }
2072
    ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->itemnumber, undef, $lookahead ) unless ( $item->withdrawn );
2073
    if ($resfound) {
2072
    if ($resfound) {
2074
          $resrec->{'ResFound'} = $resfound;
2073
          $resrec->{'ResFound'} = $resfound;
2075
        $messages->{'ResFound'} = $resrec;
2074
        $messages->{'ResFound'} = $resrec;
(-)a/C4/Reserves.pm (-16 / +10 lines)
Lines 1940-1963 sub RevertWaitingStatus { Link Here
1940
    $sth = $dbh->prepare( $query );
1940
    $sth = $dbh->prepare( $query );
1941
    $sth->execute( $reserve->{'biblionumber'} );
1941
    $sth->execute( $reserve->{'biblionumber'} );
1942
1942
1943
    ## Fix up the currently waiting reserve
1943
    $hold->set(
1944
    $query = "
1944
        {
1945
    UPDATE reserves
1945
            priority    => 1,
1946
    SET
1946
            found       => undef,
1947
      priority = 1,
1947
            waitingdate => undef,
1948
      found = NULL,
1948
            itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
1949
      waitingdate = NULL
1949
        }
1950
    WHERE
1950
    )->store();
1951
      reserve_id = ?
1952
    ";
1953
    $sth = $dbh->prepare( $query );
1954
    $sth->execute( $reserve->{'reserve_id'} );
1955
1956
    unless ( $hold->item_level_hold ) {
1957
        $hold->itemnumber(undef)->store;
1958
    }
1959
1951
1960
    _FixPriority( { biblionumber => $reserve->{biblionumber} } );
1952
    _FixPriority( { biblionumber => $reserve->{biblionumber} } );
1953
1954
    return $hold;
1961
}
1955
}
1962
1956
1963
=head2 ReserveSlip
1957
=head2 ReserveSlip
(-)a/t/db_dependent/Circulation.t (-3 / +3 lines)
Lines 2595-2601 subtest '_FixAccountForLostAndReturned returns undef if patron is deleted' => su Link Here
2595
};
2595
};
2596
2596
2597
subtest 'Set waiting flag' => sub {
2597
subtest 'Set waiting flag' => sub {
2598
    plan tests => 9;
2598
    plan tests => 11;
2599
2599
2600
    my $library_1 = $builder->build( { source => 'Branch' } );
2600
    my $library_1 = $builder->build( { source => 'Branch' } );
2601
    my $patron_1  = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } );
2601
    my $patron_1  = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } );
Lines 2639-2648 subtest 'Set waiting flag' => sub { Link Here
2639
    $hold = Koha::Holds->find( $reserve_id );
2639
    $hold = Koha::Holds->find( $reserve_id );
2640
    is( $hold->found, undef, 'Hold is no longer marked waiting' );
2640
    is( $hold->found, undef, 'Hold is no longer marked waiting' );
2641
    is( $hold->priority, 1,  "Hold is now priority one again");
2641
    is( $hold->priority, 1,  "Hold is now priority one again");
2642
    is( $hold->waitingdate, undef, "Hold no longer has a waiting date");
2643
    is( $hold->itemnumber, $item->{itemnumber}, "Hold has retained its' itemnumber");
2642
    is( $messages->{ResFound}->{ResFound}, "Reserved", "Hold is still returned");
2644
    is( $messages->{ResFound}->{ResFound}, "Reserved", "Hold is still returned");
2643
    is( $messages->{ResFound}->{found}, undef, "Hold is no longer marked found in return message");
2645
    is( $messages->{ResFound}->{found}, undef, "Hold is no longer marked found in return message");
2644
    is( $messages->{ResFound}->{priority}, 1, "Hold is priority 1 in return message");
2646
    is( $messages->{ResFound}->{priority}, 1, "Hold is priority 1 in return message");
2645
2646
};
2647
};
2647
2648
2648
subtest 'Cancel transfers on lost items' => sub {
2649
subtest 'Cancel transfers on lost items' => sub {
2649
- 

Return to bug 21944