@@ -, +, @@ values --- C4/Budgets.pm | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) --- a/C4/Budgets.pm +++ a/C4/Budgets.pm @@ -216,7 +216,7 @@ sub GetBudgetsPlanCell { # get the actual amount $sth = $dbh->prepare( qq| - SELECT SUM(ecost) AS actual FROM aqorders + SELECT SUM(ecost_tax_included) AS actual FROM aqorders WHERE budget_id = ? AND entrydate like "$cell->{'authvalue'}%" | ); @@ -225,7 +225,7 @@ sub GetBudgetsPlanCell { # get the actual amount $sth = $dbh->prepare( qq| - SELECT SUM(ecost) FROM aqorders + SELECT SUM(ecost_tax_included) FROM aqorders LEFT JOIN aqorders_items ON (aqorders.ordernumber = aqorders_items.ordernumber) LEFT JOIN items @@ -237,7 +237,7 @@ sub GetBudgetsPlanCell { # get the actual amount $sth = $dbh->prepare( qq| - SELECT SUM( ecost * quantity) AS actual + SELECT SUM( ecost_tax_included * quantity) AS actual FROM aqorders JOIN biblioitems ON (biblioitems.biblionumber = aqorders.biblionumber ) WHERE aqorders.budget_id = ? and itemtype = ? | @@ -250,7 +250,7 @@ sub GetBudgetsPlanCell { # get the actual amount $sth = $dbh->prepare( qq| - SELECT SUM(ecost * quantity) AS actual + SELECT SUM(ecost_tax_included * quantity) AS actual FROM aqorders JOIN aqbudgets ON (aqbudgets.budget_id = aqorders.budget_id ) WHERE aqorders.budget_id = ? AND @@ -329,10 +329,12 @@ sub ModBudgetPlan { # ------------------------------------------------------------------- sub GetBudgetSpent { - my ($budget_id) = @_; - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare(qq| - SELECT SUM( COALESCE(unitprice, ecost) * quantity ) AS sum FROM aqorders + my ($budget_id) = @_; + my $dbh = C4::Context->dbh; + # unitprice_tax_included should always been set here + # we should not need to retrieve ecost_tax_included + my $sth = $dbh->prepare(qq| + SELECT SUM( COALESCE(unitprice_tax_included, ecost_tax_included) * quantity ) AS sum FROM aqorders WHERE budget_id = ? AND quantityreceived > 0 AND datecancellationprinted IS NULL @@ -358,7 +360,7 @@ sub GetBudgetOrdered { my ($budget_id) = @_; my $dbh = C4::Context->dbh; my $sth = $dbh->prepare(qq| - SELECT SUM(ecost * quantity) AS sum FROM aqorders + SELECT SUM(ecost_tax_included * quantity) AS sum FROM aqorders WHERE budget_id = ? AND quantityreceived = 0 AND datecancellationprinted IS NULL --