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

(-)a/C4/Budgets.pm (-3 / +14 lines)
Lines 210-215 sub GetBudgetsPlanCell { Link Here
210
    my ($actual, $sth);
210
    my ($actual, $sth);
211
    my $dbh = C4::Context->dbh;
211
    my $dbh = C4::Context->dbh;
212
    my $roundsql = _get_rounding_sql(qq|ecost_tax_included|);
212
    my $roundsql = _get_rounding_sql(qq|ecost_tax_included|);
213
        print STDERR "C4/Budgets.pm 1\n";
213
    if ( $cell->{'authcat'} eq 'MONTHS' ) {
214
    if ( $cell->{'authcat'} eq 'MONTHS' ) {
214
        # get the actual amount
215
        # get the actual amount
215
        # FIXME we should consider quantity
216
        # FIXME we should consider quantity
Lines 219-224 sub GetBudgetsPlanCell { Link Here
219
                WHERE    budget_id = ? AND
220
                WHERE    budget_id = ? AND
220
                entrydate like "$cell->{'authvalue'}%"  |
221
                entrydate like "$cell->{'authvalue'}%"  |
221
        );
222
        );
223
        print STDERR "C4/Budgets.pm 2\n";
222
        $sth->execute( $cell->{'budget_id'} );
224
        $sth->execute( $cell->{'budget_id'} );
223
    } elsif ( $cell->{'authcat'} eq 'BRANCHES' ) {
225
    } elsif ( $cell->{'authcat'} eq 'BRANCHES' ) {
224
        # get the actual amount
226
        # get the actual amount
Lines 231-236 sub GetBudgetsPlanCell { Link Here
231
                LEFT JOIN items
233
                LEFT JOIN items
232
                ON (aqorders_items.itemnumber = items.itemnumber)
234
                ON (aqorders_items.itemnumber = items.itemnumber)
233
                WHERE budget_id = ? AND homebranch = ? |          );
235
                WHERE budget_id = ? AND homebranch = ? |          );
236
        print STDERR "C4/Budgets.pm 3\n";
234
237
235
        $sth->execute( $cell->{'budget_id'}, $cell->{'authvalue'} );
238
        $sth->execute( $cell->{'budget_id'}, $cell->{'authvalue'} );
236
    } elsif ( $cell->{'authcat'} eq 'ITEMTYPES' ) {
239
    } elsif ( $cell->{'authcat'} eq 'ITEMTYPES' ) {
Lines 242-247 sub GetBudgetsPlanCell { Link Here
242
                ON (biblioitems.biblionumber = aqorders.biblionumber )
245
                ON (biblioitems.biblionumber = aqorders.biblionumber )
243
                WHERE aqorders.budget_id = ? and itemtype  = ? |
246
                WHERE aqorders.budget_id = ? and itemtype  = ? |
244
        );
247
        );
248
        print STDERR "C4/Budgets.pm 4\n";
245
        $sth->execute(  $cell->{'budget_id'},
249
        $sth->execute(  $cell->{'budget_id'},
246
                        $cell->{'authvalue'} );
250
                        $cell->{'authvalue'} );
247
    }
251
    }
Lines 257-268 sub GetBudgetsPlanCell { Link Here
257
                ((aqbudgets.sort1_authcat = ? AND sort1 =?) OR
261
                ((aqbudgets.sort1_authcat = ? AND sort1 =?) OR
258
                (aqbudgets.sort2_authcat = ? AND sort2 =?))    |
262
                (aqbudgets.sort2_authcat = ? AND sort2 =?))    |
259
        );
263
        );
264
        print STDERR "C4/Budgets.pm 5\n";
260
        $sth->execute(  $cell->{'budget_id'},
265
        $sth->execute(  $cell->{'budget_id'},
261
                        $budget->{'sort1_authcat'},
266
                        $budget->{'sort1_authcat'},
262
                        $cell->{'authvalue'},
267
                        $cell->{'authvalue'},
263
                        $budget->{'sort2_authcat'},
268
                        $budget->{'sort2_authcat'},
264
                        $cell->{'authvalue'}
269
                        $cell->{'authvalue'}
265
        );
270
        );
271
        print STDERR "USING ",$cell->{'budget_id'},"--",$budget->{'sort1_authcat'},"--",$cell->{'authvalue'},"--",$budget->{'sort2_authcat'},"--",$cell->{'authvalue'},"\n";
266
    }
272
    }
267
    $actual = $sth->fetchrow_array;
273
    $actual = $sth->fetchrow_array;
268
274
Lines 339-344 sub GetBudgetSpent { Link Here
339
            quantityreceived > 0 AND
345
            quantityreceived > 0 AND
340
            datecancellationprinted IS NULL
346
            datecancellationprinted IS NULL
341
    |);
347
    |);
348
        print STDERR "C4/Budgets.pm 6\n";
342
	$sth->execute($budget_id);
349
	$sth->execute($budget_id);
343
	my $sum =  $sth->fetchrow_array;
350
	my $sum =  $sth->fetchrow_array;
344
351
Lines 365-370 sub GetBudgetOrdered { Link Here
365
            quantityreceived = 0 AND
372
            quantityreceived = 0 AND
366
            datecancellationprinted IS NULL
373
            datecancellationprinted IS NULL
367
    |);
374
    |);
375
        print STDERR "C4/Budgets.pm 7\n";
368
	$sth->execute($budget_id);
376
	$sth->execute($budget_id);
369
	my $sum =  $sth->fetchrow_array;
377
	my $sum =  $sth->fetchrow_array;
370
378
Lines 1294-1301 returns the correct SQL routine based on OrderPriceRounding system preference. Link Here
1294
sub _get_rounding_sql {
1302
sub _get_rounding_sql {
1295
    my $to_round = shift;
1303
    my $to_round = shift;
1296
    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
1304
    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
1297
    if   ($rounding_pref eq 'nearest_cent') { return "CAST($to_round*100 AS INTEGER)/100"; }
1305
    if   ($rounding_pref eq 'nearest_cent') {
1298
    else { return "$to_round"; }
1306
        print STDERR "C4/Budgets.pm 8\n";
1307
        return "CAST(($to_round*100) AS INTEGER)/100"; }
1308
    else {
1309
        print STDERR "C4/Budgets.pm 9\n";
1310
        return "$to_round"; }
1299
}
1311
}
1300
1312
1301
END { }    # module clean-up code here (global destructor)
1313
END { }    # module clean-up code here (global destructor)
1302
- 

Return to bug 18736