|
Lines 560-573
sub GetBudgetHierarchy {
Link Here
|
| 560 |
# Get all the budgets totals in as few queries as possible |
560 |
# Get all the budgets totals in as few queries as possible |
| 561 |
my $hr_budget_spent = $dbh->selectall_hashref(q| |
561 |
my $hr_budget_spent = $dbh->selectall_hashref(q| |
| 562 |
SELECT aqorders.budget_id, aqbudgets.budget_parent_id, |
562 |
SELECT aqorders.budget_id, aqbudgets.budget_parent_id, |
| 563 |
SUM( COALESCE(unitprice_tax_included, ecost_tax_included) * quantity ) AS budget_spent |
563 |
SUM( | . _get_rounding_sql(qq|COALESCE(unitprice_tax_included, ecost_tax_included)|) . q| * quantity ) AS budget_spent |
| 564 |
FROM aqorders JOIN aqbudgets USING (budget_id) |
564 |
FROM aqorders JOIN aqbudgets USING (budget_id) |
| 565 |
WHERE quantityreceived > 0 AND datecancellationprinted IS NULL |
565 |
WHERE quantityreceived > 0 AND datecancellationprinted IS NULL |
| 566 |
GROUP BY budget_id |
566 |
GROUP BY budget_id |
| 567 |
|, 'budget_id'); |
567 |
|, 'budget_id'); |
| 568 |
my $hr_budget_ordered = $dbh->selectall_hashref(q| |
568 |
my $hr_budget_ordered = $dbh->selectall_hashref(q| |
| 569 |
SELECT aqorders.budget_id, aqbudgets.budget_parent_id, |
569 |
SELECT aqorders.budget_id, aqbudgets.budget_parent_id, |
| 570 |
SUM(ecost_tax_included * quantity) AS budget_ordered |
570 |
SUM( | . _get_rounding_sql(qq|ecost_tax_included|) . q| * quantity) AS budget_ordered |
| 571 |
FROM aqorders JOIN aqbudgets USING (budget_id) |
571 |
FROM aqorders JOIN aqbudgets USING (budget_id) |
| 572 |
WHERE quantityreceived = 0 AND datecancellationprinted IS NULL |
572 |
WHERE quantityreceived = 0 AND datecancellationprinted IS NULL |
| 573 |
GROUP BY budget_id |
573 |
GROUP BY budget_id |