From: Nahuel ANGELINETTI Date: Thu, 8 Oct 2009 11:29:59 +0000 (+0200) Subject: (bug #3348) still fixing funds and budget table X-Git-Tag: v3.00.04_final~32 X-Git-Url: http://git.rot13.org/?p=koha.git;a=commitdiff_plain;h=65938adb1f95d120196f094e7e4dc2f70b1bc838 (bug #3348) still fixing funds and budget table This fix the sql request to be the same result as in spent.pl --- diff --git a/C4/Bookfund.pm b/C4/Bookfund.pm index 6a7c9ee68c..ada1e496f1 100644 --- a/C4/Bookfund.pm +++ b/C4/Bookfund.pm @@ -222,20 +222,23 @@ sub GetBookFundBreakdown { # do a query for spent totals. my $query = " - SELECT quantity,datereceived,freight,unitprice,listprice,ecost, - quantityreceived,subscription, closedate - FROM aqorders - LEFT JOIN aqbasket USING (basketno) - LEFT JOIN aqorderbreakdown ON aqorders.ordernumber=aqorderbreakdown.ordernumber - LEFT JOIN aqbookfund ON (aqorderbreakdown.bookfundid=aqbookfund.bookfundid and aqorderbreakdown.branchcode=aqbookfund.branchcode) - LEFT JOIN aqbudget ON (aqbudget.bookfundid=aqbookfund.bookfundid and aqbudget.branchcode=aqbookfund.branchcode) - WHERE aqorderbreakdown.bookfundid=? - AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00') - AND ((budgetdate >= ? and budgetdate < ?) OR (startdate>=? and enddate<=?)) - AND (closedate >= ? AND closedate <= ?) + Select distinct quantity,datereceived,freight,unitprice,listprice,ecost,quantityreceived + as qrev,subscription,title,itype as itemtype,aqorders.biblionumber,aqorders.booksellerinvoicenumber, + quantity-quantityreceived as tleft, + aqorders.ordernumber + as ordnum,entrydate,budgetdate,aqbasket.booksellerid,aqbasket.basketno + from aqorders + inner join aqorderbreakdown on aqorderbreakdown.ordernumber = aqorders.ordernumber + inner join aqbasket on aqbasket.basketno = aqorders.basketno + left join items on items.biblionumber=aqorders.biblionumber + where bookfundid=? + and (datereceived >= ? and datereceived < ?) + and (datecancellationprinted is NULL or + datecancellationprinted='0000-00-00') + and (closedate >= ? and closedate < ?) "; my $sth = $dbh->prepare($query); - $sth->execute( $id, $start, $end, $start, $end, $start, $end ); + $sth->execute( $id, $start, $end, $start, $end); my ($spent) = 0; while ( my $data = $sth->fetchrow_hashref ) { @@ -244,8 +247,7 @@ sub GetBookFundBreakdown { $spent += $data->{'quantity'} * $data->{'unitprice'}; } else { - $spent += ( $data->{'unitprice'} ) * ($data->{'quantityreceived'}?$data->{'quantityreceived'}:0); - + $spent += ( $data->{'unitprice'} ) * ($data->{'qrev'}?$data->{'qrev'}:0); } }