Bug Fixes
This commit is contained in:
parent
ea7bcf8891
commit
4b4afda024
4 changed files with 54 additions and 28 deletions
|
@ -83,19 +83,26 @@ sub CalcFine {
|
|||
my $data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
my $amount=0;
|
||||
if ($difference >= $data->{'firstremind'}){
|
||||
if ($data->{'chargeperiod'} != 0){
|
||||
my $temp=$difference % $data->{'chargeperiod'};
|
||||
$difference=$difference - $temp;
|
||||
$amount=($difference / $data->{'chargeperiod'}) * $data->{'fine'};
|
||||
}
|
||||
my $printout;
|
||||
if ($difference == $data->{'firstremind'}){
|
||||
$amount=$data->{'fine'};
|
||||
$printout="First Notice";
|
||||
}
|
||||
my $second=$data->{'firstremind'}+$data->{'chargeperiod'};
|
||||
if ($difference == $second){
|
||||
$amount=$data->{'fine'}*2;
|
||||
$printout="Second Notice";
|
||||
}
|
||||
if ($difference == $data->{'accountsent'}){
|
||||
$amount=5;
|
||||
$printout="Final Notice";
|
||||
}
|
||||
$dbh->disconnect;
|
||||
return($amount,$data->{'chargename'});
|
||||
return($amount,$data->{'chargename'},$printout);
|
||||
}
|
||||
|
||||
sub UpdateFine {
|
||||
my ($itemnum,$bornum,$amount,$type)=@_;
|
||||
my ($itemnum,$bornum,$amount,$type,$due)=@_;
|
||||
my $dbh=C4Connect;
|
||||
my $query="Select * from accountlines where itemnumber=$itemnum and
|
||||
borrowernumber=$bornum and (accounttype='FU' or accounttype='O' or
|
||||
|
@ -105,10 +112,10 @@ sub UpdateFine {
|
|||
$sth->execute;
|
||||
|
||||
if (my $data=$sth->fetchrow_hashref){
|
||||
print "in accounts ...";
|
||||
# print "in accounts ...";
|
||||
if ($data->{'amount'} != $amount){
|
||||
|
||||
print "updating";
|
||||
# print "updating";
|
||||
my $diff=$amount - $data->{'amount'};
|
||||
my $out=$data->{'amountoutstanding'}+$diff;
|
||||
my $query2="update accountlines set date=now(), amount=$amount,
|
||||
|
@ -119,7 +126,7 @@ sub UpdateFine {
|
|||
$sth2->execute;
|
||||
$sth2->finish;
|
||||
} else {
|
||||
print "no update needed $data->{'amount'}"
|
||||
# print "no update needed $data->{'amount'}"
|
||||
}
|
||||
} else {
|
||||
my $query2="select title from biblio,items where items.itemnumber=$itemnum
|
||||
|
@ -128,7 +135,7 @@ sub UpdateFine {
|
|||
$sth4->execute;
|
||||
my $title=$sth4->fetchrow_hashref;
|
||||
$sth4->finish;
|
||||
print "not in account";
|
||||
# print "not in account";
|
||||
my $query2="Select max(accountno) from accountlines";
|
||||
my $sth3=$dbh->prepare($query2);
|
||||
$sth3->execute;
|
||||
|
@ -139,7 +146,7 @@ sub UpdateFine {
|
|||
$query2="Insert into accountlines
|
||||
(borrowernumber,itemnumber,date,amount,
|
||||
description,accounttype,amountoutstanding,accountno) values
|
||||
($bornum,$itemnum,now(),$amount,'$type $title->{'title'}','FU',
|
||||
($bornum,$itemnum,now(),$amount,'$type $title->{'title'} $due','FU',
|
||||
$amount,$accountno[0])";
|
||||
my $sth2=$dbh->prepare($query2);
|
||||
$sth2->execute;
|
||||
|
|
10
C4/Stats.pm
10
C4/Stats.pm
|
@ -169,15 +169,19 @@ sub TotalPaid {
|
|||
sub getcharges{
|
||||
my($borrowerno,$timestamp)=@_;
|
||||
my $dbh=C4Connect;
|
||||
my $timestamp2=$timestamp-1;
|
||||
my $query="Select * from accountlines where borrowernumber=$borrowerno
|
||||
and timestamp => $timestamp and accounttype <> 'Pay'";
|
||||
and timestamp < '$timestamp' and accounttype <> 'Pay'";
|
||||
my $sth=$dbh->prepare($query);
|
||||
# print $query,"<br>";
|
||||
$sth->execute;
|
||||
my $i=0;
|
||||
my @results;
|
||||
while (my $data=$sth->fetchrow_hashref){
|
||||
$results[$i]=$data;
|
||||
$i++;
|
||||
if ($data->{'timestamp'} == $timestamp){
|
||||
$results[$i]=$data;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$dbh->disconnect;
|
||||
return(@results);
|
||||
|
|
15
fines.pl
15
fines.pl
|
@ -13,14 +13,15 @@ my $count2=0;
|
|||
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
|
||||
$mon++;
|
||||
$year=$year+1900;
|
||||
#my $date=Date_DaysSince999($mon,$mday,$year);
|
||||
my $date=Date_DaysSince999(1,19,2000);
|
||||
my $date=Date_DaysSince999($mon,$mday,$year);
|
||||
#my $date=Date_DaysSince999(1,23,2000);
|
||||
my $bornum;
|
||||
my $borrower;
|
||||
my $max=5;
|
||||
for (my $i=0;$i<$count;$i++){
|
||||
my @dates=split('-',$data->[$i]->{'date_due'});
|
||||
my $date2=Date_DaysSince999($dates[1],$dates[2],$dates[0]);
|
||||
my $due="$dates[2]/$dates[1]/$dates[0]";
|
||||
if ($date2 <= $date){
|
||||
$count2++;
|
||||
my $difference=$date-$date2;
|
||||
|
@ -30,13 +31,17 @@ for (my $i=0;$i<$count;$i++){
|
|||
}
|
||||
|
||||
|
||||
my ($amount,$type)=CalcFine($data->[$i]->{'itemnumber'},$borrower->{'categorycode'},$difference);
|
||||
my ($amount,$type,$printout)=CalcFine($data->[$i]->{'itemnumber'},$borrower->{'categorycode'},$difference);
|
||||
if ($amount > $max){
|
||||
$amount=$max;
|
||||
}
|
||||
if ($amount > 0){
|
||||
UpdateFine($data->[$i]->{'itemnumber'},$bornum,$amount,$type);
|
||||
print "$borrower->{'firstname'} $borrower->{'surname'} $data->[$i]->{'date_due'} $type $difference\n";
|
||||
UpdateFine($data->[$i]->{'itemnumber'},$bornum,$amount,$type,$due);
|
||||
if ($amount ==5){
|
||||
# marklost();
|
||||
}
|
||||
|
||||
print "$printout\t$bornum\t$borrower->{'firstname'}\t$borrower->{'surname'}\t$data->[$i]->{'date_due'}\t$type\t$difference\t$borrower->{'emailaddress'}\t$borrower->{'phone'}\t$borrower->{'streetaddress'}\t$borrower->{'city'}\n";
|
||||
} else {
|
||||
# print "0 fine\n";
|
||||
}
|
||||
|
|
24
stats.pl
24
stats.pl
|
@ -22,14 +22,17 @@ if ($time eq 'today'){
|
|||
$date=ParseDate('today');
|
||||
$date2=ParseDate('tomorrow');
|
||||
}
|
||||
|
||||
if ($time eq 'daybefore'){
|
||||
$date=ParseDate('2 days ago');
|
||||
$date2=ParseDate('yesterday');
|
||||
}
|
||||
$date=UnixDate($date,'%Y-%m-%d');
|
||||
$date2=UnixDate($date2,'%Y-%m-%d');
|
||||
my @payments=TotalPaid($date);
|
||||
my $count=@payments;
|
||||
my $total=0;
|
||||
print mktablehdr;
|
||||
print mktablerow(5,'white','Name','Type','Date/time','Amount');
|
||||
print mktablerow(5,'white','Name','Type','Date/time','Amount', 'Branch');
|
||||
for (my $i=0;$i<$count;$i++){
|
||||
my $hour=substr($payments[$i]{'timestamp'},8,2);
|
||||
my $min=substr($payments[$i]{'timestamp'},10,2);
|
||||
|
@ -37,10 +40,17 @@ for (my $i=0;$i<$count;$i++){
|
|||
my $time="$hour:$min:$sec";
|
||||
$payments[$i]{'amount'}*=-1;
|
||||
$total+=$payments[$i]{'amount'};
|
||||
print mktablerow(5,'white',"$payments[$i]{'firstname'} <b>$payments[$i]{'surname'}</b>"
|
||||
,$payments[$i]{'accounttype'},"$payments[$i]{'date'} $time",$payments[$i]{'amount'},
|
||||
$payments[$i]{'itemnumber'});
|
||||
my @charges=getcharges($payments[$i]{'borrowernumber'},$payments[$i]{'timestamp'});
|
||||
my $count=@charges;
|
||||
for (my $i2=0;$i2<$count;$i2++){
|
||||
print mktablerow(6,'red',$charges[$i2]->{'description'},$charges[$i2]->{'accounttype'},
|
||||
'',
|
||||
$charges[$i2]->{'amount'},$charges[$i2]->{'amountoutstanding'});
|
||||
}
|
||||
|
||||
print mktablerow(6,'white',"$payments[$i]{'firstname'} <b>$payments[$i]{'surname'}</b>"
|
||||
,$payments[$i]{'accounttype'},"$payments[$i]{'date'} $time",$payments[$i]{'amount'}
|
||||
,$payments[$i]{'branchcode'});
|
||||
}
|
||||
print mktableft;
|
||||
|
||||
|
@ -55,6 +65,6 @@ print "<br>Issues Shannon: $issues";
|
|||
my $returns=Count('return','C',$date,$date2);
|
||||
print "<p>Returns Levin: $returns";
|
||||
$returns=Count('return','F',$date,$date2);
|
||||
print "<p>Returns Foxton: $returns";
|
||||
print "<br>Returns Foxton: $returns";
|
||||
$returns=Count('return','S',$date,$date2);
|
||||
print "<p>Returns Shannon: $returns";
|
||||
print "<br>Returns Shannon: $returns";
|
||||
|
|
Loading…
Reference in a new issue