From dbfa733e42a95481ab6231334321c6a82ce68064 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 10 Oct 2007 13:32:40 +0000 Subject: [PATCH] =?utf8?q?Deutliche=20Beschleunigung=20der=20USTVA-Berechn?= =?utf8?q?ung=20durch=20Einschr=C3=A4nkung=20der=20betrachteten=20Datens?= =?utf8?q?=C3=A4tze=20aus=20acc=5Ftrans.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/USTVA.pm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/SL/USTVA.pm b/SL/USTVA.pm index 61a64818b..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 |; -- 2.20.1