View | Details | Raw Unified | Return to bug 13324
Collapse All | Expand All

(-)a/C4/Budgets.pm (-10 / +11 lines)
Lines 216-222 sub GetBudgetsPlanCell { Link Here
216
        # get the actual amount
216
        # get the actual amount
217
        $sth = $dbh->prepare( qq|
217
        $sth = $dbh->prepare( qq|
218
218
219
            SELECT SUM(ecost) AS actual FROM aqorders
219
            SELECT SUM(ecost_tax_included) AS actual FROM aqorders
220
                WHERE    budget_id = ? AND
220
                WHERE    budget_id = ? AND
221
                entrydate like "$cell->{'authvalue'}%"  |
221
                entrydate like "$cell->{'authvalue'}%"  |
222
        );
222
        );
Lines 225-231 sub GetBudgetsPlanCell { Link Here
225
        # get the actual amount
225
        # get the actual amount
226
        $sth = $dbh->prepare( qq|
226
        $sth = $dbh->prepare( qq|
227
227
228
            SELECT SUM(ecost) FROM aqorders
228
            SELECT SUM(ecost_tax_included) FROM aqorders
229
                LEFT JOIN aqorders_items
229
                LEFT JOIN aqorders_items
230
                ON (aqorders.ordernumber = aqorders_items.ordernumber)
230
                ON (aqorders.ordernumber = aqorders_items.ordernumber)
231
                LEFT JOIN items
231
                LEFT JOIN items
Lines 237-243 sub GetBudgetsPlanCell { Link Here
237
        # get the actual amount
237
        # get the actual amount
238
        $sth = $dbh->prepare(  qq|
238
        $sth = $dbh->prepare(  qq|
239
239
240
            SELECT SUM( ecost *  quantity) AS actual
240
            SELECT SUM( ecost_tax_included *  quantity) AS actual
241
                FROM aqorders JOIN biblioitems
241
                FROM aqorders JOIN biblioitems
242
                ON (biblioitems.biblionumber = aqorders.biblionumber )
242
                ON (biblioitems.biblionumber = aqorders.biblionumber )
243
                WHERE aqorders.budget_id = ? and itemtype  = ? |
243
                WHERE aqorders.budget_id = ? and itemtype  = ? |
Lines 250-256 sub GetBudgetsPlanCell { Link Here
250
        # get the actual amount
250
        # get the actual amount
251
        $sth = $dbh->prepare( qq|
251
        $sth = $dbh->prepare( qq|
252
252
253
        SELECT  SUM(ecost * quantity) AS actual
253
        SELECT  SUM(ecost_tax_included * quantity) AS actual
254
            FROM aqorders
254
            FROM aqorders
255
            JOIN aqbudgets ON (aqbudgets.budget_id = aqorders.budget_id )
255
            JOIN aqbudgets ON (aqbudgets.budget_id = aqorders.budget_id )
256
            WHERE  aqorders.budget_id = ? AND
256
            WHERE  aqorders.budget_id = ? AND
Lines 329-338 sub ModBudgetPlan { Link Here
329
329
330
# -------------------------------------------------------------------
330
# -------------------------------------------------------------------
331
sub GetBudgetSpent {
331
sub GetBudgetSpent {
332
	my ($budget_id) = @_;
332
    my ($budget_id) = @_;
333
	my $dbh = C4::Context->dbh;
333
    my $dbh = C4::Context->dbh;
334
	my $sth = $dbh->prepare(qq|
334
    # unitprice_tax_included should always been set here
335
        SELECT SUM( COALESCE(unitprice, ecost) * quantity ) AS sum FROM aqorders
335
    # we should not need to retrieve ecost_tax_included
336
    my $sth = $dbh->prepare(qq|
337
        SELECT SUM( COALESCE(unitprice_tax_included, ecost_tax_included) * quantity ) AS sum FROM aqorders
336
            WHERE budget_id = ? AND
338
            WHERE budget_id = ? AND
337
            quantityreceived > 0 AND
339
            quantityreceived > 0 AND
338
            datecancellationprinted IS NULL
340
            datecancellationprinted IS NULL
Lines 358-364 sub GetBudgetOrdered { Link Here
358
	my ($budget_id) = @_;
360
	my ($budget_id) = @_;
359
	my $dbh = C4::Context->dbh;
361
	my $dbh = C4::Context->dbh;
360
	my $sth = $dbh->prepare(qq|
362
	my $sth = $dbh->prepare(qq|
361
        SELECT SUM(ecost *  quantity) AS sum FROM aqorders
363
        SELECT SUM(ecost_tax_included *  quantity) AS sum FROM aqorders
362
            WHERE budget_id = ? AND
364
            WHERE budget_id = ? AND
363
            quantityreceived = 0 AND
365
            quantityreceived = 0 AND
364
            datecancellationprinted IS NULL
366
            datecancellationprinted IS NULL
365
- 

Return to bug 13324