Revision d8d66024
Von Moritz Bunkus vor etwa 10 Jahren hinzugefügt
SL/DB/Helper/PriceTaxCalculator.pm | ||
---|---|---|
37 | 37 |
exchangerate => undef, |
38 | 38 |
is_sales => $self->can('customer') && $self->customer, |
39 | 39 |
is_invoice => (ref($self) =~ /Invoice/) || $params{invoice}, |
40 |
items => { }, |
|
40 | 41 |
); |
41 | 42 |
|
42 | 43 |
_get_exchangerate($self, \%data, %params); |
... | ... | |
94 | 95 |
|
95 | 96 |
$data->{invoicediff} += $sellprice * $item->qty * $data->{exchangerate} / $item->price_factor - $linetotal if $self->taxincluded; |
96 | 97 |
|
98 |
my $linetotal_cost = 0; |
|
99 |
|
|
97 | 100 |
if (!$linetotal) { |
98 | 101 |
$item->marge_total( 0); |
99 | 102 |
$item->marge_percent(0); |
100 | 103 |
|
101 | 104 |
} else { |
102 | 105 |
my $lastcost = ! ($item->lastcost * 1) ? ($part->lastcost || 0) : $item->lastcost; |
103 |
my $linetotal_cost = _round($lastcost * $item->qty / $item->marge_price_factor, 2);
|
|
106 |
$linetotal_cost = _round($lastcost * $item->qty / $item->marge_price_factor, 2);
|
|
104 | 107 |
|
105 | 108 |
$item->marge_total( $linetotal - $linetotal_cost); |
106 | 109 |
$item->marge_percent($item->marge_total * 100 / $linetotal); |
... | ... | |
146 | 149 |
|
147 | 150 |
$data->{last_incex_chart_id} = $chart->id if $data->{is_sales}; |
148 | 151 |
|
152 |
$data->{items}->{ $item->id } = { |
|
153 |
linetotal => $linetotal, |
|
154 |
linetotal_cost => $linetotal_cost, |
|
155 |
sellprice => $sellprice, |
|
156 |
tax_amount => $tax_amount, |
|
157 |
taxkey => $taxkey, |
|
158 |
}; |
|
159 |
|
|
149 | 160 |
_dbg("CALCULATE! ${idx} i.qty " . $item->qty . " i.sellprice " . $item->sellprice . " sellprice $sellprice num_dec $num_dec taxamount $tax_amount " . |
150 | 161 |
"i.linetotal $linetotal netamount " . $self->netamount . " marge_total " . $item->marge_total . " marge_percent " . $item->marge_percent); |
151 | 162 |
} |
... | ... | |
338 | 349 |
|
339 | 350 |
The exchangerate used for the calculation. |
340 | 351 |
|
352 |
=item C<items> |
|
353 |
|
|
354 |
A hashref. For each line item this hashref contains an entry with |
|
355 |
additional values that have been calculated for that item but that |
|
356 |
aren't stored in the item object itself. These include C<linetotal>, |
|
357 |
C<linetotal_cost>, C<sellprice>, C<tax_amount> and C<taxkey>. |
|
358 |
|
|
359 |
The items are hashed by their IDs. |
|
360 |
|
|
341 | 361 |
=back |
342 | 362 |
|
343 | 363 |
=back |
Auch abrufbar als: Unified diff
PriceTaxCalculator: für Items berechnete flüchtige Werte in %data zurückgeben