my $query =
qq|SELECT ac.acc_trans_id, ac.transdate, ac.trans_id,ar.id, ac.amount, ac.taxkey,
- ar.invnumber, ar.duedate, ar.amount as umsatz,
+ ar.invnumber, ar.duedate, ar.amount as umsatz, ar.deliverydate,
ct.name,
c.accno, c.taxkey_id as charttax, c.datevautomatik, c.id, ac.chart_link AS link,
ar.invoice
UNION ALL
SELECT ac.acc_trans_id, ac.transdate, ac.trans_id,ap.id, ac.amount, ac.taxkey,
- ap.invnumber, ap.duedate, ap.amount as umsatz,
+ ap.invnumber, ap.duedate, ap.amount as umsatz, ap.deliverydate,
ct.name,
c.accno, c.taxkey_id as charttax, c.datevautomatik, c.id, ac.chart_link AS link,
ap.invoice
UNION ALL
SELECT ac.acc_trans_id, ac.transdate, ac.trans_id,gl.id, ac.amount, ac.taxkey,
- gl.reference AS invnumber, gl.transdate AS duedate, ac.amount as umsatz,
+ gl.reference AS invnumber, gl.transdate AS duedate, ac.amount as umsatz, NULL as deliverydate,
gl.description AS name,
c.accno, c.taxkey_id as charttax, c.datevautomatik, c.id, ac.chart_link AS link,
FALSE AS invoice
push @{ $self->{DATEV} }, [ \%new_trans, $trans->[$j] ];
} elsif (($j != $notsplitindex) && !$trans->[$j]->{is_tax}) {
- my %tax_info = $taxkeys->get_full_tax_info('transdate' => $trans->[$j]->{transdate});
+ my %tax_info = $taxkeys->get_full_tax_info('transdate' => $trans->[$j]->{transdate},
+ 'deliverydate' => $trans->[$j]->{deliverydate});
my %new_trans = ();
map { $new_trans{$_} = $trans->[$notsplitindex]->{$_}; } keys %{ $trans->[$notsplitindex] };
# if credit_note has a deliverydate, use this instead of invdate
# useful for credit_notes of invoices from an old period with different tax
# if there is no deliverydate then invdate is used, old default (see next elsif)
+ # Falls hier der Stichtag für Steuern anders bestimmt wird,
+ # entsprechend auch bei Taxkeys.pm anpassen
$transdate = $form->{deliverydate};
} elsif (($form->{type} eq "credit_note") || ($form->{script} eq 'ir.pl')) {
$transdate = $form->{invdate};
}
my $sth = $self->{handles}->{get_tax_info};
- do_statement($form, $sth, $self->{queries}->{get_tax_info}, $params{taxkey}, $params{transdate});
+ # Lieferdatum (deliverydate) ist entscheidend für den Steuersatz
+ do_statement($form, $sth, $self->{queries}->{get_tax_info}, $params{taxkey}, $params{deliverydate} || $params{transdate});
my $ref = $sth->fetchrow_hashref() || { };
my @all_taxkeys = map { $_->{taxkey} } (selectall_hashref_query($form, $form->get_standard_dbh(), qq|SELECT DISTINCT taxkey FROM tax WHERE taxkey IS NOT NULL|));
foreach my $taxkey (@all_taxkeys) {
- my $ref = $self->get_tax_info('transdate' => $params{transdate}, 'taxkey' => $taxkey);
+ my $ref = $self->get_tax_info('transdate' => $params{transdate}, 'taxkey' => $taxkey, 'deliverydate' => $params{deliverydate});
$tax_info{taxkeys}->{$taxkey} = $ref;
$tax_info{accnos}->{$ref->{taxchart_id}} = $ref if ($ref->{taxchart_id});