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

(-)a/C4/Acquisition.pm (-8 / +41 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 ("CAST($round_string*100 AS INTEGER)/100"); }
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 3000-3006 sub populate_order_with_prices { Link Here
3000
3033
3001
        # tax value = quantity * ecost tax excluded * tax rate
3034
        # tax value = quantity * ecost tax excluded * tax rate
3002
        $order->{tax_value_on_ordering} =
3035
        $order->{tax_value_on_ordering} =
3003
            $order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate_on_ordering};
3036
            $order->{quantity} * get_rounded_price($order->{ecost_tax_excluded}) * $order->{tax_rate_on_ordering};
3004
    }
3037
    }
3005
3038
3006
    if ($receiving) {
3039
    if ($receiving) {
Lines 3034-3040 sub populate_order_with_prices { Link Here
3034
        }
3067
        }
3035
3068
3036
        # tax value = quantity * unit price tax excluded * tax rate
3069
        # 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};
3070
        $order->{tax_value_on_receiving} = $order->{quantity} * get_rounded_price($order->{unitprice_tax_excluded}) * $order->{tax_rate_on_receiving};
3038
    }
3071
    }
3039
3072
3040
    return $order;
3073
    return $order;
(-)a/C4/Budgets.pm (-6 / +26 lines)
Lines 210-220 sub GetBudgetsPlanCell { Link Here
210
    my ( $cell, $period, $budget ) = @_;
210
    my ( $cell, $period, $budget ) = @_;
211
    my ($actual, $sth);
211
    my ($actual, $sth);
212
    my $dbh = C4::Context->dbh;
212
    my $dbh = C4::Context->dbh;
213
    my $roundsql = _get_rounding_sql(qq|ecost_tax_included|);
213
    if ( $cell->{'authcat'} eq 'MONTHS' ) {
214
    if ( $cell->{'authcat'} eq 'MONTHS' ) {
214
        # get the actual amount
215
        # get the actual amount
215
        $sth = $dbh->prepare( qq|
216
        $sth = $dbh->prepare( qq|
216
217
217
            SELECT SUM(ecost_tax_included) AS actual FROM aqorders
218
            SELECT SUM(| .  $roundsql . qq|) AS actual FROM aqorders
218
                WHERE    budget_id = ? AND
219
                WHERE    budget_id = ? AND
219
                entrydate like "$cell->{'authvalue'}%"  |
220
                entrydate like "$cell->{'authvalue'}%"  |
220
        );
221
        );
Lines 223-229 sub GetBudgetsPlanCell { Link Here
223
        # get the actual amount
224
        # get the actual amount
224
        $sth = $dbh->prepare( qq|
225
        $sth = $dbh->prepare( qq|
225
226
226
            SELECT SUM(ecost_tax_included) FROM aqorders
227
            SELECT SUM(| . $roundsql . qq|) FROM aqorders
227
                LEFT JOIN aqorders_items
228
                LEFT JOIN aqorders_items
228
                ON (aqorders.ordernumber = aqorders_items.ordernumber)
229
                ON (aqorders.ordernumber = aqorders_items.ordernumber)
229
                LEFT JOIN items
230
                LEFT JOIN items
Lines 235-241 sub GetBudgetsPlanCell { Link Here
235
        # get the actual amount
236
        # get the actual amount
236
        $sth = $dbh->prepare(  qq|
237
        $sth = $dbh->prepare(  qq|
237
238
238
            SELECT SUM( ecost_tax_included *  quantity) AS actual
239
            SELECT SUM( | . $roundsql . qq| *  quantity) AS actual
239
                FROM aqorders JOIN biblioitems
240
                FROM aqorders JOIN biblioitems
240
                ON (biblioitems.biblionumber = aqorders.biblionumber )
241
                ON (biblioitems.biblionumber = aqorders.biblionumber )
241
                WHERE aqorders.budget_id = ? and itemtype  = ? |
242
                WHERE aqorders.budget_id = ? and itemtype  = ? |
Lines 248-254 sub GetBudgetsPlanCell { Link Here
248
        # get the actual amount
249
        # get the actual amount
249
        $sth = $dbh->prepare( qq|
250
        $sth = $dbh->prepare( qq|
250
251
251
        SELECT  SUM(ecost_tax_included * quantity) AS actual
252
        SELECT  SUM(| . $roundsql . qq| * quantity) AS actual
252
            FROM aqorders
253
            FROM aqorders
253
            JOIN aqbudgets ON (aqbudgets.budget_id = aqorders.budget_id )
254
            JOIN aqbudgets ON (aqbudgets.budget_id = aqorders.budget_id )
254
            WHERE  aqorders.budget_id = ? AND
255
            WHERE  aqorders.budget_id = ? AND
Lines 332-338 sub GetBudgetSpent { Link Here
332
    # unitprice_tax_included should always been set here
333
    # unitprice_tax_included should always been set here
333
    # we should not need to retrieve ecost_tax_included
334
    # we should not need to retrieve ecost_tax_included
334
    my $sth = $dbh->prepare(qq|
335
    my $sth = $dbh->prepare(qq|
335
        SELECT SUM( COALESCE(unitprice_tax_included, ecost_tax_included) * quantity ) AS sum FROM aqorders
336
        SELECT SUM( | . _get_rounding_sql("COALESCE(unitprice_tax_included, ecost_tax_included)") . qq| * quantity ) AS sum FROM aqorders
336
            WHERE budget_id = ? AND
337
            WHERE budget_id = ? AND
337
            quantityreceived > 0 AND
338
            quantityreceived > 0 AND
338
            datecancellationprinted IS NULL
339
            datecancellationprinted IS NULL
Lines 363-369 sub GetBudgetOrdered { Link Here
363
	my ($budget_id) = @_;
364
	my ($budget_id) = @_;
364
	my $dbh = C4::Context->dbh;
365
	my $dbh = C4::Context->dbh;
365
	my $sth = $dbh->prepare(qq|
366
	my $sth = $dbh->prepare(qq|
366
        SELECT SUM(ecost_tax_included *  quantity) AS sum FROM aqorders
367
        SELECT SUM(| . _get_rounding_sql(qq|ecost_tax_included|) . qq| *  quantity) AS sum FROM aqorders
367
            WHERE budget_id = ? AND
368
            WHERE budget_id = ? AND
368
            quantityreceived = 0 AND
369
            quantityreceived = 0 AND
369
            datecancellationprinted IS NULL
370
            datecancellationprinted IS NULL
Lines 1340-1345 sub MoveOrders { Link Here
1340
    return \@report;
1341
    return \@report;
1341
}
1342
}
1342
1343
1344
=head1 INTERNAL FUNCTIONS
1345
1346
=cut
1347
1348
=head3 _get_rounding_sql
1349
1350
    $rounding_sql = _get_rounding_sql("mysql_variable_to_round_string");
1351
1352
returns the correct SQL routine based on OrderPriceRounding system preference.
1353
1354
=cut
1355
1356
sub _get_rounding_sql {
1357
    my $to_round = shift;
1358
    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
1359
    if   ($rounding_pref eq 'nearest_cent') { return "CAST($to_round*100 AS INTEGER)/100"; }
1360
    else { return "$to_round"; }
1361
}
1362
1343
END { }    # module clean-up code here (global destructor)
1363
END { }    # module clean-up code here (global destructor)
1344
1364
1345
1;
1365
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 165-185 my $total_tax_value = 0; Link Here
165
foreach my $order (@$orders) {
165
foreach my $order (@$orders) {
166
    my $line = get_infos( $order, $bookseller);
166
    my $line = get_infos( $order, $bookseller);
167
167
168
    $line->{total_tax_excluded} = $line->{unitprice_tax_excluded} * $line->{quantity};
168
    $line->{total_tax_excluded} = get_rounded_price($line->{unitprice_tax_excluded}) * $line->{quantity};
169
    $line->{total_tax_included} = $line->{unitprice_tax_included} * $line->{quantity};
169
    $line->{total_tax_included} = get_rounded_price($line->{unitprice_tax_included}) * $line->{quantity};
170
170
171
    $line->{tax_value} = $line->{tax_value_on_receiving};
171
    $line->{tax_value} = $line->{tax_value_on_receiving};
172
    $line->{tax_rate} = $line->{tax_rate_on_receiving};
172
    $line->{tax_rate} = $line->{tax_rate_on_receiving};
173
173
174
    $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
174
    $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
175
    $foot{$$line{tax_rate}}{tax_value} += $$line{tax_value};
175
    $foot{$$line{tax_rate}}{tax_value} += get_rounded_price($$line{tax_value});
176
    $total_tax_value += $$line{tax_value};
176
    $total_tax_value += $$line{tax_value};
177
    $foot{$$line{tax_rate}}{quantity}  += $$line{quantity};
177
    $foot{$$line{tax_rate}}{quantity}  += $$line{quantity};
178
    $total_quantity += $$line{quantity};
178
    $total_quantity += $$line{quantity};
179
    $foot{$$line{tax_rate}}{total_tax_excluded} += $$line{total_tax_excluded};
179
    $foot{$$line{tax_rate}}{total_tax_excluded} += get_rounded_price($$line{total_tax_excluded});
180
    $total_tax_excluded += $$line{total_tax_excluded};
180
    $total_tax_excluded += get_rounded_price($$line{total_tax_excluded});
181
    $foot{$$line{tax_rate}}{total_tax_included} += $$line{total_tax_included};
181
    $foot{$$line{tax_rate}}{total_tax_included} += get_rounded_price($$line{total_tax_included});
182
    $total_tax_included += $$line{total_tax_included};
182
    $total_tax_included += get_rounded_price($$line{total_tax_included});
183
183
184
    $line->{orderline} = $line->{parent_ordernumber};
184
    $line->{orderline} = $line->{parent_ordernumber};
185
    push @orders_loop, $line;
185
    push @orders_loop, $line;
(-)a/acqui/ordered.pl (-1 / +2 lines)
Lines 33-38 use CGI qw ( -utf8 ); Link Here
33
use C4::Auth;
33
use C4::Auth;
34
use C4::Output;
34
use C4::Output;
35
use Koha::Acquisition::Invoice::Adjustments;
35
use Koha::Acquisition::Invoice::Adjustments;
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 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 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/installer/data/mysql/atomicupdate/bug18736_add_rounding_syspref.perl (-1 / +1 lines)
Lines 1-6 Link Here
1
$DBversion = 'XXX';  # will be replaced by the RM
1
$DBversion = 'XXX';  # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
2
if( CheckVersion( $DBversion ) ) {
3
    # $dbh->do( "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OrderPriceRounding',NULL,'Local preference for rounding orders before calculations to ensure correct calculations','|nearest_cent','Choice')" );
3
    $dbh->do( "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('OrderPriceRounding',NULL,'Local preference for rounding orders before calculations to ensure correct calculations','|nearest_cent','Choice')" );
4
4
5
    SetVersion( $DBversion );
5
    SetVersion( $DBversion );
6
    print "Upgrade to $DBversion done (Bug 18736 - Add syspref to control order rounding)\n";
6
    print "Upgrade to $DBversion done (Bug 18736 - Add syspref to control order rounding)\n";
(-)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