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

(-)a/C4/Acquisition.pm (-1 / +1 lines)
Lines 2025-2031 returns a price rounded as specified in OrderPriceRounding system preference. Link Here
2025
sub get_rounded_price {
2025
sub get_rounded_price {
2026
    my ( $price ) =  @_;
2026
    my ( $price ) =  @_;
2027
    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
2027
    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
2028
    if( $rounding_pref eq 'nearest_cent' ) { return Koha::Number::Price->new( $price )->format(); }
2028
    if( $rounding_pref eq 'nearest_cent' ) { return Koha::Number::Price->new( $price )->round(); }
2029
    else                                   { return $price; }
2029
    else                                   { return $price; }
2030
}
2030
}
2031
2031
(-)a/C4/Budgets.pm (-2 / +2 lines)
Lines 561-574 sub GetBudgetHierarchy { Link Here
561
    # Get all the budgets totals in as few queries as possible
561
    # Get all the budgets totals in as few queries as possible
562
    my $hr_budget_spent = $dbh->selectall_hashref(q|
562
    my $hr_budget_spent = $dbh->selectall_hashref(q|
563
        SELECT aqorders.budget_id, aqbudgets.budget_parent_id,
563
        SELECT aqorders.budget_id, aqbudgets.budget_parent_id,
564
               SUM( COALESCE(unitprice_tax_included, ecost_tax_included) * quantity ) AS budget_spent
564
               SUM( | . _get_rounding_sql(qq|COALESCE(unitprice_tax_included, ecost_tax_included)|) . q| * quantity ) AS budget_spent
565
        FROM aqorders JOIN aqbudgets USING (budget_id)
565
        FROM aqorders JOIN aqbudgets USING (budget_id)
566
        WHERE quantityreceived > 0 AND datecancellationprinted IS NULL
566
        WHERE quantityreceived > 0 AND datecancellationprinted IS NULL
567
        GROUP BY budget_id, budget_parent_id
567
        GROUP BY budget_id, budget_parent_id
568
        |, 'budget_id');
568
        |, 'budget_id');
569
    my $hr_budget_ordered = $dbh->selectall_hashref(q|
569
    my $hr_budget_ordered = $dbh->selectall_hashref(q|
570
        SELECT aqorders.budget_id, aqbudgets.budget_parent_id,
570
        SELECT aqorders.budget_id, aqbudgets.budget_parent_id,
571
               SUM(ecost_tax_included *  quantity) AS budget_ordered
571
               SUM( | . _get_rounding_sql(qq|ecost_tax_included|) . q| *  quantity) AS budget_ordered
572
        FROM aqorders JOIN aqbudgets USING (budget_id)
572
        FROM aqorders JOIN aqbudgets USING (budget_id)
573
        WHERE quantityreceived = 0 AND datecancellationprinted IS NULL
573
        WHERE quantityreceived = 0 AND datecancellationprinted IS NULL
574
        GROUP BY budget_id, budget_parent_id
574
        GROUP BY budget_id, budget_parent_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