@@ -, +, @@ there is no charge for the new hold. --- C4/Reserves.pm | 100 +++++++++++--------------------------------------------- 1 file changed, 19 insertions(+), 81 deletions(-) --- a/C4/Reserves.pm +++ a/C4/Reserves.pm @@ -156,9 +156,6 @@ sub AddReserve { $bibitems, $priority, $resdate, $expdate, $notes, $title, $checkitem, $found ) = @_; - my $fee = - GetReserveFee($borrowernumber, $biblionumber, - $bibitems ); my $dbh = C4::Context->dbh; $resdate = format_date_in_iso( $resdate ) if ( $resdate ); $resdate = C4::Dates->today( 'iso' ) unless ( $resdate ); @@ -178,9 +175,9 @@ sub AddReserve { $waitingdate = $resdate; } - #eval { # updates take place here - if ( $fee > 0 ) { + my $fee = GetReserveFee( $borrowernumber ); + if ( $fee ) { my $nextacctno = &getnextacctno( $borrowernumber ); my $query = qq{ INSERT INTO accountlines @@ -652,91 +649,32 @@ sub GetOtherReserves { =head2 GetReserveFee - $fee = GetReserveFee($borrowernumber,$biblionumber,$biblionumber); + $fee = GetReserveFee( $borrowernumber ); -Calculate the fee for a reserve + Calculate the fee for a reserve. Returns undef if no fee is found. + + NOTE: This code is simplified on bug 14702. The old checks were unneeded + and erroneous. This routine is called at the moment of adding a reserve, + we just need to pass the hold fee. =cut sub GetReserveFee { - my ($borrowernumber, $biblionumber, $bibitems ) = @_; - - #check for issues; - my $dbh = C4::Context->dbh; + my ( $borrowernumber ) = @_; + my $dbh = C4::Context->dbh; my $query = qq{ - SELECT * FROM borrowers - LEFT JOIN categories ON borrowers.categorycode = categories.categorycode - WHERE borrowernumber = ? +SELECT reservefee +FROM borrowers +LEFT JOIN categories ON borrowers.categorycode = categories.categorycode +WHERE borrowernumber = ? }; - my $sth = $dbh->prepare($query); - $sth->execute($borrowernumber); + my $sth = $dbh->prepare( $query ); + $sth->execute( $borrowernumber ); my $data = $sth->fetchrow_hashref; - my $fee = $data->{'reservefee'}; - my $cntitems = @- > $bibitems; - - if ( $fee > 0 ) { - - # check for items on issue - # first find biblioitem records - my @biblioitems; - my $sth1 = $dbh->prepare( - "SELECT * FROM biblio LEFT JOIN biblioitems on biblio.biblionumber = biblioitems.biblionumber - WHERE (biblio.biblionumber = ?)" - ); - $sth1->execute($biblionumber); - while ( my $data1 = $sth1->fetchrow_hashref ) { - my $found = 0; - my $x = 0; - while ( $x < $cntitems ) { - if ( @$bibitems->{'biblioitemnumber'} == - $data->{'biblioitemnumber'} ) - { - $found = 1; - } - $x++; - } - - if ( $found == 0 ) { - push @biblioitems, $data1; - } - } - my $cntitemsfound = @biblioitems; - my $issues = 0; - my $x = 0; - my $allissued = 1; - while ( $x < $cntitemsfound ) { - my $bitdata = $biblioitems[$x]; - my $sth2 = $dbh->prepare( - "SELECT * FROM items - WHERE biblioitemnumber = ?" - ); - $sth2->execute( $bitdata->{'biblioitemnumber'} ); - while ( my $itdata = $sth2->fetchrow_hashref ) { - my $sth3 = $dbh->prepare( - "SELECT * FROM issues - WHERE itemnumber = ?" - ); - $sth3->execute( $itdata->{'itemnumber'} ); - if ( my $isdata = $sth3->fetchrow_hashref ) { - } - else { - $allissued = 0; - } - } - $x++; - } - if ( $allissued == 0 ) { - my $rsth = - $dbh->prepare("SELECT * FROM reserves WHERE biblionumber = ?"); - $rsth->execute($biblionumber); - if ( my $rdata = $rsth->fetchrow_hashref ) { - } - else { - $fee = 0; - } - } + if( $data && $data->{'reservefee'} > 0 ) { + return $data->{'reservefee'}; } - return $fee; + return; } =head2 GetReservesToBranch --