X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FUSTVA.pm;h=b10fea6377d4d8aae149cf0f87bb3ac30291916d;hb=786b3862388eb8d4cdcc5dfc663a37fe0e9a82a1;hp=148bf4f46d38f023a805f92ac04d75500776f7cd;hpb=f6c60e9467658c089790836395281ed5729e5305;p=kivitendo-erp.git diff --git a/SL/USTVA.pm b/SL/USTVA.pm index 148bf4f46..b10fea637 100644 --- a/SL/USTVA.pm +++ b/SL/USTVA.pm @@ -796,6 +796,21 @@ sub get_accounts_ustva { $ARwhere .= " AND acc.transdate <= '$todate'"; } + my $acc_trans_where = '1=1'; + if ($fromdate || $todate) { + $acc_trans_where = "ac.trans_id IN (SELECT DISTINCT trans_id FROM acc_trans WHERE "; + + if ($fromdate) { + $acc_trans_where .= "transdate >= '$fromdate'"; + } + if ($todate) { + $acc_trans_where .= " AND " if ($fromdate); + $acc_trans_where .= "transdate <= '$todate'"; + } + + $acc_trans_where .= ")"; + } + ############################################ # Method eq 'cash' = IST Versteuerung ############################################ @@ -843,9 +858,7 @@ sub get_accounts_ustva { ) ) WHERE - 1=1 - -- Here no where, please. All Transactions ever should be - -- testet if they are paied in the USTVA report period. + $acc_trans_where GROUP BY tk.pos_ustva |; @@ -878,7 +891,7 @@ sub get_accounts_ustva { } else { - $self->error("Unknown tax method: $form->{method}") + $form->error("Unknown tax method: $form->{method}") }