X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FHelper%2FPriceTaxCalculator.pm;h=2478292a4245bbfe4dd3cc748914cebf66eb55e7;hb=2da5d610ce0aeb43428de82e6b5e79acfb502628;hp=e4a91807ba60adeccc176eb5fd05a001033b6b67;hpb=a34ae1630d888a6c824dad13db000bd7e0e1c3e6;p=kivitendo-erp.git diff --git a/SL/DB/Helper/PriceTaxCalculator.pm b/SL/DB/Helper/PriceTaxCalculator.pm index e4a91807b..2478292a4 100644 --- a/SL/DB/Helper/PriceTaxCalculator.pm +++ b/SL/DB/Helper/PriceTaxCalculator.pm @@ -90,13 +90,14 @@ sub _calculate_item { $item->marge_percent(0); } else { - my $lastcost = ! ($item->lastcost * 1) ? ($item->part->lastcost || 0) : $item->lastcost; + my $lastcost = ! ($item->lastcost * 1) ? ($item->part->lastcost || 0) : $item->lastcost; + my $linetotal_cost = _round($lastcost * $item->qty / $item->marge_price_factor, 2); - $item->marge_total( $linetotal - $lastcost / $item->marge_price_factor); + $item->marge_total( $linetotal - $linetotal_cost); $item->marge_percent($item->marge_total * 100 / $linetotal); $self->marge_total( $self->marge_total + $item->marge_total); - $data->{lastcost_total} += $lastcost; + $data->{lastcost_total} += $linetotal_cost; } my $taxkey = $item->part->get_taxkey(date => $self->transdate, is_sales => $data->{is_sales}, taxzone => $self->taxzone_id); @@ -123,6 +124,7 @@ sub _calculate_item { my $chart = $item->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; + $data->{amounts}->{ $chart->id }->{amount} -= $tax_amount if $self->taxincluded; push @{ $data->{assembly_items} }, []; if ($item->part->is_assembly) {