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

(-)a/C4/Acquisition.pm (-10 / +44 lines)
Lines 93-98 BEGIN { Link Here
93
        &NotifyOrderUsers
93
        &NotifyOrderUsers
94
94
95
        &FillWithDefaultValues
95
        &FillWithDefaultValues
96
97
        &get_rounded_price
96
    );
98
    );
97
}
99
}
98
100
Lines 1470-1477 sub ModReceiveOrder { Link Here
1470
        $dbh->do(q|
1472
        $dbh->do(q|
1471
            UPDATE aqorders
1473
            UPDATE aqorders
1472
            SET
1474
            SET
1473
                tax_value_on_ordering = quantity * ecost_tax_excluded * tax_rate_on_ordering,
1475
                tax_value_on_ordering = quantity * | . _get_rounding_sql(q|ecost_tax_excluded|) . q| * tax_rate_on_ordering,
1474
                tax_value_on_receiving = quantity * unitprice_tax_excluded * tax_rate_on_receiving
1476
                tax_value_on_receiving = quantity * | . _get_rounding_sql(q|unitprice_tax_excluded|) . q| * tax_rate_on_receiving
1475
            WHERE ordernumber = ?
1477
            WHERE ordernumber = ?
1476
        |, undef, $order->{ordernumber});
1478
        |, undef, $order->{ordernumber});
1477
1479
Lines 1483-1490 sub ModReceiveOrder { Link Here
1483
        $order->{tax_rate_on_ordering} //= 0;
1485
        $order->{tax_rate_on_ordering} //= 0;
1484
        $order->{unitprice_tax_excluded} //= 0;
1486
        $order->{unitprice_tax_excluded} //= 0;
1485
        $order->{tax_rate_on_receiving} //= 0;
1487
        $order->{tax_rate_on_receiving} //= 0;
1486
        $order->{tax_value_on_ordering} = $order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate_on_ordering};
1488
        $order->{tax_value_on_ordering} = $order->{quantity} * get_rounded_price($order->{ecost_tax_excluded}) * $order->{tax_rate_on_ordering};
1487
        $order->{tax_value_on_receiving} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate_on_receiving};
1489
        $order->{tax_value_on_receiving} = $order->{quantity} * get_rounded_price($order->{unitprice_tax_excluded}) * $order->{tax_rate_on_receiving};
1488
        $order->{datereceived} = $datereceived;
1490
        $order->{datereceived} = $datereceived;
1489
        $order->{invoiceid} = $invoice->{invoiceid};
1491
        $order->{invoiceid} = $invoice->{invoiceid};
1490
        $order->{orderstatus} = 'complete';
1492
        $order->{orderstatus} = 'complete';
Lines 1646-1653 sub CancelReceipt { Link Here
1646
        $dbh->do(q|
1648
        $dbh->do(q|
1647
            UPDATE aqorders
1649
            UPDATE aqorders
1648
            SET
1650
            SET
1649
                tax_value_on_ordering = quantity * ecost_tax_excluded * tax_rate_on_ordering,
1651
                tax_value_on_ordering = quantity * | . _get_rounding_sql(q|ecost_tax_excluded|) . q| * tax_rate_on_ordering,
1650
                tax_value_on_receiving = quantity * unitprice_tax_excluded * tax_rate_on_receiving
1652
                tax_value_on_receiving = quantity * | . _get_rounding_sql(q|unitprice_tax_excluded|) . q| * tax_rate_on_receiving
1651
            WHERE ordernumber = ?
1653
            WHERE ordernumber = ?
1652
        |, undef, $parent_ordernumber);
1654
        |, undef, $parent_ordernumber);
1653
1655
Lines 1998-2003 sub TransferOrder { Link Here
1998
    return $newordernumber;
2000
    return $newordernumber;
1999
}
2001
}
2000
2002
2003
=head3 _get_rounding_sql
2004
2005
    $rounding_sql = _get_rounding_sql("mysql_variable_to_round_string");
2006
2007
returns the correct SQL routine based on OrderPriceRounding system preference.
2008
2009
=cut
2010
2011
sub _get_rounding_sql {
2012
    my $round_string = @_;
2013
    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
2014
    if ( $rounding_pref eq "nearest_cent"  ) { return ("ROUND($round_string,2)"); }
2015
    else                                     { return ("$round_string"); }
2016
}
2017
2018
=head3 get_rounded_price
2019
2020
    $rounded_price = get_rounded_price( $price );
2021
2022
returns a price rounded as specified in OrderPriceRounding system preference.
2023
2024
=cut
2025
2026
sub get_rounded_price {
2027
    my $price = @_;
2028
    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
2029
    if( $rounding_pref eq 'nearest_cent' ) { return Koha::Number::Price->new( $price )->format(); }
2030
    else                                   { return $price; }
2031
}
2032
2033
2001
=head2 FUNCTIONS ABOUT PARCELS
2034
=head2 FUNCTIONS ABOUT PARCELS
2002
2035
2003
=head3 GetParcels
2036
=head3 GetParcels
Lines 2149-2158 sub GetLateOrders { Link Here
2149
        AND (aqorders.datecancellationprinted IS NULL OR aqorders.datecancellationprinted='0000-00-00')
2182
        AND (aqorders.datecancellationprinted IS NULL OR aqorders.datecancellationprinted='0000-00-00')
2150
    ";
2183
    ";
2151
    my $having = "";
2184
    my $having = "";
2185
    my ($round_sql_start,$round_sql_end) = _get_rounding_sql();
2152
    if ($dbdriver eq "mysql") {
2186
    if ($dbdriver eq "mysql") {
2153
        $select .= "
2187
        $select .= "
2154
        aqorders.quantity - COALESCE(aqorders.quantityreceived,0)                 AS quantity,
2188
        aqorders.quantity - COALESCE(aqorders.quantityreceived,0)                 AS quantity,
2155
        (aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal,
2189
        (aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * $round_sql_start aqorders.rrp $round_sql_end AS subtotal,
2156
        DATEDIFF(CAST(now() AS date),closedate) AS latesince
2190
        DATEDIFF(CAST(now() AS date),closedate) AS latesince
2157
        ";
2191
        ";
2158
        if ( defined $delay ) {
2192
        if ( defined $delay ) {
Lines 2164-2170 sub GetLateOrders { Link Here
2164
        # FIXME: account for IFNULL as above
2198
        # FIXME: account for IFNULL as above
2165
        $select .= "
2199
        $select .= "
2166
                aqorders.quantity                AS quantity,
2200
                aqorders.quantity                AS quantity,
2167
                aqorders.quantity * aqorders.rrp AS subtotal,
2201
                aqorders.quantity * $round_sql_start aqorders.rrp $round_sql_end AS subtotal,
2168
                (CAST(now() AS date) - closedate)            AS latesince
2202
                (CAST(now() AS date) - closedate)            AS latesince
2169
        ";
2203
        ";
2170
        if ( defined $delay ) {
2204
        if ( defined $delay ) {
Lines 2978-2984 sub populate_order_with_prices { Link Here
2978
3012
2979
        # tax value = quantity * ecost tax excluded * tax rate
3013
        # tax value = quantity * ecost tax excluded * tax rate
2980
        $order->{tax_value_on_ordering} =
3014
        $order->{tax_value_on_ordering} =
2981
            $order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate_on_ordering};
3015
            $order->{quantity} * get_rounded_price($order->{ecost_tax_excluded}) * $order->{tax_rate_on_ordering};
2982
    }
3016
    }
2983
3017
2984
    if ($receiving) {
3018
    if ($receiving) {
Lines 3012-3018 sub populate_order_with_prices { Link Here
3012
        }
3046
        }
3013
3047
3014
        # tax value = quantity * unit price tax excluded * tax rate
3048
        # tax value = quantity * unit price tax excluded * tax rate
3015
        $order->{tax_value_on_receiving} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate_on_receiving};
3049
        $order->{tax_value_on_receiving} = $order->{quantity} * get_rounded_price($order->{unitprice_tax_excluded}) * $order->{tax_rate_on_receiving};
3016
    }
3050
    }
3017
3051
3018
    return $order;
3052
    return $order;
(-)a/C4/Budgets.pm (-6 / +26 lines)
Lines 209-219 sub GetBudgetsPlanCell { Link Here
209
    my ( $cell, $period, $budget ) = @_;
209
    my ( $cell, $period, $budget ) = @_;
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
    if ( $cell->{'authcat'} eq 'MONTHS' ) {
213
    if ( $cell->{'authcat'} eq 'MONTHS' ) {
213
        # get the actual amount
214
        # get the actual amount
214
        $sth = $dbh->prepare( qq|
215
        $sth = $dbh->prepare( qq|
215
216
216
            SELECT SUM(ecost_tax_included) AS actual FROM aqorders
217
            SELECT SUM(| .  $roundsql . qq|) AS actual FROM aqorders
217
                WHERE    budget_id = ? AND
218
                WHERE    budget_id = ? AND
218
                entrydate like "$cell->{'authvalue'}%"  |
219
                entrydate like "$cell->{'authvalue'}%"  |
219
        );
220
        );
Lines 222-228 sub GetBudgetsPlanCell { Link Here
222
        # get the actual amount
223
        # get the actual amount
223
        $sth = $dbh->prepare( qq|
224
        $sth = $dbh->prepare( qq|
224
225
225
            SELECT SUM(ecost_tax_included) FROM aqorders
226
            SELECT SUM(| . $roundsql . qq|) FROM aqorders
226
                LEFT JOIN aqorders_items
227
                LEFT JOIN aqorders_items
227
                ON (aqorders.ordernumber = aqorders_items.ordernumber)
228
                ON (aqorders.ordernumber = aqorders_items.ordernumber)
228
                LEFT JOIN items
229
                LEFT JOIN items
Lines 234-240 sub GetBudgetsPlanCell { Link Here
234
        # get the actual amount
235
        # get the actual amount
235
        $sth = $dbh->prepare(  qq|
236
        $sth = $dbh->prepare(  qq|
236
237
237
            SELECT SUM( ecost_tax_included *  quantity) AS actual
238
            SELECT SUM( | . $roundsql . qq| *  quantity) AS actual
238
                FROM aqorders JOIN biblioitems
239
                FROM aqorders JOIN biblioitems
239
                ON (biblioitems.biblionumber = aqorders.biblionumber )
240
                ON (biblioitems.biblionumber = aqorders.biblionumber )
240
                WHERE aqorders.budget_id = ? and itemtype  = ? |
241
                WHERE aqorders.budget_id = ? and itemtype  = ? |
Lines 247-253 sub GetBudgetsPlanCell { Link Here
247
        # get the actual amount
248
        # get the actual amount
248
        $sth = $dbh->prepare( qq|
249
        $sth = $dbh->prepare( qq|
249
250
250
        SELECT  SUM(ecost_tax_included * quantity) AS actual
251
        SELECT  SUM(| . $roundsql . qq| * quantity) AS actual
251
            FROM aqorders
252
            FROM aqorders
252
            JOIN aqbudgets ON (aqbudgets.budget_id = aqorders.budget_id )
253
            JOIN aqbudgets ON (aqbudgets.budget_id = aqorders.budget_id )
253
            WHERE  aqorders.budget_id = ? AND
254
            WHERE  aqorders.budget_id = ? AND
Lines 331-337 sub GetBudgetSpent { Link Here
331
    # unitprice_tax_included should always been set here
332
    # unitprice_tax_included should always been set here
332
    # we should not need to retrieve ecost_tax_included
333
    # we should not need to retrieve ecost_tax_included
333
    my $sth = $dbh->prepare(qq|
334
    my $sth = $dbh->prepare(qq|
334
        SELECT SUM( COALESCE(unitprice_tax_included, ecost_tax_included) * quantity ) AS sum FROM aqorders
335
        SELECT SUM( | . _get_rounding_sql("COALESCE(unitprice_tax_included, ecost_tax_included)") . qq| * quantity ) AS sum FROM aqorders
335
            WHERE budget_id = ? AND
336
            WHERE budget_id = ? AND
336
            quantityreceived > 0 AND
337
            quantityreceived > 0 AND
337
            datecancellationprinted IS NULL
338
            datecancellationprinted IS NULL
Lines 357-363 sub GetBudgetOrdered { Link Here
357
	my ($budget_id) = @_;
358
	my ($budget_id) = @_;
358
	my $dbh = C4::Context->dbh;
359
	my $dbh = C4::Context->dbh;
359
	my $sth = $dbh->prepare(qq|
360
	my $sth = $dbh->prepare(qq|
360
        SELECT SUM(ecost_tax_included *  quantity) AS sum FROM aqorders
361
        SELECT SUM(| . _get_rounding_sql(qq|ecost_tax_included|) . qq| *  quantity) AS sum FROM aqorders
361
            WHERE budget_id = ? AND
362
            WHERE budget_id = ? AND
362
            quantityreceived = 0 AND
363
            quantityreceived = 0 AND
363
            datecancellationprinted IS NULL
364
            datecancellationprinted IS NULL
Lines 1276-1281 sub MoveOrders { Link Here
1276
    return \@report;
1277
    return \@report;
1277
}
1278
}
1278
1279
1280
=head1 INTERNAL FUNCTIONS
1281
1282
=cut
1283
1284
=head3 _get_rounding_sql
1285
1286
    $rounding_sql = _get_rounding_sql("mysql_variable_to_round_string");
1287
1288
returns the correct SQL routine based on OrderPriceRounding system preference.
1289
1290
=cut
1291
1292
sub _get_rounding_sql {
1293
    my $to_round = shift;
1294
    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
1295
    if   ($rounding_pref eq 'nearest_cent') { return "ROUND($to_round,2)"; }
1296
    else { return "$to_round"; }
1297
}
1298
1279
END { }    # module clean-up code here (global destructor)
1299
END { }    # module clean-up code here (global destructor)
1280
1300
1281
1;
1301
1;
(-)a/acqui/basket.pl (-4 / +4 lines)
Lines 346-354 if ( $op eq 'list' ) { Link Here
346
        push @books_loop, $line;
346
        push @books_loop, $line;
347
347
348
        $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
348
        $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
349
        $foot{$$line{tax_rate}}{tax_value} += $$line{tax_value};
349
        $foot{$$line{tax_rate}}{tax_value} += get_rounded_price($$line{tax_value});
350
        $total_tax_value += $$line{tax_value};
350
        $total_tax_value += $$line{tax_value};
351
        $foot{$$line{tax_rate}}{quantity}  += $$line{quantity};
351
        $foot{$$line{tax_rate}}{quantity}  += get_rounded_price($$line{quantity});
352
        $total_quantity += $$line{quantity};
352
        $total_quantity += $$line{quantity};
353
        $foot{$$line{tax_rate}}{total_tax_excluded} += $$line{total_tax_excluded};
353
        $foot{$$line{tax_rate}}{total_tax_excluded} += $$line{total_tax_excluded};
354
        $total_tax_excluded += $$line{total_tax_excluded};
354
        $total_tax_excluded += $$line{total_tax_excluded};
Lines 451-458 sub get_order_infos { Link Here
451
    $line{basketno}       = $basketno;
451
    $line{basketno}       = $basketno;
452
    $line{budget_name}    = $budget->{budget_name};
452
    $line{budget_name}    = $budget->{budget_name};
453
453
454
    $line{total_tax_included} = $line{ecost_tax_included} * $line{quantity};
454
    $line{total_tax_included} = get_rounded_price($line{ecost_tax_included}) * $line{quantity};
455
    $line{total_tax_excluded} = $line{ecost_tax_excluded} * $line{quantity};
455
    $line{total_tax_excluded} = get_rounded_price($line{ecost_tax_excluded}) * $line{quantity};
456
    $line{tax_value} = $line{tax_value_on_ordering};
456
    $line{tax_value} = $line{tax_value_on_ordering};
457
    $line{tax_rate} = $line{tax_rate_on_ordering};
457
    $line{tax_rate} = $line{tax_rate_on_ordering};
458
458
(-)a/acqui/basketgroup.pl (-5 / +5 lines)
Lines 51-57 use C4::Auth; Link Here
51
use C4::Output;
51
use C4::Output;
52
use CGI qw ( -utf8 );
52
use CGI qw ( -utf8 );
53
53
54
use C4::Acquisition qw/CloseBasketgroup ReOpenBasketgroup GetOrders GetBasketsByBasketgroup GetBasketsByBookseller ModBasketgroup NewBasketgroup DelBasketgroup GetBasketgroups ModBasket GetBasketgroup GetBasket GetBasketGroupAsCSV/;
54
use C4::Acquisition qw/CloseBasketgroup ReOpenBasketgroup GetOrders GetBasketsByBasketgroup GetBasketsByBookseller ModBasketgroup NewBasketgroup DelBasketgroup GetBasketgroups ModBasket GetBasketgroup GetBasket GetBasketGroupAsCSV get_rounded_price/;
55
use Koha::EDI qw/create_edi_order get_edifact_ean/;
55
use Koha::EDI qw/create_edi_order get_edifact_ean/;
56
56
57
use Koha::Biblioitems;
57
use Koha::Biblioitems;
Lines 78-86 sub BasketTotal { Link Here
78
    for my $order (@orders){
78
    for my $order (@orders){
79
        # FIXME The following is wrong
79
        # FIXME The following is wrong
80
        if ( $bookseller->listincgst ) {
80
        if ( $bookseller->listincgst ) {
81
            $total = $total + ( $order->{ecost_tax_included} * $order->{quantity} );
81
            $total = $total + ( get_rounded_price($order->{ecost_tax_included}) * $order->{quantity} );
82
        } else {
82
        } else {
83
            $total = $total + ( $order->{ecost_tax_excluded} * $order->{quantity} );
83
            $total = $total + ( get_rounded_price($order->{ecost_tax_excluded}) * $order->{quantity} );
84
        }
84
        }
85
    }
85
    }
86
    $total .= " " . ($bookseller->invoiceprice // 0);
86
    $total .= " " . ($bookseller->invoiceprice // 0);
Lines 172-179 sub printbasketgrouppdf{ Link Here
172
172
173
            $ord->{tax_value} = $ord->{tax_value_on_ordering};
173
            $ord->{tax_value} = $ord->{tax_value_on_ordering};
174
            $ord->{tax_rate} = $ord->{tax_rate_on_ordering};
174
            $ord->{tax_rate} = $ord->{tax_rate_on_ordering};
175
            $ord->{total_tax_included} = $ord->{ecost_tax_included} * $ord->{quantity};
175
            $ord->{total_tax_included} = get_rounded_price($ord->{ecost_tax_included}) * $ord->{quantity};
176
            $ord->{total_tax_excluded} = $ord->{ecost_tax_excluded} * $ord->{quantity};
176
            $ord->{total_tax_excluded} = get_rounded_price($ord->{ecost_tax_excluded}) * $ord->{quantity};
177
177
178
            my $biblioitem = Koha::Biblioitems->search({ biblionumber => $ord->{biblionumber} })->next;
178
            my $biblioitem = Koha::Biblioitems->search({ biblionumber => $ord->{biblionumber} })->next;
179
179
(-)a/acqui/invoice.pl (-7 / +7 lines)
Lines 124-144 my $total_tax_value = 0; Link Here
124
foreach my $order (@$orders) {
124
foreach my $order (@$orders) {
125
    my $line = get_infos( $order, $bookseller);
125
    my $line = get_infos( $order, $bookseller);
126
126
127
    $line->{total_tax_excluded} = $line->{unitprice_tax_excluded} * $line->{quantity};
127
    $line->{total_tax_excluded} = get_rounded_price($line->{unitprice_tax_excluded}) * $line->{quantity};
128
    $line->{total_tax_included} = $line->{unitprice_tax_included} * $line->{quantity};
128
    $line->{total_tax_included} = get_rounded_price($line->{unitprice_tax_included}) * $line->{quantity};
129
129
130
    $line->{tax_value} = $line->{tax_value_on_receiving};
130
    $line->{tax_value} = $line->{tax_value_on_receiving};
131
    $line->{tax_rate} = $line->{tax_rate_on_receiving};
131
    $line->{tax_rate} = $line->{tax_rate_on_receiving};
132
132
133
    $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
133
    $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
134
    $foot{$$line{tax_rate}}{tax_value} += $$line{tax_value};
134
    $foot{$$line{tax_rate}}{tax_value} += get_rounded_price($$line{tax_value});
135
    $total_tax_value += $$line{tax_value};
135
    $total_tax_value += $$line{tax_value};
136
    $foot{$$line{tax_rate}}{quantity}  += $$line{quantity};
136
    $foot{$$line{tax_rate}}{quantity}  += $$line{quantity};
137
    $total_quantity += $$line{quantity};
137
    $total_quantity += $$line{quantity};
138
    $foot{$$line{tax_rate}}{total_tax_excluded} += $$line{total_tax_excluded};
138
    $foot{$$line{tax_rate}}{total_tax_excluded} += get_rounded_price($$line{total_tax_excluded});
139
    $total_tax_excluded += $$line{total_tax_excluded};
139
    $total_tax_excluded += get_rounded_price($$line{total_tax_excluded});
140
    $foot{$$line{tax_rate}}{total_tax_included} += $$line{total_tax_included};
140
    $foot{$$line{tax_rate}}{total_tax_included} += get_rounded_price($$line{total_tax_included});
141
    $total_tax_included += $$line{total_tax_included};
141
    $total_tax_included += get_rounded_price($$line{total_tax_included});
142
142
143
    $line->{orderline} = $line->{parent_ordernumber};
143
    $line->{orderline} = $line->{parent_ordernumber};
144
    push @orders_loop, $line;
144
    push @orders_loop, $line;
(-)a/acqui/ordered.pl (-1 / +2 lines)
Lines 33-38 use warnings; Link Here
33
use CGI qw ( -utf8 );
33
use CGI qw ( -utf8 );
34
use C4::Auth;
34
use C4::Auth;
35
use C4::Output;
35
use C4::Output;
36
use C4::Acquisition;
36
37
37
my $dbh     = C4::Context->dbh;
38
my $dbh     = C4::Context->dbh;
38
my $input   = new CGI;
39
my $input   = new CGI;
Lines 89-95 while ( my $data = $sth->fetchrow_hashref ) { Link Here
89
        $left = $data->{'quantity'};
90
        $left = $data->{'quantity'};
90
    }
91
    }
91
    if ( $left && $left > 0 ) {
92
    if ( $left && $left > 0 ) {
92
        my $subtotal = $left * $data->{'ecost'};
93
        my $subtotal = $left * get_rounded_price($data->{'ecost'});
93
        $data->{subtotal} = sprintf( "%.2f", $subtotal );
94
        $data->{subtotal} = sprintf( "%.2f", $subtotal );
94
        $data->{'left'} = $left;
95
        $data->{'left'} = $left;
95
        push @ordered, $data;
96
        push @ordered, $data;
(-)a/acqui/parcel.pl (-5 / +5 lines)
Lines 135-141 for my $order ( @orders ) { Link Here
135
        $order->{unitprice} = $order->{unitprice_tax_excluded};
135
        $order->{unitprice} = $order->{unitprice_tax_excluded};
136
    }
136
    }
137
137
138
    $order->{total} = $order->{unitprice} * $order->{quantity};
138
    $order->{total} = get_rounded_price($order->{unitprice}) * $order->{quantity};
139
139
140
    my %line = %{ $order };
140
    my %line = %{ $order };
141
    $line{invoice} = $invoice->{invoicenumber};
141
    $line{invoice} = $invoice->{invoicenumber};
Lines 153-160 for my $order ( @orders ) { Link Here
153
    $line{tax_rate} = $line{tax_rate_on_receiving};
153
    $line{tax_rate} = $line{tax_rate_on_receiving};
154
    $foot{$line{tax_rate}}{tax_rate} = $line{tax_rate};
154
    $foot{$line{tax_rate}}{tax_rate} = $line{tax_rate};
155
    $foot{$line{tax_rate}}{tax_value} += $line{tax_value};
155
    $foot{$line{tax_rate}}{tax_value} += $line{tax_value};
156
    $total_tax_excluded += $line{unitprice_tax_excluded} * $line{quantity};
156
    $total_tax_excluded += get_rounded_price($line{unitprice_tax_excluded}) * $line{quantity};
157
    $total_tax_included += $line{unitprice_tax_included} * $line{quantity};
157
    $total_tax_included += get_rounded_price($line{unitprice_tax_included}) * $line{quantity};
158
158
159
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
159
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
160
    $line{suggestionid}         = $suggestion->{suggestionid};
160
    $line{suggestionid}         = $suggestion->{suggestionid};
Lines 173-179 for my $order ( @orders ) { Link Here
173
    my $budget_name = GetBudgetName( $line{budget_id} );
173
    my $budget_name = GetBudgetName( $line{budget_id} );
174
    $line{budget_name} = $budget_name;
174
    $line{budget_name} = $budget_name;
175
175
176
    $subtotal_for_funds->{ $line{budget_name} }{ecost} += $order->{ecost} * $order->{quantity};
176
    $subtotal_for_funds->{ $line{budget_name} }{ecost} += get_rounded_price($order->{ecost}) * $order->{quantity};
177
    $subtotal_for_funds->{ $line{budget_name} }{unitprice} += $order->{total};
177
    $subtotal_for_funds->{ $line{budget_name} }{unitprice} += $order->{total};
178
178
179
    push @loop_received, \%line;
179
    push @loop_received, \%line;
Lines 231-237 unless( defined $invoice->{closedate} ) { Link Here
231
        } else {
231
        } else {
232
            $order->{ecost} = $order->{ecost_tax_excluded};
232
            $order->{ecost} = $order->{ecost_tax_excluded};
233
        }
233
        }
234
        $order->{total} = $order->{ecost} * $order->{quantity};
234
        $order->{total} = get_rounded_price($order->{ecost}) * $order->{quantity};
235
235
236
        my %line = %$order;
236
        my %line = %$order;
237
237
(-)a/acqui/pdfformat/layout3pages.pm (-3 / +4 lines)
Lines 29-34 use strict; Link Here
29
use warnings;
29
use warnings;
30
use utf8;
30
use utf8;
31
31
32
use C4::Acquisition;
32
use Koha::Number::Price;
33
use Koha::Number::Price;
33
use Koha::DateUtils;
34
use Koha::DateUtils;
34
use Koha::Libraries;
35
use Koha::Libraries;
Lines 222-230 sub printbaskets { Link Here
222
            $total_tax_excluded += $ord->{total_tax_excluded};
223
            $total_tax_excluded += $ord->{total_tax_excluded};
223
            $total_tax_included += $ord->{total_tax_included};
224
            $total_tax_included += $ord->{total_tax_included};
224
            $totaltax_value += $ord->{tax_value};
225
            $totaltax_value += $ord->{tax_value};
225
            $totaldiscount += ($ord->{rrp_tax_excluded} - $ord->{ecost_tax_excluded} ) * $ord->{quantity};
226
            $totaldiscount += (get_rounded_price($ord->{rrp_tax_excluded}) - get_rounded_price($ord->{ecost_tax_excluded}) ) * $ord->{quantity};
226
            $total_rrp_tax_excluded += $ord->{rrp_tax_excluded} * $ord->{quantity};
227
            $total_rrp_tax_excluded += get_rounded_price($ord->{rrp_tax_excluded}) * $ord->{quantity};
227
            $total_rrp_tax_included += $ord->{rrp_tax_included} * $ord->{quantity};
228
            $total_rrp_tax_included += get_rounded_price($ord->{rrp_tax_included}) * $ord->{quantity};
228
            push @gst, $ord->{tax_rate};
229
            push @gst, $ord->{tax_rate};
229
        }
230
        }
230
        @gst = uniq map { $_ * 100 } @gst;
231
        @gst = uniq map { $_ * 100 } @gst;
(-)a/acqui/pdfformat/layout3pagesfr.pm (+1 lines)
Lines 28-33 use strict; Link Here
28
use warnings;
28
use warnings;
29
use utf8;
29
use utf8;
30
30
31
use C4::Acquisition;
31
use Koha::Number::Price;
32
use Koha::Number::Price;
32
use Koha::DateUtils;
33
use Koha::DateUtils;
33
use Koha::Libraries;
34
use Koha::Libraries;
(-)a/acqui/spent.pl (-1 / +1 lines)
Lines 92-98 my @spent; Link Here
92
while ( my $data = $sth->fetchrow_hashref ) {
92
while ( my $data = $sth->fetchrow_hashref ) {
93
    my $recv = $data->{'quantityreceived'};
93
    my $recv = $data->{'quantityreceived'};
94
    if ( $recv > 0 ) {
94
    if ( $recv > 0 ) {
95
        my $rowtotal = $recv * $data->{'unitprice'};
95
        my $rowtotal = $recv * get_rounded_price($data->{'unitprice'});
96
        $data->{'rowtotal'}  = sprintf( "%.2f", $rowtotal );
96
        $data->{'rowtotal'}  = sprintf( "%.2f", $rowtotal );
97
        $data->{'unitprice'} = sprintf( "%.2f", $data->{'unitprice'} );
97
        $data->{'unitprice'} = sprintf( "%.2f", $data->{'unitprice'} );
98
        $subtotal += $rowtotal;
98
        $subtotal += $rowtotal;
(-)a/reports/orders_by_fund.pl (-3 / +2 lines)
Lines 107-114 if ( $get_orders ) { Link Here
107
        $order->{title} = $biblio ? $biblio->title : '';
107
        $order->{title} = $biblio ? $biblio->title : '';
108
        $order->{title} ||= $order->{biblionumber};
108
        $order->{title} ||= $order->{biblionumber};
109
109
110
        $order->{'total_rrp'} = $order->{'quantity'} * $order->{'rrp'};
110
        $order->{'total_rrp'} = get_rounded_price($order->{'quantity'}) * $order->{'rrp'};
111
        $order->{'total_ecost'} = $order->{'quantity'} * $order->{'ecost'};
111
        $order->{'total_ecost'} = get_rounded_price($order->{'quantity'}) * $order->{'ecost'};
112
112
113
        # Format the dates and currencies correctly
113
        # Format the dates and currencies correctly
114
        $order->{'datereceived'} = output_pref(dt_from_string($order->{'datereceived'}));
114
        $order->{'datereceived'} = output_pref(dt_from_string($order->{'datereceived'}));
115
- 

Return to bug 18736