Revision 46547316
Von Bernd Bleßmann vor mehr als 4 Jahren hinzugefügt
SL/DB/Helper/PriceTaxCalculator.pm | ||
---|---|---|
30 | 30 |
units_by_name => \%units_by_name, |
31 | 31 |
price_factors_by_id => \%price_factors_by_id, |
32 | 32 |
taxes => { }, |
33 |
taxes_by_tax_id => { }, |
|
33 | 34 |
amounts => { }, |
34 | 35 |
amounts_cogs => { }, |
35 | 36 |
allocated => { }, |
... | ... | |
65 | 66 |
|
66 | 67 |
return $self unless wantarray; |
67 | 68 |
|
68 |
return map { ($_ => $data{$_}) } qw(taxes amounts amounts_cogs allocated exchangerate assembly_items items rounding); |
|
69 |
return map { ($_ => $data{$_}) } qw(taxes taxes_by_tax_id amounts amounts_cogs allocated exchangerate assembly_items items rounding);
|
|
69 | 70 |
} |
70 | 71 |
|
71 | 72 |
sub _get_exchangerate { |
... | ... | |
124 | 125 |
if ($taxkey->tax->chart_id) { |
125 | 126 |
$data->{taxes}->{ $taxkey->tax->chart_id } ||= 0; |
126 | 127 |
$data->{taxes}->{ $taxkey->tax->chart_id } += $tax_amount; |
128 |
$data->{taxes_by_tax_id}->{ $taxkey->tax_id } ||= 0; |
|
129 |
$data->{taxes_by_tax_id}->{ $taxkey->tax_id } += $tax_amount; |
|
127 | 130 |
} elsif ($tax_amount) { |
128 | 131 |
die "tax_amount != 0 but no chart_id for taxkey " . $taxkey->id . " tax " . $taxkey->tax->id; |
129 | 132 |
} |
... | ... | |
340 | 343 |
A hash reference with the calculated taxes. The keys are chart IDs, |
341 | 344 |
the values the calculated taxes. |
342 | 345 |
|
346 |
=item C<taxes_by_tax_id> |
|
347 |
|
|
348 |
A hash reference with the calculated taxes. The keys are tax IDs, |
|
349 |
the values the calculated taxes. |
|
350 |
|
|
343 | 351 |
=item C<amounts> |
344 | 352 |
|
345 | 353 |
A hash reference with the calculated amounts. The keys are chart IDs, |
t/db_helper/price_tax_calculator.t | ||
---|---|---|
156 | 156 |
taxes => { |
157 | 157 |
$tax->chart_id => 1.11, |
158 | 158 |
}, |
159 |
taxes_by_tax_id => { |
|
160 |
$tax->id => 1.1115, |
|
161 |
}, |
|
159 | 162 |
items => [ |
160 | 163 |
{ linetotal => 5.85, |
161 | 164 |
linetotal_cost => 4.83, |
... | ... | |
193 | 196 |
# item 2: |
194 | 197 |
# sellprice 9.714 * qty 1.2 = 11.6568 rounded 11.66 |
195 | 198 |
# 7%(11.6568) = 0.815976; rounded = 0.82 |
199 |
# 7%(11.66) = 0.8162 |
|
196 | 200 |
# total rounded = 12.48 |
197 | 201 |
|
198 | 202 |
# lastcost 5.473 * qty 1.2 = 6.5676; rounded 6.57 |
... | ... | |
238 | 242 |
$tax->chart_id => 1.11, |
239 | 243 |
$tax7->chart_id => 0.82, |
240 | 244 |
}, |
245 |
taxes_by_tax_id => { |
|
246 |
$tax->id => 1.1115, |
|
247 |
$tax7->id => 0.8162, |
|
248 |
}, |
|
241 | 249 |
items => [ |
242 | 250 |
{ linetotal => 5.85, |
243 | 251 |
linetotal_cost => 4.83, |
... | ... | |
341 | 349 |
taxes => { |
342 | 350 |
$tax->chart_id => 2.9, |
343 | 351 |
}, |
352 |
taxes_by_tax_id => { |
|
353 |
$tax->id => 2.89750, |
|
354 |
}, |
|
344 | 355 |
items => [ |
345 | 356 |
{ linetotal => 5.27, |
346 | 357 |
linetotal_cost => 1.93, |
... | ... | |
409 | 420 |
taxes => { |
410 | 421 |
$tax->chart_id => 0.66, |
411 | 422 |
}, |
423 |
taxes_by_tax_id => { |
|
424 |
$tax->id => 0.66310, |
|
425 |
}, |
|
412 | 426 |
items => [ |
413 | 427 |
{ linetotal => 3.49, |
414 | 428 |
linetotal_cost => 0, |
... | ... | |
459 | 473 |
taxes => { |
460 | 474 |
$tax->chart_id => 1843, |
461 | 475 |
}, |
476 |
taxes_by_tax_id => { |
|
477 |
$tax->id => 1843, |
|
478 |
}, |
|
462 | 479 |
items => [ |
463 | 480 |
{ linetotal => 9700, |
464 | 481 |
linetotal_cost => 0, |
... | ... | |
520 | 537 |
taxes => { |
521 | 538 |
$tax->chart_id => 12.84, |
522 | 539 |
}, |
540 |
taxes_by_tax_id => { |
|
541 |
$tax->id => 12.8364, |
|
542 |
}, |
|
523 | 543 |
items => [ |
524 | 544 |
{ linetotal => 67.56, |
525 | 545 |
linetotal_cost => 19301.93, |
Auch abrufbar als: Unified diff
PTC: Steuern auch nach Steuer-Id zurückgeben
Bisher kann der PTC die berechntete Steuer pro Steuerkonto zurückgeben.
Allerdings kann kivi so konfiguriert sein, dass verschiedene Steuern
auf ein Konto gebucht werden. Diese lassen sich dann durch die Rückgabe
des PTC nicht unterscheiden.
Jetzt werden die Steuern zusätzlich auch pro Steuereintrag (also per tax.id)
zurückgegeben.