BUG FIXING :

Signed-off-by: Chris Cormack <crc@liblime.com>
This commit is contained in:
Henri-Damien LAURENT 2007-09-12 16:00:01 +02:00 committed by Chris Cormack
parent e0c6540912
commit f8db0248f5
1 changed files with 6 additions and 6 deletions

View File

@ -228,21 +228,21 @@ sub GetBookFundBreakdown {
quantityreceived,subscription
FROM aqorders
LEFT JOIN aqorderbreakdown ON aqorders.ordernumber=aqorderbreakdown.ordernumber
WHERE bookfundid=?
LEFT JOIN aqbookfund ON (aqorderbreakdown.bookfundid=aqbookfund.bookfundid and aqorderbreakdown.branchcode=aqbookfund.branchcode)
LEFT JOIN aqbudget ON (aqbudget.bookfundid=aqbookfund.bookfundid and aqbudget.branchcode=aqbudget.branchcode)
WHERE aqorderbreakdown.bookfundid=?
AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00')
AND ((datereceived >= ? and datereceived < ?) OR (budgetdate >= ? and budgetdate < ?))
AND ((budgetdate >= ? and budgetdate < ?) OR (startdate>=? and enddate<=?))
";
my $sth = $dbh->prepare($query);
$sth->execute( $id, $start, $end, $start, $end );
my $spent = 0;
my ($spent) = 0;
while ( my $data = $sth->fetchrow_hashref ) {
if ( $data->{'subscription'} == 1 ) {
$spent += $data->{'quantity'} * $data->{'unitprice'};
}
else {
my $leftover = $data->{'quantity'} - ($data->{'quantityreceived'}?$data->{'quantityreceived'}:0);
$spent += ( $data->{'unitprice'} ) * ($data->{'quantityreceived'}?$data->{'quantityreceived'}:0);
}
@ -274,7 +274,7 @@ sub GetBookFundBreakdown {
while ( my $data = $sth->fetchrow_hashref ) {
my $left = $data->{'tleft'};
if ( !$left || $left eq '' ) {
if ( (!$left && (!$data->{'datereceived'}||$data->{'datereceived'} eq '0000-00-00') ) || $left eq '' ) {
$left = $data->{'quantity'};
}
if ( $left && $left > 0 ) {