Update of /cvsroot/koha/koha/C4/Circulation In directory usw-pr-cvs1:/tmp/cvs-serv9030/C4/Circulation Modified Files: Circ2.pm Log Message: Fixed the code that adds a credit or wipes a lost book charge from a borrowers account if said book is returned Index: Circ2.pm =================================================================== RCS file: /cvsroot/koha/koha/C4/Circulation/Circ2.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** Circ2.pm 2001/04/03 21:32:37 1.15 --- Circ2.pm 2001/05/02 21:15:22 1.16 *************** *** 206,210 **** } my $amount = checkaccount($env,$patroninformation->{'borrowernumber'}, $dbh,$date); ! if ($amount>5) { $rejected=sprintf "Patron owes \$%.02f.", $amount; last SWITCH; --- 206,214 ---- } my $amount = checkaccount($env,$patroninformation->{'borrowernumber'}, $dbh,$date); ! if ($amount>5 && $patroninformation->{'categorycode'} ne 'L' && ! $patroninformation->{'categorycode'} ne 'W' && ! $patroninformation->{'categorycode'} ne 'I' ! && $patroninformation->{'categorycode'} ne 'B' && ! $patroninformation->{'categorycode'} ne 'P') { $rejected=sprintf "Patron owes \$%.02f.", $amount; last SWITCH; *************** *** 341,344 **** --- 345,355 ---- } + sub updateitemlost{ + my ($dbh,$itemno)=@_; + my $query="update items set itemlost=0 where itemnumber=$itemno"; + my $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + } sub returnbook { *************** *** 353,356 **** --- 364,368 ---- my ($currentborrower) = currentborrower($env, $iteminformation->{'itemnumber'}, $dbh); updatelastseen($env,$dbh,$iteminformation->{'itemnumber'}); + updateitemlost($dbh,$iteminformation->{'itemnumber'}); if ($currentborrower) { ($borrower)=getpatroninformation($env,$currentborrower,0); *************** *** 376,381 **** } $sth->finish; # check for charge made for lost book ! $sth=$dbh->prepare("select * from accountlines where (borrowernumber=$borrower->{'borrowernumber'}) and (itemnumber = $iteminformation->{'itemnumber'}) and (accounttype='L')"); $sth->execute; if (my $data = $sth->fetchrow_hashref) { --- 388,399 ---- } $sth->finish; + } + if ($iteminformation->{'itemlost'} eq '1'){ # check for charge made for lost book ! my $query="select * from accountlines where (itemnumber = ! $iteminformation->{'itemnumber'}) and (accounttype='L' or accounttype='Rep') ! order by date desc"; ! # print $query; ! $sth=$dbh->prepare($query); $sth->execute; if (my $data = $sth->fetchrow_hashref) { *************** *** 385,388 **** --- 403,407 ---- my $acctno = $data->{'accountno'}; my $amountleft; + # print $amount; if ($data->{'amountoutstanding'} == $amount) { $offset = $data->{'amount'}; *************** *** 394,409 **** my $uquery = "update accountlines set accounttype = 'LR',amountoutstanding='0' ! where (borrowernumber = $borrower->{'borrowernumber'}) and (itemnumber = $iteminformation->{'itemnumber'}) and (accountno = '$acctno') "; my $usth = $dbh->prepare($uquery); $usth->execute(); $usth->finish; ! my $nextaccntno = C4::Accounts::getnextacctno($env,$borrower->{'borrowernumber'},$dbh); $uquery = "insert into accountlines (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding) ! values ($borrower->{'borrowernumber'},$nextaccntno,now(),0-$amount,'Book Returned', 'CR',$amountleft)"; $usth = $dbh->prepare($uquery); $usth->execute; $usth->finish; --- 413,431 ---- my $uquery = "update accountlines set accounttype = 'LR',amountoutstanding='0' ! where (borrowernumber = $data->{'borrowernumber'}) and (itemnumber = $iteminformation->{'itemnumber'}) and (accountno = '$acctno') "; + # print $uquery; my $usth = $dbh->prepare($uquery); $usth->execute(); $usth->finish; ! my $nextaccntno = getnextacctno($env,$data->{'borrowernumber'},$dbh); ! my $desc="Book Returned ".$iteminformation->{'barcode'}; $uquery = "insert into accountlines (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding) ! values ($data->{'borrowernumber'},$nextaccntno,now(),0-$amount,'$desc', 'CR',$amountleft)"; $usth = $dbh->prepare($uquery); + # print $uquery; $usth->execute; $usth->finish; *************** *** 414,420 **** $usth->execute; $usth->finish; } $sth->finish; ! } my ($resfound,$resrec) = find_reserves($env, $dbh, $iteminformation->{'itemnumber'}); if ($resfound eq 'y') { --- 436,446 ---- $usth->execute; $usth->finish; + $uquery="update items set itemnotes='' where itemnumber=$iteminformation->{'itemnumber'}"; + $usth = $dbh->prepare($uquery); + $usth->execute; + $usth->finish; } $sth->finish; ! } my ($resfound,$resrec) = find_reserves($env, $dbh, $iteminformation->{'itemnumber'}); if ($resfound eq 'y') { *************** *** 600,604 **** } my $select="select * from issues,items,biblioitems,biblio where ! borrowernumber=$borrowernumber and issues.itemnumber=items.itemnumber and items.biblionumber=biblio.biblionumber and items.biblioitemnumber=biblioitems.biblioitemnumber and returndate is null --- 626,630 ---- } my $select="select * from issues,items,biblioitems,biblio where ! borrowernumber='$borrowernumber' and issues.itemnumber=items.itemnumber and items.biblionumber=biblio.biblionumber and items.biblioitemnumber=biblioitems.biblioitemnumber and returndate is null