From 65938adb1f95d120196f094e7e4dc2f70b1bc838 Mon Sep 17 00:00:00 2001 From: Nahuel ANGELINETTI Date: Thu, 8 Oct 2009 13:29:59 +0200 Subject: [PATCH] (bug #3348) still fixing funds and budget table This fix the sql request to be the same result as in spent.pl --- C4/Bookfund.pm | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) 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); } } -- 2.39.5