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

(-)a/C4/Acquisition.pm (-1 / +1 lines)
Lines 2028-2034 returns a price rounded as specified in OrderPriceRounding system preference. Link Here
2028
sub get_rounded_price {
2028
sub get_rounded_price {
2029
    my ( $price ) =  @_;
2029
    my ( $price ) =  @_;
2030
    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
2030
    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
2031
    if( $rounding_pref eq 'nearest_cent' ) { return Koha::Number::Price->new( $price )->format(); }
2031
    if( $rounding_pref eq 'nearest_cent' ) { return Koha::Number::Price->new( $price )->round(); }
2032
    else                                   { return $price; }
2032
    else                                   { return $price; }
2033
}
2033
}
2034
2034
(-)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 qw( format_price round );
23
use C4::Context;
23
use C4::Context;
24
use Koha::Acquisition::Currencies;
24
use Koha::Acquisition::Currencies;
25
25
Lines 79-84 sub round { Link Here
79
79
80
    my $format_params = $self->_format_params;
80
    my $format_params = $self->_format_params;
81
81
82
    # To avoid the system to crash, we will not format big number
83
    # We divide per 100 because we want to keep the default DECIMAL_DIGITS (2)
84
    # error - round() overflow. Try smaller precision or use Math::BigFloat
85
    return $self->value if $self->value > Number::Format::MAX_INT/100;
86
82
    return Number::Format->new(%$format_params)->round($self->value);
87
    return Number::Format->new(%$format_params)->round($self->value);
83
}
88
}
84
89
(-)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