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

(-)a/C4/Acquisition.pm (-8 / +41 lines)
Lines 92-97 BEGIN { Link Here
92
        &NotifyOrderUsers
92
        &NotifyOrderUsers
93
93
94
        &FillWithDefaultValues
94
        &FillWithDefaultValues
95
96
        &get_rounded_price
95
    );
97
    );
96
}
98
}
97
99
Lines 1460-1467 sub ModReceiveOrder { Link Here
1460
        $dbh->do(q|
1462
        $dbh->do(q|
1461
            UPDATE aqorders
1463
            UPDATE aqorders
1462
            SET
1464
            SET
1463
                tax_value_on_ordering = quantity * ecost_tax_excluded * tax_rate_on_ordering,
1465
                tax_value_on_ordering = quantity * | . _get_rounding_sql(q|ecost_tax_excluded|) . q| * tax_rate_on_ordering,
1464
                tax_value_on_receiving = quantity * unitprice_tax_excluded * tax_rate_on_receiving
1466
                tax_value_on_receiving = quantity * | . _get_rounding_sql(q|unitprice_tax_excluded|) . q| * tax_rate_on_receiving
1465
            WHERE ordernumber = ?
1467
            WHERE ordernumber = ?
1466
        |, undef, $order->{ordernumber});
1468
        |, undef, $order->{ordernumber});
1467
1469
Lines 1473-1480 sub ModReceiveOrder { Link Here
1473
        $order->{tax_rate_on_ordering} //= 0;
1475
        $order->{tax_rate_on_ordering} //= 0;
1474
        $order->{unitprice_tax_excluded} //= 0;
1476
        $order->{unitprice_tax_excluded} //= 0;
1475
        $order->{tax_rate_on_receiving} //= 0;
1477
        $order->{tax_rate_on_receiving} //= 0;
1476
        $order->{tax_value_on_ordering} = $order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate_on_ordering};
1478
        $order->{tax_value_on_ordering} = $order->{quantity} * get_rounded_price($order->{ecost_tax_excluded}) * $order->{tax_rate_on_ordering};
1477
        $order->{tax_value_on_receiving} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate_on_receiving};
1479
        $order->{tax_value_on_receiving} = $order->{quantity} * get_rounded_price($order->{unitprice_tax_excluded}) * $order->{tax_rate_on_receiving};
1478
        $order->{datereceived} = $datereceived;
1480
        $order->{datereceived} = $datereceived;
1479
        $order->{invoiceid} = $invoice->{invoiceid};
1481
        $order->{invoiceid} = $invoice->{invoiceid};
1480
        $order->{orderstatus} = 'complete';
1482
        $order->{orderstatus} = 'complete';
Lines 1644-1651 sub CancelReceipt { Link Here
1644
        $dbh->do(q|
1646
        $dbh->do(q|
1645
            UPDATE aqorders
1647
            UPDATE aqorders
1646
            SET
1648
            SET
1647
                tax_value_on_ordering = quantity * ecost_tax_excluded * tax_rate_on_ordering,
1649
                tax_value_on_ordering = quantity * | . _get_rounding_sql(q|ecost_tax_excluded|) . q| * tax_rate_on_ordering,
1648
                tax_value_on_receiving = quantity * unitprice_tax_excluded * tax_rate_on_receiving
1650
                tax_value_on_receiving = quantity * | . _get_rounding_sql(q|unitprice_tax_excluded|) . q| * tax_rate_on_receiving
1649
            WHERE ordernumber = ?
1651
            WHERE ordernumber = ?
1650
        |, undef, $parent_ordernumber);
1652
        |, undef, $parent_ordernumber);
1651
1653
Lines 1997-2002 sub TransferOrder { Link Here
1997
    return $newordernumber;
1999
    return $newordernumber;
1998
}
2000
}
1999
2001
2002
=head3 _get_rounding_sql
2003
2004
    $rounding_sql = _get_rounding_sql("mysql_variable_to_round_string");
2005
2006
returns the correct SQL routine based on OrderPriceRounding system preference.
2007
2008
=cut
2009
2010
sub _get_rounding_sql {
2011
    my ( $round_string ) = @_;
2012
    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
2013
    if ( $rounding_pref eq "nearest_cent"  ) { return ("CAST($round_string*100 AS INTEGER)/100"); }
2014
    else                                     { return ("$round_string"); }
2015
}
2016
2017
=head3 get_rounded_price
2018
2019
    $rounded_price = get_rounded_price( $price );
2020
2021
returns a price rounded as specified in OrderPriceRounding system preference.
2022
2023
=cut
2024
2025
sub get_rounded_price {
2026
    my ( $price ) =  @_;
2027
    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
2028
    if( $rounding_pref eq 'nearest_cent' ) { return Koha::Number::Price->new( $price )->format(); }
2029
    else                                   { return $price; }
2030
}
2031
2032
2000
=head2 FUNCTIONS ABOUT PARCELS
2033
=head2 FUNCTIONS ABOUT PARCELS
2001
2034
2002
=head3 GetParcels
2035
=head3 GetParcels
Lines 3002-3008 sub populate_order_with_prices { Link Here
3002
3035
3003
        # tax value = quantity * ecost tax excluded * tax rate
3036
        # tax value = quantity * ecost tax excluded * tax rate
3004
        $order->{tax_value_on_ordering} =
3037
        $order->{tax_value_on_ordering} =
3005
            $order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate_on_ordering};
3038
            $order->{quantity} * get_rounded_price($order->{ecost_tax_excluded}) * $order->{tax_rate_on_ordering};
3006
    }
3039
    }
3007
3040
3008
    if ($receiving) {
3041
    if ($receiving) {
Lines 3036-3042 sub populate_order_with_prices { Link Here
3036
        }
3069
        }
3037
3070
3038
        # tax value = quantity * unit price tax excluded * tax rate
3071
        # tax value = quantity * unit price tax excluded * tax rate
3039
        $order->{tax_value_on_receiving} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate_on_receiving};
3072
        $order->{tax_value_on_receiving} = $order->{quantity} * get_rounded_price($order->{unitprice_tax_excluded}) * $order->{tax_rate_on_receiving};
3040
    }
3073
    }
3041
3074
3042
    return $order;
3075
    return $order;
(-)a/C4/Budgets.pm (-6 / +26 lines)
Lines 211-221 sub GetBudgetsPlanCell { Link Here
211
    my ( $cell, $period, $budget ) = @_;
211
    my ( $cell, $period, $budget ) = @_;
212
    my ($actual, $sth);
212
    my ($actual, $sth);
213
    my $dbh = C4::Context->dbh;
213
    my $dbh = C4::Context->dbh;
214
    my $roundsql = _get_rounding_sql(qq|ecost_tax_included|);
214
    if ( $cell->{'authcat'} eq 'MONTHS' ) {
215
    if ( $cell->{'authcat'} eq 'MONTHS' ) {
215
        # get the actual amount
216
        # get the actual amount
216
        $sth = $dbh->prepare( qq|
217
        $sth = $dbh->prepare( qq|
217
218
218
            SELECT SUM(ecost_tax_included) AS actual FROM aqorders
219
            SELECT SUM(| .  $roundsql . qq|) AS actual FROM aqorders
219
                WHERE    budget_id = ? AND
220
                WHERE    budget_id = ? AND
220
                entrydate like "$cell->{'authvalue'}%"  |
221
                entrydate like "$cell->{'authvalue'}%"  |
221
        );
222
        );
Lines 224-230 sub GetBudgetsPlanCell { Link Here
224
        # get the actual amount
225
        # get the actual amount
225
        $sth = $dbh->prepare( qq|
226
        $sth = $dbh->prepare( qq|
226
227
227
            SELECT SUM(ecost_tax_included) FROM aqorders
228
            SELECT SUM(| . $roundsql . qq|) FROM aqorders
228
                LEFT JOIN aqorders_items
229
                LEFT JOIN aqorders_items
229
                ON (aqorders.ordernumber = aqorders_items.ordernumber)
230
                ON (aqorders.ordernumber = aqorders_items.ordernumber)
230
                LEFT JOIN items
231
                LEFT JOIN items
Lines 236-242 sub GetBudgetsPlanCell { Link Here
236
        # get the actual amount
237
        # get the actual amount
237
        $sth = $dbh->prepare(  qq|
238
        $sth = $dbh->prepare(  qq|
238
239
239
            SELECT SUM( ecost_tax_included *  quantity) AS actual
240
            SELECT SUM( | . $roundsql . qq| *  quantity) AS actual
240
                FROM aqorders JOIN biblioitems
241
                FROM aqorders JOIN biblioitems
241
                ON (biblioitems.biblionumber = aqorders.biblionumber )
242
                ON (biblioitems.biblionumber = aqorders.biblionumber )
242
                WHERE aqorders.budget_id = ? and itemtype  = ? |
243
                WHERE aqorders.budget_id = ? and itemtype  = ? |
Lines 249-255 sub GetBudgetsPlanCell { Link Here
249
        # get the actual amount
250
        # get the actual amount
250
        $sth = $dbh->prepare( qq|
251
        $sth = $dbh->prepare( qq|
251
252
252
        SELECT  SUM(ecost_tax_included * quantity) AS actual
253
        SELECT  SUM(| . $roundsql . qq| * quantity) AS actual
253
            FROM aqorders
254
            FROM aqorders
254
            JOIN aqbudgets ON (aqbudgets.budget_id = aqorders.budget_id )
255
            JOIN aqbudgets ON (aqbudgets.budget_id = aqorders.budget_id )
255
            WHERE  aqorders.budget_id = ? AND
256
            WHERE  aqorders.budget_id = ? AND
Lines 333-339 sub GetBudgetSpent { Link Here
333
    # unitprice_tax_included should always been set here
334
    # unitprice_tax_included should always been set here
334
    # we should not need to retrieve ecost_tax_included
335
    # we should not need to retrieve ecost_tax_included
335
    my $sth = $dbh->prepare(qq|
336
    my $sth = $dbh->prepare(qq|
336
        SELECT SUM( COALESCE(unitprice_tax_included, ecost_tax_included) * quantity ) AS sum FROM aqorders
337
        SELECT SUM( | . _get_rounding_sql("COALESCE(unitprice_tax_included, ecost_tax_included)") . qq| * quantity ) AS sum FROM aqorders
337
            WHERE budget_id = ? AND
338
            WHERE budget_id = ? AND
338
            quantityreceived > 0 AND
339
            quantityreceived > 0 AND
339
            datecancellationprinted IS NULL
340
            datecancellationprinted IS NULL
Lines 364-370 sub GetBudgetOrdered { Link Here
364
	my ($budget_id) = @_;
365
	my ($budget_id) = @_;
365
	my $dbh = C4::Context->dbh;
366
	my $dbh = C4::Context->dbh;
366
	my $sth = $dbh->prepare(qq|
367
	my $sth = $dbh->prepare(qq|
367
        SELECT SUM(ecost_tax_included *  quantity) AS sum FROM aqorders
368
        SELECT SUM(| . _get_rounding_sql(qq|ecost_tax_included|) . qq| *  quantity) AS sum FROM aqorders
368
            WHERE budget_id = ? AND
369
            WHERE budget_id = ? AND
369
            quantityreceived = 0 AND
370
            quantityreceived = 0 AND
370
            datecancellationprinted IS NULL
371
            datecancellationprinted IS NULL
Lines 1346-1351 sub MoveOrders { Link Here
1346
    return \@report;
1347
    return \@report;
1347
}
1348
}
1348
1349
1350
=head1 INTERNAL FUNCTIONS
1351
1352
=cut
1353
1354
=head3 _get_rounding_sql
1355
1356
    $rounding_sql = _get_rounding_sql("mysql_variable_to_round_string");
1357
1358
returns the correct SQL routine based on OrderPriceRounding system preference.
1359
1360
=cut
1361
1362
sub _get_rounding_sql {
1363
    my $to_round = shift;
1364
    my $rounding_pref = C4::Context->preference('OrderPriceRounding');
1365
    if   ($rounding_pref eq 'nearest_cent') { return "CAST($to_round*100 AS INTEGER)/100"; }
1366
    else { return "$to_round"; }
1367
}
1368
1349
END { }    # module clean-up code here (global destructor)
1369
END { }    # module clean-up code here (global destructor)
1350
1370
1351
1;
1371
1;
(-)a/Koha/pdfformat/layout3pages.pm (-3 / +4 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;
Lines 220-228 sub printbaskets { Link Here
220
            $total_tax_excluded += $ord->{total_tax_excluded};
221
            $total_tax_excluded += $ord->{total_tax_excluded};
221
            $total_tax_included += $ord->{total_tax_included};
222
            $total_tax_included += $ord->{total_tax_included};
222
            $totaltax_value += $ord->{tax_value};
223
            $totaltax_value += $ord->{tax_value};
223
            $totaldiscount += ($ord->{rrp_tax_excluded} - $ord->{ecost_tax_excluded} ) * $ord->{quantity};
224
            $totaldiscount += (get_rounded_price($ord->{rrp_tax_excluded}) - get_rounded_price($ord->{ecost_tax_excluded}) ) * $ord->{quantity};
224
            $total_rrp_tax_excluded += $ord->{rrp_tax_excluded} * $ord->{quantity};
225
            $total_rrp_tax_excluded += get_rounded_price($ord->{rrp_tax_excluded}) * $ord->{quantity};
225
            $total_rrp_tax_included += $ord->{rrp_tax_included} * $ord->{quantity};
226
            $total_rrp_tax_included += get_rounded_price($ord->{rrp_tax_included}) * $ord->{quantity};
226
            push @gst, $ord->{tax_rate};
227
            push @gst, $ord->{tax_rate};
227
        }
228
        }
228
        @gst = uniq map { $_ * 100 } @gst;
229
        @gst = uniq map { $_ * 100 } @gst;
(-)a/Koha/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/basket.pl (-4 / +4 lines)
Lines 347-355 if ( $op eq 'list' ) { Link Here
347
        push @books_loop, $line;
347
        push @books_loop, $line;
348
348
349
        $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
349
        $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
350
        $foot{$$line{tax_rate}}{tax_value} += $$line{tax_value};
350
        $foot{$$line{tax_rate}}{tax_value} += get_rounded_price($$line{tax_value});
351
        $total_tax_value += $$line{tax_value};
351
        $total_tax_value += $$line{tax_value};
352
        $foot{$$line{tax_rate}}{quantity}  += $$line{quantity};
352
        $foot{$$line{tax_rate}}{quantity}  += get_rounded_price($$line{quantity});
353
        $total_quantity += $$line{quantity};
353
        $total_quantity += $$line{quantity};
354
        $foot{$$line{tax_rate}}{total_tax_excluded} += $$line{total_tax_excluded};
354
        $foot{$$line{tax_rate}}{total_tax_excluded} += $$line{total_tax_excluded};
355
        $total_tax_excluded += $$line{total_tax_excluded};
355
        $total_tax_excluded += $$line{total_tax_excluded};
Lines 452-459 sub get_order_infos { Link Here
452
    $line{basketno}       = $basketno;
452
    $line{basketno}       = $basketno;
453
    $line{budget_name}    = $budget->{budget_name};
453
    $line{budget_name}    = $budget->{budget_name};
454
454
455
    $line{total_tax_included} = $line{ecost_tax_included} * $line{quantity};
455
    $line{total_tax_included} = get_rounded_price($line{ecost_tax_included}) * $line{quantity};
456
    $line{total_tax_excluded} = $line{ecost_tax_excluded} * $line{quantity};
456
    $line{total_tax_excluded} = get_rounded_price($line{ecost_tax_excluded}) * $line{quantity};
457
    $line{tax_value} = $line{tax_value_on_ordering};
457
    $line{tax_value} = $line{tax_value_on_ordering};
458
    $line{tax_rate} = $line{tax_rate_on_ordering};
458
    $line{tax_rate} = $line{tax_rate_on_ordering};
459
459
(-)a/acqui/basketgroup.pl (-5 / +5 lines)
Lines 51-57 use C4::Output; Link Here
51
use CGI qw ( -utf8 );
51
use CGI qw ( -utf8 );
52
use File::Spec;
52
use File::Spec;
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
    return $total;
86
    return $total;
Lines 169-176 sub printbasketgrouppdf{ Link Here
169
169
170
            $ord->{tax_value} = $ord->{tax_value_on_ordering};
170
            $ord->{tax_value} = $ord->{tax_value_on_ordering};
171
            $ord->{tax_rate} = $ord->{tax_rate_on_ordering};
171
            $ord->{tax_rate} = $ord->{tax_rate_on_ordering};
172
            $ord->{total_tax_included} = $ord->{ecost_tax_included} * $ord->{quantity};
172
            $ord->{total_tax_included} = get_rounded_price($ord->{ecost_tax_included}) * $ord->{quantity};
173
            $ord->{total_tax_excluded} = $ord->{ecost_tax_excluded} * $ord->{quantity};
173
            $ord->{total_tax_excluded} = get_rounded_price($ord->{ecost_tax_excluded}) * $ord->{quantity};
174
174
175
            my $biblioitem = Koha::Biblioitems->search({ biblionumber => $ord->{biblionumber} })->next;
175
            my $biblioitem = Koha::Biblioitems->search({ biblionumber => $ord->{biblionumber} })->next;
176
176
(-)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 92-98 while ( my $data = $sth->fetchrow_hashref ) { Link Here
92
        $left = $data->{'quantity'};
93
        $left = $data->{'quantity'};
93
    }
94
    }
94
    if ( $left && $left > 0 ) {
95
    if ( $left && $left > 0 ) {
95
        my $subtotal = $left * $data->{'ecost_tax_included'};
96
        my $subtotal = $left * get_rounded_price($data->{'ecost_tax_included'});
96
        $data->{subtotal} = sprintf( "%.2f", $subtotal );
97
        $data->{subtotal} = sprintf( "%.2f", $subtotal );
97
        $data->{'left'} = $left;
98
        $data->{'left'} = $left;
98
        push @ordered, $data;
99
        push @ordered, $data;
(-)a/acqui/parcel.pl (-5 / +5 lines)
Lines 136-142 for my $order ( @orders ) { Link Here
136
        $order->{unitprice} = $order->{unitprice_tax_excluded};
136
        $order->{unitprice} = $order->{unitprice_tax_excluded};
137
    }
137
    }
138
138
139
    $order->{total} = $order->{unitprice} * $order->{quantity};
139
    $order->{total} = get_rounded_price($order->{unitprice}) * $order->{quantity};
140
140
141
    my %line = %{ $order };
141
    my %line = %{ $order };
142
    $line{invoice} = $invoice->{invoicenumber};
142
    $line{invoice} = $invoice->{invoicenumber};
Lines 154-161 for my $order ( @orders ) { Link Here
154
    $line{tax_rate} = $line{tax_rate_on_receiving};
154
    $line{tax_rate} = $line{tax_rate_on_receiving};
155
    $foot{$line{tax_rate}}{tax_rate} = $line{tax_rate};
155
    $foot{$line{tax_rate}}{tax_rate} = $line{tax_rate};
156
    $foot{$line{tax_rate}}{tax_value} += $line{tax_value};
156
    $foot{$line{tax_rate}}{tax_value} += $line{tax_value};
157
    $total_tax_excluded += $line{unitprice_tax_excluded} * $line{quantity};
157
    $total_tax_excluded += get_rounded_price($line{unitprice_tax_excluded}) * $line{quantity};
158
    $total_tax_included += $line{unitprice_tax_included} * $line{quantity};
158
    $total_tax_included += get_rounded_price($line{unitprice_tax_included}) * $line{quantity};
159
159
160
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
160
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
161
    $line{suggestionid}         = $suggestion->{suggestionid};
161
    $line{suggestionid}         = $suggestion->{suggestionid};
Lines 174-180 for my $order ( @orders ) { Link Here
174
    my $budget_name = GetBudgetName( $line{budget_id} );
174
    my $budget_name = GetBudgetName( $line{budget_id} );
175
    $line{budget_name} = $budget_name;
175
    $line{budget_name} = $budget_name;
176
176
177
    $subtotal_for_funds->{ $line{budget_name} }{ecost} += $order->{ecost} * $order->{quantity};
177
    $subtotal_for_funds->{ $line{budget_name} }{ecost} += get_rounded_price($order->{ecost}) * $order->{quantity};
178
    $subtotal_for_funds->{ $line{budget_name} }{unitprice} += $order->{total};
178
    $subtotal_for_funds->{ $line{budget_name} }{unitprice} += $order->{total};
179
179
180
    push @loop_received, \%line;
180
    push @loop_received, \%line;
Lines 232-238 unless( defined $invoice->{closedate} ) { Link Here
232
        } else {
232
        } else {
233
            $order->{ecost} = $order->{ecost_tax_excluded};
233
            $order->{ecost} = $order->{ecost_tax_excluded};
234
        }
234
        }
235
        $order->{total} = $order->{ecost} * $order->{quantity};
235
        $order->{total} = get_rounded_price($order->{ecost}) * $order->{quantity};
236
236
237
        my %line = %$order;
237
        my %line = %$order;
238
238
(-)a/acqui/spent.pl (-1 / +1 lines)
Lines 95-101 my @spent; Link Here
95
while ( my $data = $sth->fetchrow_hashref ) {
95
while ( my $data = $sth->fetchrow_hashref ) {
96
    my $recv = $data->{'quantityreceived'};
96
    my $recv = $data->{'quantityreceived'};
97
    if ( $recv > 0 ) {
97
    if ( $recv > 0 ) {
98
        my $rowtotal = $recv * $data->{'unitprice_tax_included'};
98
        my $rowtotal = $recv * get_rounded_price($data->{'unitprice_tax_included'});
99
        $data->{'rowtotal'}  = sprintf( "%.2f", $rowtotal );
99
        $data->{'rowtotal'}  = sprintf( "%.2f", $rowtotal );
100
        $data->{'unitprice_tax_included'} = sprintf( "%.2f", $data->{'unitprice_tax_included'} );
100
        $data->{'unitprice_tax_included'} = sprintf( "%.2f", $data->{'unitprice_tax_included'} );
101
        $subtotal += $rowtotal;
101
        $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