Lines 309-318
sub GetBudgetSpent {
Link Here
|
309 |
my ($budget_id) = @_; |
309 |
my ($budget_id) = @_; |
310 |
my $dbh = C4::Context->dbh; |
310 |
my $dbh = C4::Context->dbh; |
311 |
my $sth = $dbh->prepare(qq| |
311 |
my $sth = $dbh->prepare(qq| |
312 |
SELECT SUM( COALESCE(unitprice, ecost) * quantity ) AS sum FROM aqorders |
312 |
SELECT SUM(( COALESCE(unitprice, ecost) +COALESCE(unitprice, ecost)*IF(invoiceincgst=0,COALESCE(aqorders.gstrate,0),0) )* quantityreceived ) AS sum FROM aqorders |
313 |
WHERE budget_id = ? AND |
313 |
LEFT JOIN aqbasket ON (aqorders.basketno = aqbasket.basketno) |
314 |
quantityreceived > 0 AND |
314 |
LEFT JOIN aqbooksellers ON(aqbasket.booksellerid=aqbooksellers.id) |
315 |
datecancellationprinted IS NULL |
315 |
WHERE budget_id = ? AND quantityreceived > 0 AND datecancellationprinted IS NULL |
316 |
|); |
316 |
|); |
317 |
$sth->execute($budget_id); |
317 |
$sth->execute($budget_id); |
318 |
my $sum = $sth->fetchrow_array; |
318 |
my $sum = $sth->fetchrow_array; |
Lines 335-344
sub GetBudgetOrdered {
Link Here
|
335 |
my ($budget_id) = @_; |
335 |
my ($budget_id) = @_; |
336 |
my $dbh = C4::Context->dbh; |
336 |
my $dbh = C4::Context->dbh; |
337 |
my $sth = $dbh->prepare(qq| |
337 |
my $sth = $dbh->prepare(qq| |
338 |
SELECT SUM(ecost * quantity) AS sum FROM aqorders |
338 |
SELECT SUM((ecost+ecost*IF(listincgst=0,COALESCE(aqorders.gstrate,0),0) ) * (quantity-quantityreceived)) AS sum FROM aqorders |
339 |
WHERE budget_id = ? AND |
339 |
LEFT JOIN aqbasket ON (aqorders.basketno = aqbasket.basketno) |
340 |
quantityreceived = 0 AND |
340 |
LEFT JOIN aqbooksellers ON(aqbasket.booksellerid=aqbooksellers.id) |
341 |
datecancellationprinted IS NULL |
341 |
WHERE budget_id = ? AND datecancellationprinted IS NULL |
342 |
|); |
342 |
|); |
343 |
$sth->execute($budget_id); |
343 |
$sth->execute($budget_id); |
344 |
my $sum = $sth->fetchrow_array; |
344 |
my $sum = $sth->fetchrow_array; |
345 |
- |
|
|