From: Sven Schöling Date: Fri, 26 Oct 2018 10:52:36 +0000 (+0200) Subject: PTC: Fehlerhafte ungerundete Berechnung von grossamount X-Git-Tag: release-3.5.4~186 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=0e83d54de99fbb7e0ab6471eb2c70db9a0b53466;p=kivitendo-erp.git PTC: Fehlerhafte ungerundete Berechnung von grossamount 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) --- 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;