From 41d7e8a44cd15a462f4de891720ae9b866eab45c Mon Sep 17 00:00:00 2001 From: szrj1m Date: Thu, 18 Aug 2005 21:15:20 +0000 Subject: [PATCH] UpdateStats is now being passed $accountno. --- C4/Accounts2.pm | 91 +++++++++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 40 deletions(-) diff --git a/C4/Accounts2.pm b/C4/Accounts2.pm index bb2a1ccae8..3efec3234d 100755 --- a/C4/Accounts2.pm +++ b/C4/Accounts2.pm @@ -28,8 +28,8 @@ use C4::Circulation::Circ2; use vars qw($VERSION @ISA @EXPORT); # set the version for version checking -$VERSION = 0.01; # FIXME - Should probably be different from - # the version for C4::Accounts +$VERSION = 0.01; # FIXME - Should probably be different from + # the version for C4::Accounts =head1 NAME @@ -80,10 +80,12 @@ will be credited to the next one. sub recordpayment{ #here we update both the accountoffsets and the account lines my ($env,$bornumber,$data)=@_; + warn "in accounts2.pm"; my $dbh = C4::Context->dbh; my $newamtos = 0; my $accdata = ""; my $branch=$env->{'branchcode'}; + warn $branch; my $amountleft = $data; # begin transaction my $nextaccntno = getnextacctno($env,$bornumber,$dbh); @@ -96,10 +98,10 @@ sub recordpayment{ while (($accdata=$sth->fetchrow_hashref) and ($amountleft>0)){ if ($accdata->{'amountoutstanding'} < $amountleft) { $newamtos = 0; - $amountleft -= $accdata->{'amountoutstanding'}; + $amountleft -= $accdata->{'amountoutstanding'}; } else { $newamtos = $accdata->{'amountoutstanding'} - $amountleft; - $amountleft = 0; + $amountleft = 0; } my $thisacct = $accdata->{accountno}; my $usth = $dbh->prepare("update accountlines set amountoutstanding= ? @@ -143,11 +145,12 @@ sub makepayment{ #here we update both the accountoffsets and the account lines #updated to check, if they are paying off a lost item, we return the item # from their card, and put a note on the item record - my ($bornumber,$accountno,$amount,$user)=@_; - my $env; + my ($bornumber,$accountno,$amount,$user,$branch)=@_; + my %env; + $env{'branchcode'}=$branch; my $dbh = C4::Context->dbh; # begin transaction - my $nextaccntno = getnextacctno($env,$bornumber,$dbh); + my $nextaccntno = getnextacctno(\%env,$bornumber,$dbh); my $newamtos=0; my $sth=$dbh->prepare("Select * from accountlines where borrowernumber=? and accountno=?"); $sth->execute($bornumber,$accountno); @@ -155,33 +158,34 @@ sub makepayment{ $sth->finish; $dbh->do(<do(<do(<finish; #check to see what accounttype if ($data->{'accounttype'} eq 'Rep' || $data->{'accounttype'} eq 'L'){ @@ -231,17 +235,17 @@ sub fixaccounts { and accountno=?"); $sth->execute($borrowernumber,$accountno); my $data=$sth->fetchrow_hashref; - # FIXME - Error-checking + # FIXME - Error-checking my $diff=$amount-$data->{'amount'}; my $outstanding=$data->{'amountoutstanding'}+$diff; $sth->finish; $dbh->do(<prepare("Select * from items where barcode='$itemnum'"); +# $sth->execute; +# my $data=$sth->fetchrow_hashref; +# $sth->finish; $desc.=" ".$itemnum; - my $sth=$dbh->prepare("INSERT INTO accountlines - (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber) - VALUES (?, ?, now(), ?,?, ?,?,?)"); + my $sth=$dbh->prepare("INSERT INTO accountlines + (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber) + VALUES (?, ?, now(), ?,?, ?,?,?)"); # $sth->execute($bornum, $accountno, $amount, $desc, $type, $amountleft, $data->{'itemnumber'}); $sth->execute($bornum, $accountno, $amount, $desc, $type, $amountleft, $itemnum); } else { - my $sth=$dbh->prepare("INSERT INTO accountlines - (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding) - VALUES (?, ?, now(), ?, ?, ?, ?)"); + $desc=$dbh->quote($desc); + my $sth=$dbh->prepare("INSERT INTO accountlines + (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding) + VALUES (?, ?, now(), ?, ?, ?, ?)"); $sth->execute($bornum, $accountno, $amount, $desc, $type, $amountleft); } } @@ -347,10 +357,10 @@ sub fixcredit{ $sth->finish; if ($accdata->{'amountoutstanding'} < $amountleft) { $newamtos = 0; - $amountleft -= $accdata->{'amountoutstanding'}; + $amountleft -= $accdata->{'amountoutstanding'}; } else { $newamtos = $accdata->{'amountoutstanding'} - $amountleft; - $amountleft = 0; + $amountleft = 0; } my $thisacct = $accdata->{accountno}; my $usth = $dbh->prepare("update accountlines set amountoutstanding= ? @@ -375,10 +385,10 @@ sub fixcredit{ while (($accdata=$sth->fetchrow_hashref) and ($amountleft>0)){ if ($accdata->{'amountoutstanding'} < $amountleft) { $newamtos = 0; - $amountleft -= $accdata->{'amountoutstanding'}; + $amountleft -= $accdata->{'amountoutstanding'}; } else { $newamtos = $accdata->{'amountoutstanding'} - $amountleft; - $amountleft = 0; + $amountleft = 0; } my $thisacct = $accdata->{accountno}; my $usth = $dbh->prepare("update accountlines set amountoutstanding= ? @@ -422,10 +432,10 @@ sub refund{ while (($accdata=$sth->fetchrow_hashref) and ($amountleft<0)){ if ($accdata->{'amountoutstanding'} > $amountleft) { $newamtos = 0; - $amountleft -= $accdata->{'amountoutstanding'}; + $amountleft -= $accdata->{'amountoutstanding'}; } else { $newamtos = $accdata->{'amountoutstanding'} - $amountleft; - $amountleft = 0; + $amountleft = 0; } # print $amountleft; my $thisacct = $accdata->{accountno}; @@ -455,3 +465,4 @@ __END__ DBI(3) =cut + -- 2.39.5