From 0e83d54de99fbb7e0ab6471eb2c70db9a0b53466 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 26 Oct 2018 12:52:36 +0200 Subject: [PATCH] PTC: Fehlerhafte ungerundete Berechnung von grossamount MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Bei Rechnungen mit sehr vielen sehr kleinen Positionen wurde die Rundungsfehlerakkumulation _nur_ in den finalen netamounts berücksichtigt, nicht aber in den daraus berechneten grossamounts was zu Cent-Abweichungen geführt hat. (cherry picked from commit 061180a3a9cd5ddffc5d9b40fc1751653fc8ef09) --- SL/DB/Helper/PriceTaxCalculator.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SL/DB/Helper/PriceTaxCalculator.pm b/SL/DB/Helper/PriceTaxCalculator.pm index e1db34039..80c804728 100644 --- a/SL/DB/Helper/PriceTaxCalculator.pm +++ b/SL/DB/Helper/PriceTaxCalculator.pm @@ -145,8 +145,6 @@ sub _calculate_item { die "tax_amount != 0 but no chart_id for taxkey " . $taxkey->id . " tax " . $taxkey->tax->id; } - $self->netamount($self->netamount + $sellprice * (1 - $item->discount) * $item->qty / $item->price_factor); - my $chart = $part->get_chart(type => $data->{is_sales} ? 'income' : 'expense', taxzone => $self->taxzone_id); $data->{amounts}->{ $chart->id } ||= { taxkey => $taxkey->taxkey_id, tax_id => $taxkey->tax_id, amount => 0 }; $data->{amounts}->{ $chart->id }->{amount} += $linetotal; @@ -187,6 +185,8 @@ sub _calculate_amounts { $data->{taxes}->{$chart_id} = $rounded; } + $self->netamount(sum map { $_->{amount} } values %{ $data->{amounts} }); + my $amount = _round(($self->netamount + $tax_diff) * $data->{exchangerate}, 2); my $diff = $amount - ($self->netamount + $tax_diff) * $data->{exchangerate}; my $netamount = $amount; -- 2.20.1