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

(-)a/C4/Acquisition.pm (-1 / +1 lines)
Lines 2036-2042 returns a price rounded as specified in OrderPriceRounding system preference. Link Here
2036
sub get_rounded_price {
2036
sub get_rounded_price {
2037
    my ( $price ) =  @_;
2037
    my ( $price ) =  @_;
2038
    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
2038
    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
2039
    if( $rounding_pref eq 'nearest_cent' ) { return Koha::Number::Price->new( $price )->format(); }
2039
    if( $rounding_pref eq 'nearest_cent' ) { return Koha::Number::Price->new( $price )->round(); }
2040
    else                                   { return $price; }
2040
    else                                   { return $price; }
2041
}
2041
}
2042
2042
(-)a/C4/Budgets.pm (-2 / +2 lines)
Lines 560-573 sub GetBudgetHierarchy { Link Here
560
    # Get all the budgets totals in as few queries as possible
560
    # Get all the budgets totals in as few queries as possible
561
    my $hr_budget_spent = $dbh->selectall_hashref(q|
561
    my $hr_budget_spent = $dbh->selectall_hashref(q|
562
        SELECT aqorders.budget_id, aqbudgets.budget_parent_id,
562
        SELECT aqorders.budget_id, aqbudgets.budget_parent_id,
563
               SUM( COALESCE(unitprice_tax_included, ecost_tax_included) * quantity ) AS budget_spent
563
               SUM( | . _get_rounding_sql(qq|COALESCE(unitprice_tax_included, ecost_tax_included)|) . q| * quantity ) AS budget_spent
564
        FROM aqorders JOIN aqbudgets USING (budget_id)
564
        FROM aqorders JOIN aqbudgets USING (budget_id)
565
        WHERE quantityreceived > 0 AND datecancellationprinted IS NULL
565
        WHERE quantityreceived > 0 AND datecancellationprinted IS NULL
566
        GROUP BY budget_id
566
        GROUP BY budget_id
567
        |, 'budget_id');
567
        |, 'budget_id');
568
    my $hr_budget_ordered = $dbh->selectall_hashref(q|
568
    my $hr_budget_ordered = $dbh->selectall_hashref(q|
569
        SELECT aqorders.budget_id, aqbudgets.budget_parent_id,
569
        SELECT aqorders.budget_id, aqbudgets.budget_parent_id,
570
               SUM(ecost_tax_included *  quantity) AS budget_ordered
570
               SUM( | . _get_rounding_sql(qq|ecost_tax_included|) . q| *  quantity) AS budget_ordered
571
        FROM aqorders JOIN aqbudgets USING (budget_id)
571
        FROM aqorders JOIN aqbudgets USING (budget_id)
572
        WHERE quantityreceived = 0 AND datecancellationprinted IS NULL
572
        WHERE quantityreceived = 0 AND datecancellationprinted IS NULL
573
        GROUP BY budget_id
573
        GROUP BY budget_id
(-)a/Koha/Number/Price.pm (-1 / +6 lines)
Lines 19-25 package Koha::Number::Price; Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Number::Format qw( format_price );
22
use Number::Format;
23
use C4::Context;
23
use C4::Context;
24
use Koha::Acquisition::Currencies;
24
use Koha::Acquisition::Currencies;
25
25
Lines 84-89 sub round { Link Here
84
84
85
    my $format_params = $self->_format_params;
85
    my $format_params = $self->_format_params;
86
86
87
    # To avoid the system to crash, we will not format big number
88
    # We divide per 100 because we want to keep the default DECIMAL_DIGITS (2)
89
    # error - round() overflow. Try smaller precision or use Math::BigFloat
90
    return $self->value if $self->value > Number::Format::MAX_INT/100;
91
87
    return Number::Format->new(%$format_params)->round($self->value);
92
    return Number::Format->new(%$format_params)->round($self->value);
88
}
93
}
89
94
(-)a/acqui/spent.pl (-1 / +1 lines)
Lines 34-39 use C4::Auth; Link Here
34
use C4::Output;
34
use C4::Output;
35
use Modern::Perl;
35
use Modern::Perl;
36
use CGI qw ( -utf8 );
36
use CGI qw ( -utf8 );
37
use C4::Acquisition;
37
use Koha::Acquisition::Invoice::Adjustments;
38
use Koha::Acquisition::Invoice::Adjustments;
38
39
39
my $dbh      = C4::Context->dbh;
40
my $dbh      = C4::Context->dbh;
40
- 

Return to bug 18736