31 |
31 |
|
32 |
32 |
use SL::DBUtils;
|
33 |
33 |
use SL::DATEV::KNEFile;
|
34 |
|
use SL::Taxkeys;
|
35 |
34 |
|
36 |
35 |
use Data::Dumper;
|
37 |
36 |
use DateTime;
|
... | ... | |
360 |
359 |
|
361 |
360 |
$fromto =~ s/transdate/ac\.transdate/g;
|
362 |
361 |
|
363 |
|
my $taxkeys = Taxkeys->new();
|
364 |
362 |
my $filter = ''; # Useful for debugging purposes
|
365 |
363 |
|
366 |
364 |
my %all_taxchart_ids = selectall_as_map($form, $self->dbh, qq|SELECT DISTINCT chart_id, TRUE AS is_set FROM tax|, 'chart_id', 'is_set');
|
... | ... | |
370 |
368 |
ar.invnumber, ar.duedate, ar.amount as umsatz, ar.deliverydate,
|
371 |
369 |
ct.name,
|
372 |
370 |
c.accno, c.taxkey_id as charttax, c.datevautomatik, c.id, ac.chart_link AS link,
|
373 |
|
ar.invoice
|
|
371 |
ar.invoice,
|
|
372 |
t.rate AS taxrate
|
374 |
373 |
FROM acc_trans ac
|
375 |
374 |
LEFT JOIN ar ON (ac.trans_id = ar.id)
|
376 |
375 |
LEFT JOIN customer ct ON (ar.customer_id = ct.id)
|
377 |
376 |
LEFT JOIN chart c ON (ac.chart_id = c.id)
|
|
377 |
LEFT JOIN tax t ON (ac.tax_id = t.id)
|
378 |
378 |
WHERE (ar.id IS NOT NULL)
|
379 |
379 |
AND $fromto
|
380 |
380 |
$trans_id_filter
|
... | ... | |
386 |
386 |
ap.invnumber, ap.duedate, ap.amount as umsatz, ap.deliverydate,
|
387 |
387 |
ct.name,
|
388 |
388 |
c.accno, c.taxkey_id as charttax, c.datevautomatik, c.id, ac.chart_link AS link,
|
389 |
|
ap.invoice
|
|
389 |
ap.invoice,
|
|
390 |
t.rate AS taxrate
|
390 |
391 |
FROM acc_trans ac
|
391 |
392 |
LEFT JOIN ap ON (ac.trans_id = ap.id)
|
392 |
393 |
LEFT JOIN vendor ct ON (ap.vendor_id = ct.id)
|
393 |
394 |
LEFT JOIN chart c ON (ac.chart_id = c.id)
|
|
395 |
LEFT JOIN tax t ON (ac.tax_id = t.id)
|
394 |
396 |
WHERE (ap.id IS NOT NULL)
|
395 |
397 |
AND $fromto
|
396 |
398 |
$trans_id_filter
|
... | ... | |
402 |
404 |
gl.reference AS invnumber, gl.transdate AS duedate, ac.amount as umsatz, NULL as deliverydate,
|
403 |
405 |
gl.description AS name,
|
404 |
406 |
c.accno, c.taxkey_id as charttax, c.datevautomatik, c.id, ac.chart_link AS link,
|
405 |
|
FALSE AS invoice
|
|
407 |
FALSE AS invoice,
|
|
408 |
t.rate AS taxrate
|
406 |
409 |
FROM acc_trans ac
|
407 |
410 |
LEFT JOIN gl ON (ac.trans_id = gl.id)
|
408 |
411 |
LEFT JOIN chart c ON (ac.chart_id = c.id)
|
|
412 |
LEFT JOIN tax t ON (ac.tax_id = t.id)
|
409 |
413 |
WHERE (gl.id IS NOT NULL)
|
410 |
414 |
AND $fromto
|
411 |
415 |
$trans_id_filter
|
... | ... | |
475 |
479 |
}
|
476 |
480 |
}
|
477 |
481 |
|
478 |
|
my %taxid_taxkeys = ();
|
479 |
482 |
my $absumsatz = 0;
|
480 |
483 |
if (scalar(@{$trans}) <= 2) {
|
481 |
484 |
push @{ $self->{DATEV} }, $trans;
|
... | ... | |
545 |
548 |
push @{ $self->{DATEV} }, [ \%new_trans, $trans->[$j] ];
|
546 |
549 |
|
547 |
550 |
} elsif (($j != $notsplitindex) && !$trans->[$j]->{is_tax}) {
|
548 |
|
my %tax_info = $taxkeys->get_full_tax_info('transdate' => $trans->[$j]->{transdate},
|
549 |
|
'deliverydate' => $trans->[$j]->{deliverydate});
|
550 |
551 |
|
551 |
552 |
my %new_trans = ();
|
552 |
553 |
map { $new_trans{$_} = $trans->[$notsplitindex]->{$_}; } keys %{ $trans->[$notsplitindex] };
|
553 |
554 |
|
554 |
|
my $tax_rate = $tax_info{taxkeys}->{ $trans->[$j]->{'taxkey'} }->{taxrate};
|
|
555 |
my $tax_rate = $trans->[$j]->{'taxrate'};
|
555 |
556 |
$new_trans{'net_amount'} = $trans->[$j]->{'amount'} * -1;
|
556 |
557 |
$new_trans{'tax_rate'} = 1 + $tax_rate;
|
557 |
558 |
|
tax_id auslesen
Statt die tax_id aus einem Join auf die Tabelle taxkeys zu bekommen,
wird nun direkt von der acc_trans auf die Steuer zugegriffen. Dies
geschieht an verschiedenen Stellen:
Die tax_id wird jetzt in Kreditoren-/Debitoren- und Dialogbuchungen
aus der acc_trans gelesen statt aus der Tabelle taxkeys.
Im DATEV-Export wird jetzt die id über den Eintrag in der acc_trans
ermittelt anstatt über die Tabelle taxkeys.