CVS: koha/C4/Circulation Circ2.pm,1.17,1.18
Update of /cvsroot/koha/koha/C4/Circulation In directory usw-pr-cvs1:/tmp/cvs-serv20579/C4/Circulation Modified Files: Circ2.pm Log Message: Changed the way a lost book being returned is handled. If the book has already been paid for a credit is added to their account. And offset against any current charges Index: Circ2.pm =================================================================== RCS file: /cvsroot/koha/koha/C4/Circulation/Circ2.pm,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** Circ2.pm 2001/05/02 22:38:26 1.17 --- Circ2.pm 2001/05/09 23:29:00 1.18 *************** *** 420,424 **** --- 420,465 ---- $usth->execute(); $usth->finish; + #check if any credit is left if so writeoff other accounts] my $nextaccntno = getnextacctno($env,$data->{'borrowernumber'},$dbh); + if ($amountleft < 0){ + $amountleft*=-1; + } + if ($amountleft > 0){ + # print $amountleft; + my $query = "select * from accountlines + where (borrowernumber = '$data->{'borrowernumber'}') and (amountoutstanding >0) + order by date"; + my $sth = $dbh->prepare($query); + $sth->execute; + # offset transactions + my $newamtos; + my $accdata; + while (($accdata=$sth->fetchrow_hashref) and ($amountleft>0)){ + if ($accdata->{'amountoutstanding'} < $amountleft) { + $newamtos = 0; + $amountleft = $amountleft - $accdata->{'amountoutstanding'}; + } else { + $newamtos = $accdata->{'amountoutstanding'} - $amountleft; + $amountleft = 0; + } + my $thisacct = $accdata->{accountno}; + my $updquery = "update accountlines set amountoutstanding= '$newamtos' + where (borrowernumber = '$data->{'borrowernumber'}') and (accountno='$thisacct')"; + my $usth = $dbh->prepare($updquery); + $usth->execute; + $usth->finish; + $updquery = "insert into accountoffsets + (borrowernumber, accountno, offsetaccount, offsetamount) + values + ($data->{'borrowernumber'},$accdata->{'accountno'},$nextaccntno,$newamtos)"; + my $usth = $dbh->prepare($updquery); + $usth->execute; + $usth->finish; + } + } + if ($amountleft > 0){ + $amountleft*=-1; + } + $sth->finish; my $desc="Book Returned ".$iteminformation->{'barcode'}; $uquery = "insert into accountlines *************** *** 463,467 **** my ($env,$patroninformation,$dbh) = @_; my $amount = checkaccount($env,$patroninformation->{'borrowernumber'}, $dbh); ! if ($amount>0) { my %flaginfo; $flaginfo{'message'}=sprintf "Patron owes \$%.02f", $amount; --- 504,508 ---- my ($env,$patroninformation,$dbh) = @_; my $amount = checkaccount($env,$patroninformation->{'borrowernumber'}, $dbh); ! if ($amount > 0) { my %flaginfo; $flaginfo{'message'}=sprintf "Patron owes \$%.02f", $amount; *************** *** 470,473 **** --- 511,519 ---- } $flags{'CHARGES'}=\%flaginfo; + } elsif ($amount < 0){ + my %flaginfo; + $amount=$amount*-1; + $flaginfo{'message'}=sprintf "Patron has credit of \$%.02f", $amount; + $flags{'CHARGES'}=\%flaginfo; } if ($patroninformation->{'gonenoaddress'} == 1) {
participants (1)
-
Chris Cormack