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 1472-1479 sub ModReceiveOrder { Link Here
1472
        $dbh->do(q|
1474
        $dbh->do(q|
1473
            UPDATE aqorders
1475
            UPDATE aqorders
1474
            SET
1476
            SET
1475
                tax_value_on_ordering = quantity * ecost_tax_excluded * tax_rate_on_ordering,
1477
                tax_value_on_ordering = quantity * | . _get_rounding_sql(q|ecost_tax_excluded|) . q| * tax_rate_on_ordering,
1476
                tax_value_on_receiving = quantity * unitprice_tax_excluded * tax_rate_on_receiving
1478
                tax_value_on_receiving = quantity * | . _get_rounding_sql(q|unitprice_tax_excluded|) . q| * tax_rate_on_receiving
1477
            WHERE ordernumber = ?
1479
            WHERE ordernumber = ?
1478
        |, undef, $order->{ordernumber});
1480
        |, undef, $order->{ordernumber});
1479
1481
Lines 1485-1492 sub ModReceiveOrder { Link Here
1485
        $order->{tax_rate_on_ordering} //= 0;
1487
        $order->{tax_rate_on_ordering} //= 0;
1486
        $order->{unitprice_tax_excluded} //= 0;
1488
        $order->{unitprice_tax_excluded} //= 0;
1487
        $order->{tax_rate_on_receiving} //= 0;
1489
        $order->{tax_rate_on_receiving} //= 0;
1488
        $order->{tax_value_on_ordering} = $order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate_on_ordering};
1490
        $order->{tax_value_on_ordering} = $order->{quantity} * get_rounded_price($order->{ecost_tax_excluded}) * $order->{tax_rate_on_ordering};
1489
        $order->{tax_value_on_receiving} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate_on_receiving};
1491
        $order->{tax_value_on_receiving} = $order->{quantity} * get_rounded_price($order->{unitprice_tax_excluded}) * $order->{tax_rate_on_receiving};
1490
        $order->{datereceived} = $datereceived;
1492
        $order->{datereceived} = $datereceived;
1491
        $order->{invoiceid} = $invoice->{invoiceid};
1493
        $order->{invoiceid} = $invoice->{invoiceid};
1492
        $order->{orderstatus} = 'complete';
1494
        $order->{orderstatus} = 'complete';
Lines 1648-1655 sub CancelReceipt { Link Here
1648
        $dbh->do(q|
1650
        $dbh->do(q|
1649
            UPDATE aqorders
1651
            UPDATE aqorders
1650
            SET
1652
            SET
1651
                tax_value_on_ordering = quantity * ecost_tax_excluded * tax_rate_on_ordering,
1653
                tax_value_on_ordering = quantity * | . _get_rounding_sql(q|ecost_tax_excluded|) . q| * tax_rate_on_ordering,
1652
                tax_value_on_receiving = quantity * unitprice_tax_excluded * tax_rate_on_receiving
1654
                tax_value_on_receiving = quantity * | . _get_rounding_sql(q|unitprice_tax_excluded|) . q| * tax_rate_on_receiving
1653
            WHERE ordernumber = ?
1655
            WHERE ordernumber = ?
1654
        |, undef, $parent_ordernumber);
1656
        |, undef, $parent_ordernumber);
1655
1657
Lines 2000-2005 sub TransferOrder { Link Here
2000
    return $newordernumber;
2002
    return $newordernumber;
2001
}
2003
}
2002
2004
2005
=head3 _get_rounding_sql
2006
2007
    $rounding_sql = _get_rounding_sql("mysql_variable_to_round_string");
2008
2009
returns the correct SQL routine based on OrderPriceRounding system preference.
2010
2011
=cut
2012
2013
sub _get_rounding_sql {
2014
    my $round_string = @_;
2015
    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
2016
    if ( $rounding_pref eq "nearest_cent"  ) { return ("ROUND($round_string,2)"); }
2017
    else                                     { return ("$round_string"); }
2018
}
2019
2020
=head3 get_rounded_price
2021
2022
    $rounded_price = get_rounded_price( $price );
2023
2024
returns a price rounded as specified in OrderPriceRounding system preference.
2025
2026
=cut
2027
2028
sub get_rounded_price {
2029
    my $price = @_;
2030
    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
2031
    if( $rounding_pref eq 'nearest_cent' ) { return Koha::Number::Price->new( $price )->format(); }
2032
    else                                   { return $price; }
2033
}
2034
2035
2003
=head2 FUNCTIONS ABOUT PARCELS
2036
=head2 FUNCTIONS ABOUT PARCELS
2004
2037
2005
=head3 GetParcels
2038
=head3 GetParcels
Lines 2150-2159 sub GetLateOrders { Link Here
2150
        AND aqbasket.closedate IS NOT NULL
2183
        AND aqbasket.closedate IS NOT NULL
2151
        AND (aqorders.datecancellationprinted IS NULL OR aqorders.datecancellationprinted='0000-00-00')
2184
        AND (aqorders.datecancellationprinted IS NULL OR aqorders.datecancellationprinted='0000-00-00')
2152
    ";
2185
    ";
2186
    my ($round_sql_start,$round_sql_end) = _get_rounding_sql();
2153
    if ($dbdriver eq "mysql") {
2187
    if ($dbdriver eq "mysql") {
2154
        $select .= "
2188
        $select .= "
2155
        aqorders.quantity - COALESCE(aqorders.quantityreceived,0)                 AS quantity,
2189
        aqorders.quantity - COALESCE(aqorders.quantityreceived,0)                 AS quantity,
2156
        (aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal,
2190
        (aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * $round_sql_start aqorders.rrp $round_sql_end AS subtotal,
2157
        DATEDIFF(CAST(now() AS date),closedate) AS latesince
2191
        DATEDIFF(CAST(now() AS date),closedate) AS latesince
2158
        ";
2192
        ";
2159
        if ( defined $delay ) {
2193
        if ( defined $delay ) {
Lines 2165-2171 sub GetLateOrders { Link Here
2165
        # FIXME: account for IFNULL as above
2199
        # FIXME: account for IFNULL as above
2166
        $select .= "
2200
        $select .= "
2167
                aqorders.quantity                AS quantity,
2201
                aqorders.quantity                AS quantity,
2168
                aqorders.quantity * aqorders.rrp AS subtotal,
2202
                aqorders.quantity * $round_sql_start aqorders.rrp $round_sql_end AS subtotal,
2169
                (CAST(now() AS date) - closedate)            AS latesince
2203
                (CAST(now() AS date) - closedate)            AS latesince
2170
        ";
2204
        ";
2171
        if ( defined $delay ) {
2205
        if ( defined $delay ) {
Lines 3000-3006 sub populate_order_with_prices { Link Here
3000
3034
3001
        # tax value = quantity * ecost tax excluded * tax rate
3035
        # tax value = quantity * ecost tax excluded * tax rate
3002
        $order->{tax_value_on_ordering} =
3036
        $order->{tax_value_on_ordering} =
3003
            $order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate_on_ordering};
3037
            $order->{quantity} * get_rounded_price($order->{ecost_tax_excluded}) * $order->{tax_rate_on_ordering};
3004
    }
3038
    }
3005
3039
3006
    if ($receiving) {
3040
    if ($receiving) {
Lines 3034-3040 sub populate_order_with_prices { Link Here
3034
        }
3068
        }
3035
3069
3036
        # tax value = quantity * unit price tax excluded * tax rate
3070
        # tax value = quantity * unit price tax excluded * tax rate
3037
        $order->{tax_value_on_receiving} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate_on_receiving};
3071
        $order->{tax_value_on_receiving} = $order->{quantity} * get_rounded_price($order->{unitprice_tax_excluded}) * $order->{tax_rate_on_receiving};
3038
    }
3072
    }
3039
3073
3040
    return $order;
3074
    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 1329-1334 sub MoveOrders { Link Here
1329
    return \@report;
1330
    return \@report;
1330
}
1331
}
1331
1332
1333
=head1 INTERNAL FUNCTIONS
1334
1335
=cut
1336
1337
=head3 _get_rounding_sql
1338
1339
    $rounding_sql = _get_rounding_sql("mysql_variable_to_round_string");
1340
1341
returns the correct SQL routine based on OrderPriceRounding system preference.
1342
1343
=cut
1344
1345
sub _get_rounding_sql {
1346
    my $to_round = shift;
1347
    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
1348
    if   ($rounding_pref eq 'nearest_cent') { return "ROUND($to_round,2)"; }
1349
    else { return "$to_round"; }
1350
}
1351
1332
END { }    # module clean-up code here (global destructor)
1352
END { }    # module clean-up code here (global destructor)
1333
1353
1334
1;
1354
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 50-56 use C4::Auth; Link Here
50
use C4::Output;
50
use C4::Output;
51
use CGI qw ( -utf8 );
51
use CGI qw ( -utf8 );
52
52
53
use C4::Acquisition qw/CloseBasketgroup ReOpenBasketgroup GetOrders GetBasketsByBasketgroup GetBasketsByBookseller ModBasketgroup NewBasketgroup DelBasketgroup GetBasketgroups ModBasket GetBasketgroup GetBasket GetBasketGroupAsCSV/;
53
use C4::Acquisition qw/CloseBasketgroup ReOpenBasketgroup GetOrders GetBasketsByBasketgroup GetBasketsByBookseller ModBasketgroup NewBasketgroup DelBasketgroup GetBasketgroups ModBasket GetBasketgroup GetBasket GetBasketGroupAsCSV get_rounded_price/;
54
use Koha::EDI qw/create_edi_order get_edifact_ean/;
54
use Koha::EDI qw/create_edi_order get_edifact_ean/;
55
55
56
use Koha::Biblioitems;
56
use Koha::Biblioitems;
Lines 77-85 sub BasketTotal { Link Here
77
    for my $order (@orders){
77
    for my $order (@orders){
78
        # FIXME The following is wrong
78
        # FIXME The following is wrong
79
        if ( $bookseller->listincgst ) {
79
        if ( $bookseller->listincgst ) {
80
            $total = $total + ( $order->{ecost_tax_included} * $order->{quantity} );
80
            $total = $total + ( get_rounded_price($order->{ecost_tax_included}) * $order->{quantity} );
81
        } else {
81
        } else {
82
            $total = $total + ( $order->{ecost_tax_excluded} * $order->{quantity} );
82
            $total = $total + ( get_rounded_price($order->{ecost_tax_excluded}) * $order->{quantity} );
83
        }
83
        }
84
    }
84
    }
85
    return $total;
85
    return $total;
Lines 170-177 sub printbasketgrouppdf{ Link Here
170
170
171
            $ord->{tax_value} = $ord->{tax_value_on_ordering};
171
            $ord->{tax_value} = $ord->{tax_value_on_ordering};
172
            $ord->{tax_rate} = $ord->{tax_rate_on_ordering};
172
            $ord->{tax_rate} = $ord->{tax_rate_on_ordering};
173
            $ord->{total_tax_included} = $ord->{ecost_tax_included} * $ord->{quantity};
173
            $ord->{total_tax_included} = get_rounded_price($ord->{ecost_tax_included}) * $ord->{quantity};
174
            $ord->{total_tax_excluded} = $ord->{ecost_tax_excluded} * $ord->{quantity};
174
            $ord->{total_tax_excluded} = get_rounded_price($ord->{ecost_tax_excluded}) * $ord->{quantity};
175
175
176
            my $biblioitem = Koha::Biblioitems->search({ biblionumber => $ord->{biblionumber} })->next;
176
            my $biblioitem = Koha::Biblioitems->search({ biblionumber => $ord->{biblionumber} })->next;
177
177
(-)a/acqui/invoice.pl (-7 / +7 lines)
Lines 123-143 my $total_tax_value = 0; Link Here
123
foreach my $order (@$orders) {
123
foreach my $order (@$orders) {
124
    my $line = get_infos( $order, $bookseller);
124
    my $line = get_infos( $order, $bookseller);
125
125
126
    $line->{total_tax_excluded} = $line->{unitprice_tax_excluded} * $line->{quantity};
126
    $line->{total_tax_excluded} = get_rounded_price($line->{unitprice_tax_excluded}) * $line->{quantity};
127
    $line->{total_tax_included} = $line->{unitprice_tax_included} * $line->{quantity};
127
    $line->{total_tax_included} = get_rounded_price($line->{unitprice_tax_included}) * $line->{quantity};
128
128
129
    $line->{tax_value} = $line->{tax_value_on_receiving};
129
    $line->{tax_value} = $line->{tax_value_on_receiving};
130
    $line->{tax_rate} = $line->{tax_rate_on_receiving};
130
    $line->{tax_rate} = $line->{tax_rate_on_receiving};
131
131
132
    $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
132
    $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
133
    $foot{$$line{tax_rate}}{tax_value} += $$line{tax_value};
133
    $foot{$$line{tax_rate}}{tax_value} += get_rounded_price($$line{tax_value});
134
    $total_tax_value += $$line{tax_value};
134
    $total_tax_value += $$line{tax_value};
135
    $foot{$$line{tax_rate}}{quantity}  += $$line{quantity};
135
    $foot{$$line{tax_rate}}{quantity}  += $$line{quantity};
136
    $total_quantity += $$line{quantity};
136
    $total_quantity += $$line{quantity};
137
    $foot{$$line{tax_rate}}{total_tax_excluded} += $$line{total_tax_excluded};
137
    $foot{$$line{tax_rate}}{total_tax_excluded} += get_rounded_price($$line{total_tax_excluded});
138
    $total_tax_excluded += $$line{total_tax_excluded};
138
    $total_tax_excluded += get_rounded_price($$line{total_tax_excluded});
139
    $foot{$$line{tax_rate}}{total_tax_included} += $$line{total_tax_included};
139
    $foot{$$line{tax_rate}}{total_tax_included} += get_rounded_price($$line{total_tax_included});
140
    $total_tax_included += $$line{total_tax_included};
140
    $total_tax_included += get_rounded_price($$line{total_tax_included});
141
141
142
    $line->{orderline} = $line->{parent_ordernumber};
142
    $line->{orderline} = $line->{parent_ordernumber};
143
    push @orders_loop, $line;
143
    push @orders_loop, $line;
(-)a/acqui/ordered.pl (-1 / +2 lines)
Lines 32-37 use Modern::Perl; Link Here
32
use CGI qw ( -utf8 );
32
use CGI qw ( -utf8 );
33
use C4::Auth;
33
use C4::Auth;
34
use C4::Output;
34
use C4::Output;
35
use C4::Acquisition;
35
36
36
my $dbh     = C4::Context->dbh;
37
my $dbh     = C4::Context->dbh;
37
my $input   = new CGI;
38
my $input   = new CGI;
Lines 88-94 while ( my $data = $sth->fetchrow_hashref ) { Link Here
88
        $left = $data->{'quantity'};
89
        $left = $data->{'quantity'};
89
    }
90
    }
90
    if ( $left && $left > 0 ) {
91
    if ( $left && $left > 0 ) {
91
        my $subtotal = $left * $data->{'ecost'};
92
        my $subtotal = $left * get_rounded_price($data->{'ecost'});
92
        $data->{subtotal} = sprintf( "%.2f", $subtotal );
93
        $data->{subtotal} = sprintf( "%.2f", $subtotal );
93
        $data->{'left'} = $left;
94
        $data->{'left'} = $left;
94
        push @ordered, $data;
95
        push @ordered, $data;
(-)a/acqui/parcel.pl (-5 / +5 lines)
Lines 134-140 for my $order ( @orders ) { Link Here
134
        $order->{unitprice} = $order->{unitprice_tax_excluded};
134
        $order->{unitprice} = $order->{unitprice_tax_excluded};
135
    }
135
    }
136
136
137
    $order->{total} = $order->{unitprice} * $order->{quantity};
137
    $order->{total} = get_rounded_price($order->{unitprice}) * $order->{quantity};
138
138
139
    my %line = %{ $order };
139
    my %line = %{ $order };
140
    $line{invoice} = $invoice->{invoicenumber};
140
    $line{invoice} = $invoice->{invoicenumber};
Lines 152-159 for my $order ( @orders ) { Link Here
152
    $line{tax_rate} = $line{tax_rate_on_receiving};
152
    $line{tax_rate} = $line{tax_rate_on_receiving};
153
    $foot{$line{tax_rate}}{tax_rate} = $line{tax_rate};
153
    $foot{$line{tax_rate}}{tax_rate} = $line{tax_rate};
154
    $foot{$line{tax_rate}}{tax_value} += $line{tax_value};
154
    $foot{$line{tax_rate}}{tax_value} += $line{tax_value};
155
    $total_tax_excluded += $line{unitprice_tax_excluded} * $line{quantity};
155
    $total_tax_excluded += get_rounded_price($line{unitprice_tax_excluded}) * $line{quantity};
156
    $total_tax_included += $line{unitprice_tax_included} * $line{quantity};
156
    $total_tax_included += get_rounded_price($line{unitprice_tax_included}) * $line{quantity};
157
157
158
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
158
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
159
    $line{suggestionid}         = $suggestion->{suggestionid};
159
    $line{suggestionid}         = $suggestion->{suggestionid};
Lines 172-178 for my $order ( @orders ) { Link Here
172
    my $budget_name = GetBudgetName( $line{budget_id} );
172
    my $budget_name = GetBudgetName( $line{budget_id} );
173
    $line{budget_name} = $budget_name;
173
    $line{budget_name} = $budget_name;
174
174
175
    $subtotal_for_funds->{ $line{budget_name} }{ecost} += $order->{ecost} * $order->{quantity};
175
    $subtotal_for_funds->{ $line{budget_name} }{ecost} += get_rounded_price($order->{ecost}) * $order->{quantity};
176
    $subtotal_for_funds->{ $line{budget_name} }{unitprice} += $order->{total};
176
    $subtotal_for_funds->{ $line{budget_name} }{unitprice} += $order->{total};
177
177
178
    push @loop_received, \%line;
178
    push @loop_received, \%line;
Lines 230-236 unless( defined $invoice->{closedate} ) { Link Here
230
        } else {
230
        } else {
231
            $order->{ecost} = $order->{ecost_tax_excluded};
231
            $order->{ecost} = $order->{ecost_tax_excluded};
232
        }
232
        }
233
        $order->{total} = $order->{ecost} * $order->{quantity};
233
        $order->{total} = get_rounded_price($order->{ecost}) * $order->{quantity};
234
234
235
        my %line = %$order;
235
        my %line = %$order;
236
236
(-)a/acqui/pdfformat/layout3pages.pm (-3 / +4 lines)
Lines 28-33 use List::MoreUtils qw/uniq/; Link Here
28
use Modern::Perl;
28
use Modern::Perl;
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;
Lines 221-229 sub printbaskets { Link Here
221
            $total_tax_excluded += $ord->{total_tax_excluded};
222
            $total_tax_excluded += $ord->{total_tax_excluded};
222
            $total_tax_included += $ord->{total_tax_included};
223
            $total_tax_included += $ord->{total_tax_included};
223
            $totaltax_value += $ord->{tax_value};
224
            $totaltax_value += $ord->{tax_value};
224
            $totaldiscount += ($ord->{rrp_tax_excluded} - $ord->{ecost_tax_excluded} ) * $ord->{quantity};
225
            $totaldiscount += (get_rounded_price($ord->{rrp_tax_excluded}) - get_rounded_price($ord->{ecost_tax_excluded}) ) * $ord->{quantity};
225
            $total_rrp_tax_excluded += $ord->{rrp_tax_excluded} * $ord->{quantity};
226
            $total_rrp_tax_excluded += get_rounded_price($ord->{rrp_tax_excluded}) * $ord->{quantity};
226
            $total_rrp_tax_included += $ord->{rrp_tax_included} * $ord->{quantity};
227
            $total_rrp_tax_included += get_rounded_price($ord->{rrp_tax_included}) * $ord->{quantity};
227
            push @gst, $ord->{tax_rate};
228
            push @gst, $ord->{tax_rate};
228
        }
229
        }
229
        @gst = uniq map { $_ * 100 } @gst;
230
        @gst = uniq map { $_ * 100 } @gst;
(-)a/acqui/pdfformat/layout3pagesfr.pm (+1 lines)
Lines 27-32 use List::MoreUtils qw/uniq/; Link Here
27
use Modern::Perl;
27
use Modern::Perl;
28
use utf8;
28
use utf8;
29
29
30
use C4::Acquisition;
30
use Koha::Number::Price;
31
use Koha::Number::Price;
31
use Koha::DateUtils;
32
use Koha::DateUtils;
32
use Koha::Libraries;
33
use Koha::Libraries;
(-)a/acqui/spent.pl (-1 / +1 lines)
Lines 91-97 my @spent; Link Here
91
while ( my $data = $sth->fetchrow_hashref ) {
91
while ( my $data = $sth->fetchrow_hashref ) {
92
    my $recv = $data->{'quantityreceived'};
92
    my $recv = $data->{'quantityreceived'};
93
    if ( $recv > 0 ) {
93
    if ( $recv > 0 ) {
94
        my $rowtotal = $recv * $data->{'unitprice'};
94
        my $rowtotal = $recv * get_rounded_price($data->{'unitprice'});
95
        $data->{'rowtotal'}  = sprintf( "%.2f", $rowtotal );
95
        $data->{'rowtotal'}  = sprintf( "%.2f", $rowtotal );
96
        $data->{'unitprice'} = sprintf( "%.2f", $data->{'unitprice'} );
96
        $data->{'unitprice'} = sprintf( "%.2f", $data->{'unitprice'} );
97
        $subtotal += $rowtotal;
97
        $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