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

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

Return to bug 13324