X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FUSTVA.pm;h=b10fea6377d4d8aae149cf0f87bb3ac30291916d;hb=06af498f71c9424b2d373d12b4dd90cdac58e070;hp=3655208743eabde393935f023a380ff8f7964135;hpb=86f876b61346bf14a4369b2739fc48ac8a7e02be;p=kivitendo-erp.git diff --git a/SL/USTVA.pm b/SL/USTVA.pm index 365520874..b10fea637 100644 --- a/SL/USTVA.pm +++ b/SL/USTVA.pm @@ -25,6 +25,31 @@ package USTVA; +use SL::DBUtils; + +sub get_coa { + + my ( $self, $form, $myconfig) = @_; + + my $query = q{ SELECT coa FROM defaults }; + + my $dbh = $form->dbconnect($myconfig); + my $sth = $dbh->prepare($query); + $sth->execute() || $form->dberror($query); + + my ($coa) = selectrow_query($form, $dbh, $query); + + $sth->finish; + $dbh->disconnect; + + $form->{coa} = $coa; + $form->{"COA_$coa"} = '1'; + $form->{COA_Germany} = '1' if ( $coa eq 'Germany-DATEV-SKR03EU' or $coa eq 'Germany-DATEV-SKR04EU'); + + return; +} + + sub report_variables { # Get all positions for taxreport out of the database # Needs Databaseupdate Pg-upgrade2/USTVA_abstraction.pl @@ -53,8 +78,6 @@ sub report_variables { $where_dcp |; - $main::lxdebug->message(LXDebug::QUERY, "\$query= \n $query\n"); - my $dbh = $form->dbconnect($myconfig); my $sth = $dbh->prepare($query); @@ -363,11 +386,7 @@ sub info { } else { - if ($form->{error_function}) { - &{ $form->{error_function} }($msg); - } else { - die "Hinweis: $msg\n"; - } + die "Hinweis: $msg\n"; } $main::lxdebug->leave_sub(); @@ -777,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 ############################################ @@ -824,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 |; @@ -859,7 +891,7 @@ sub get_accounts_ustva { } else { - $self->error("Unknown tax method: $form->{method}") + $form->error("Unknown tax method: $form->{method}") }