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

(-)a/C4/Circulation.pm (-4 / +3 lines)
Lines 2079-2089 sub AddReturn { Link Here
2079
    ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->itemnumber, undef, $lookahead ) unless ( $item->withdrawn );
2079
    ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->itemnumber, undef, $lookahead ) unless ( $item->withdrawn );
2080
    # 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)
2080
    # 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)
2081
    if ( $resfound eq "Waiting" and $branch ne $resrec->{branchcode} ) {
2081
    if ( $resfound eq "Waiting" and $branch ne $resrec->{branchcode} ) {
2082
        C4::Reserves::RevertWaitingStatus( { itemnumber => $item->itemnumber } );
2082
        my $hold = C4::Reserves::RevertWaitingStatus( { itemnumber => $item->itemnumber } );
2083
        #If the hold is reverted we need to refetch for the return values
2083
        $resfound = 'Reserved';
2084
        ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->itemnumber, undef, $lookahead ) unless ( $item->withdrawn );
2084
        $resrec = $hold->unblessed;
2085
    }
2085
    }
2086
    ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->itemnumber, undef, $lookahead ) unless ( $item->withdrawn );
2087
    if ($resfound) {
2086
    if ($resfound) {
2088
          $resrec->{'ResFound'} = $resfound;
2087
          $resrec->{'ResFound'} = $resfound;
2089
        $messages->{'ResFound'} = $resrec;
2088
        $messages->{'ResFound'} = $resrec;
(-)a/C4/Reserves.pm (-16 / +10 lines)
Lines 1966-1989 sub RevertWaitingStatus { Link Here
1966
    $sth = $dbh->prepare( $query );
1966
    $sth = $dbh->prepare( $query );
1967
    $sth->execute( $reserve->{'biblionumber'} );
1967
    $sth->execute( $reserve->{'biblionumber'} );
1968
1968
1969
    ## Fix up the currently waiting reserve
1969
    $hold->set(
1970
    $query = "
1970
        {
1971
    UPDATE reserves
1971
            priority    => 1,
1972
    SET
1972
            found       => undef,
1973
      priority = 1,
1973
            waitingdate => undef,
1974
      found = NULL,
1974
            itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
1975
      waitingdate = NULL
1975
        }
1976
    WHERE
1976
    )->store();
1977
      reserve_id = ?
1978
    ";
1979
    $sth = $dbh->prepare( $query );
1980
    $sth->execute( $reserve->{'reserve_id'} );
1981
1982
    unless ( $hold->item_level_hold ) {
1983
        $hold->itemnumber(undef)->store;
1984
    }
1985
1977
1986
    _FixPriority( { biblionumber => $reserve->{biblionumber} } );
1978
    _FixPriority( { biblionumber => $reserve->{biblionumber} } );
1979
1980
    return $hold;
1987
}
1981
}
1988
1982
1989
=head2 ReserveSlip
1983
=head2 ReserveSlip
(-)a/t/db_dependent/Circulation.t (-3 / +3 lines)
Lines 2846-2852 subtest '_FixAccountForLostAndReturned returns undef if patron is deleted' => su Link Here
2846
};
2846
};
2847
2847
2848
subtest 'Set waiting flag' => sub {
2848
subtest 'Set waiting flag' => sub {
2849
    plan tests => 9;
2849
    plan tests => 11;
2850
2850
2851
    my $library_1 = $builder->build( { source => 'Branch' } );
2851
    my $library_1 = $builder->build( { source => 'Branch' } );
2852
    my $patron_1  = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } );
2852
    my $patron_1  = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } );
Lines 2890-2899 subtest 'Set waiting flag' => sub { Link Here
2890
    $hold = Koha::Holds->find( $reserve_id );
2890
    $hold = Koha::Holds->find( $reserve_id );
2891
    is( $hold->found, undef, 'Hold is no longer marked waiting' );
2891
    is( $hold->found, undef, 'Hold is no longer marked waiting' );
2892
    is( $hold->priority, 1,  "Hold is now priority one again");
2892
    is( $hold->priority, 1,  "Hold is now priority one again");
2893
    is( $hold->waitingdate, undef, "Hold no longer has a waiting date");
2894
    is( $hold->itemnumber, $item->{itemnumber}, "Hold has retained its' itemnumber");
2893
    is( $messages->{ResFound}->{ResFound}, "Reserved", "Hold is still returned");
2895
    is( $messages->{ResFound}->{ResFound}, "Reserved", "Hold is still returned");
2894
    is( $messages->{ResFound}->{found}, undef, "Hold is no longer marked found in return message");
2896
    is( $messages->{ResFound}->{found}, undef, "Hold is no longer marked found in return message");
2895
    is( $messages->{ResFound}->{priority}, 1, "Hold is priority 1 in return message");
2897
    is( $messages->{ResFound}->{priority}, 1, "Hold is priority 1 in return message");
2896
2897
};
2898
};
2898
2899
2899
subtest 'Cancel transfers on lost items' => sub {
2900
subtest 'Cancel transfers on lost items' => sub {
2900
- 

Return to bug 21944