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

(-)a/C4/Budgets.pm (-8 / +8 lines)
Lines 352-358 sub GetBudgetSpent { Link Here
352
            quantityreceived > 0 AND
352
            quantityreceived > 0 AND
353
            datecancellationprinted IS NULL
353
            datecancellationprinted IS NULL
354
    |);
354
    |);
355
	$sth->execute($budget_id);
355
    $sth->execute($budget_id);
356
    my $sum = ( $sth->fetchrow_array || 0 ) + 0;
356
    my $sum = ( $sth->fetchrow_array || 0 ) + 0;
357
357
358
    $sth = $dbh->prepare(qq|
358
    $sth = $dbh->prepare(qq|
Lines 370-393 sub GetBudgetSpent { Link Here
370
        $sum += $adj->adjustment;
370
        $sum += $adj->adjustment;
371
    }
371
    }
372
372
373
	return $sum;
373
    return $sum;
374
}
374
}
375
375
376
# -------------------------------------------------------------------
376
# -------------------------------------------------------------------
377
sub GetBudgetOrdered {
377
sub GetBudgetOrdered {
378
	my ($budget_id) = @_;
378
    my ($budget_id) = @_;
379
	my $dbh = C4::Context->dbh;
379
    my $dbh = C4::Context->dbh;
380
380
381
    # Get correct unitprice and ecost prices as possible
381
    # Get correct unitprice and ecost prices as possible
382
    my ( $unitprice_field, $ecost_field ) = FieldsForCalculatingFundValues();
382
    my ( $unitprice_field, $ecost_field ) = FieldsForCalculatingFundValues();
383
383
384
	my $sth = $dbh->prepare(qq|
384
    my $sth = $dbh->prepare(qq|
385
        SELECT SUM(| . C4::Acquisition::get_rounding_sql(qq|$ecost_field|) . qq| *  quantity) AS sum FROM aqorders
385
        SELECT SUM(| . C4::Acquisition::get_rounding_sql(qq|$ecost_field|) . qq| *  quantity) AS sum FROM aqorders
386
            WHERE budget_id = ? AND
386
            WHERE budget_id = ? AND
387
            quantityreceived = 0 AND
387
            quantityreceived = 0 AND
388
            datecancellationprinted IS NULL
388
            datecancellationprinted IS NULL
389
    |);
389
    |);
390
	$sth->execute($budget_id);
390
    $sth->execute($budget_id);
391
    my $sum =  ( $sth->fetchrow_array || 0 ) + 0;
391
    my $sum =  ( $sth->fetchrow_array || 0 ) + 0;
392
392
393
    my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $budget_id, encumber_open => 1, closedate => undef},{ join => 'invoiceid' });
393
    my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $budget_id, encumber_open => 1, closedate => undef},{ join => 'invoiceid' });
Lines 395-401 sub GetBudgetOrdered { Link Here
395
        $sum += $adj->adjustment;
395
        $sum += $adj->adjustment;
396
    }
396
    }
397
397
398
	return $sum;
398
    return $sum;
399
}
399
}
400
400
401
=head2 GetBudgetName
401
=head2 GetBudgetName
Lines 1414-1420 sub MoveOrders { Link Here
1414
1414
1415
    my ( $unitprice_field, $ecost_field ) = FieldsForCalculatingFundValues();
1415
    my ( $unitprice_field, $ecost_field ) = FieldsForCalculatingFundValues();
1416
1416
1417
Fetch the tax inclusive or tax exclusive database fields for caclulating fund values based
1417
Fetch the tax inclusive or tax exclusive database fields for calculating fund values based
1418
on the value of the CalculateFundValuesIncludingTax system preference.
1418
on the value of the CalculateFundValuesIncludingTax system preference.
1419
1419
1420
=cut
1420
=cut
(-)a/acqui/spent.pl (-1 / +1 lines)
Lines 21-27 Link Here
21
21
22
=head1 NAME
22
=head1 NAME
23
23
24
 spent.pl
24
 acqui/spent.pl
25
25
26
=head1 DESCRIPTION
26
=head1 DESCRIPTION
27
27
(-)a/t/db_dependent/Budgets.t (-4 / +3 lines)
Lines 1221-1227 subtest 'FieldsForCalculatingFundValues with a vendor NOT including tax in their Link Here
1221
    t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '1');
1221
    t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '1');
1222
    my ( $unitprice_field, $ecost_field ) = C4::Budgets->FieldsForCalculatingFundValues();
1222
    my ( $unitprice_field, $ecost_field ) = C4::Budgets->FieldsForCalculatingFundValues();
1223
    is ( $unitprice_field, 'unitprice_tax_included', "We expect this to be unitprice_tax_included" );
1223
    is ( $unitprice_field, 'unitprice_tax_included', "We expect this to be unitprice_tax_included" );
1224
    is ( $ecost_field, 'ecost_tax_included', "We expect this to be ecost_tax_included" ); 
1224
    is ( $ecost_field, 'ecost_tax_included', "We expect this to be ecost_tax_included" );
1225
    t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '0');
1225
    t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '0');
1226
    ( $unitprice_field, $ecost_field ) = C4::Budgets->FieldsForCalculatingFundValues();
1226
    ( $unitprice_field, $ecost_field ) = C4::Budgets->FieldsForCalculatingFundValues();
1227
    is ( $unitprice_field, 'unitprice_tax_excluded', "We expect this to be unitprice_tax_excluded" );
1227
    is ( $unitprice_field, 'unitprice_tax_excluded', "We expect this to be unitprice_tax_excluded" );
Lines 1229-1235 subtest 'FieldsForCalculatingFundValues with a vendor NOT including tax in their Link Here
1229
1229
1230
    # Test GetBudgetOrdered()
1230
    # Test GetBudgetOrdered()
1231
    # -----------------------
1231
    # -----------------------
1232
    
1232
1233
    # Build an order
1233
    # Build an order
1234
    t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent');
1234
    t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent');
1235
    my $item_1        = $builder->build_sample_item;
1235
    my $item_1        = $builder->build_sample_item;
Lines 1325-1331 subtest 'FieldsForCalculatingFundValues with a vendor that IS including tax in t Link Here
1325
    t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '1');
1325
    t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '1');
1326
    my ( $unitprice_field, $ecost_field ) = C4::Budgets->FieldsForCalculatingFundValues();
1326
    my ( $unitprice_field, $ecost_field ) = C4::Budgets->FieldsForCalculatingFundValues();
1327
    is ( $unitprice_field, 'unitprice_tax_included', "We expect this to be unitprice_tax_included" );
1327
    is ( $unitprice_field, 'unitprice_tax_included', "We expect this to be unitprice_tax_included" );
1328
    is ( $ecost_field, 'ecost_tax_included', "We expect this to be ecost_tax_included" ); 
1328
    is ( $ecost_field, 'ecost_tax_included', "We expect this to be ecost_tax_included" );
1329
    t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '0');
1329
    t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '0');
1330
    ( $unitprice_field, $ecost_field ) = C4::Budgets->FieldsForCalculatingFundValues();
1330
    ( $unitprice_field, $ecost_field ) = C4::Budgets->FieldsForCalculatingFundValues();
1331
    is ( $unitprice_field, 'unitprice_tax_excluded', "We expect this to be unitprice_tax_excluded" );
1331
    is ( $unitprice_field, 'unitprice_tax_excluded', "We expect this to be unitprice_tax_excluded" );
1332
- 

Return to bug 31631