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 1987-2010 sub RevertWaitingStatus { Link Here
1987
    $sth = $dbh->prepare( $query );
1987
    $sth = $dbh->prepare( $query );
1988
    $sth->execute( $reserve->{'biblionumber'} );
1988
    $sth->execute( $reserve->{'biblionumber'} );
1989
1989
1990
    ## Fix up the currently waiting reserve
1990
    $hold->set(
1991
    $query = "
1991
        {
1992
    UPDATE reserves
1992
            priority    => 1,
1993
    SET
1993
            found       => undef,
1994
      priority = 1,
1994
            waitingdate => undef,
1995
      found = NULL,
1995
            itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
1996
      waitingdate = NULL
1996
        }
1997
    WHERE
1997
    )->store();
1998
      reserve_id = ?
1999
    ";
2000
    $sth = $dbh->prepare( $query );
2001
    $sth->execute( $reserve->{'reserve_id'} );
2002
2003
    unless ( $hold->item_level_hold ) {
2004
        $hold->itemnumber(undef)->store;
2005
    }
2006
1998
2007
    _FixPriority( { biblionumber => $reserve->{biblionumber} } );
1999
    _FixPriority( { biblionumber => $reserve->{biblionumber} } );
2000
2001
    return $hold;
2008
}
2002
}
2009
2003
2010
=head2 ReserveSlip
2004
=head2 ReserveSlip
(-)a/t/db_dependent/Circulation.t (-3 / +3 lines)
Lines 2909-2915 subtest '_FixAccountForLostAndFound returns undef if patron is deleted' => sub { Link Here
2909
};
2909
};
2910
2910
2911
subtest 'Set waiting flag' => sub {
2911
subtest 'Set waiting flag' => sub {
2912
    plan tests => 9;
2912
    plan tests => 11;
2913
2913
2914
    my $library_1 = $builder->build( { source => 'Branch' } );
2914
    my $library_1 = $builder->build( { source => 'Branch' } );
2915
    my $patron_1  = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } );
2915
    my $patron_1  = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } );
Lines 2958-2967 subtest 'Set waiting flag' => sub { Link Here
2958
    $hold = Koha::Holds->find( $reserve_id );
2958
    $hold = Koha::Holds->find( $reserve_id );
2959
    is( $hold->found, undef, 'Hold is no longer marked waiting' );
2959
    is( $hold->found, undef, 'Hold is no longer marked waiting' );
2960
    is( $hold->priority, 1,  "Hold is now priority one again");
2960
    is( $hold->priority, 1,  "Hold is now priority one again");
2961
    is( $hold->waitingdate, undef, "Hold no longer has a waiting date");
2962
    is( $hold->itemnumber, $item->{itemnumber}, "Hold has retained its' itemnumber");
2961
    is( $messages->{ResFound}->{ResFound}, "Reserved", "Hold is still returned");
2963
    is( $messages->{ResFound}->{ResFound}, "Reserved", "Hold is still returned");
2962
    is( $messages->{ResFound}->{found}, undef, "Hold is no longer marked found in return message");
2964
    is( $messages->{ResFound}->{found}, undef, "Hold is no longer marked found in return message");
2963
    is( $messages->{ResFound}->{priority}, 1, "Hold is priority 1 in return message");
2965
    is( $messages->{ResFound}->{priority}, 1, "Hold is priority 1 in return message");
2964
2965
};
2966
};
2966
2967
2967
subtest 'Cancel transfers on lost items' => sub {
2968
subtest 'Cancel transfers on lost items' => sub {
2968
- 

Return to bug 21944