Locales Quoting war fehlerhaft.
[kivitendo-erp.git] / SL / USTVA.pm
index 3655208..13f9a62 100644 (file)
 
 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);
 
@@ -134,7 +157,7 @@ sub steuernummer_input {
       'Thüringen'              => 'FFF/BBB/UUUUP',    # '/' 3
       'Sachsen'                => 'FFF/BBB/UUUUP',    # '/' 3
       'Hamburg'                => 'FF/BBB/UUUUP',     # '/' 3
-      'Baden Würtemberg'       => 'FF/BBB/UUUUP',     # '/' 2
+      'Baden Württemberg'      => 'FF/BBB/UUUUP',     # '/' 2
       'Sachsen Anhalt'         => 'FFF/BBB/UUUUP',    # '/' 3
       'Saarland'               => 'FFF/BBB/UUUUP',    # '/' 3
       'Bremen'                 => 'FF BBB UUUUP',     # ' ' 3
@@ -287,7 +310,7 @@ sub fa_auswahl {
             <td>
               <select size="1" name="elsterland_new" onchange="update_auswahl()">|;
   if ($land eq '') {
-    $fa_auswahl .= qq|<option value="Auswahl" $checked>hier auswählen...</option>\n|;
+    $fa_auswahl .= qq|<option value="Auswahl" $checked>| . $main::locale->text('Select federal state...') . qq|</option>\n|;
   }
   foreach $elster_land (sort keys %$elster_init) {
     $fa_auswahl .= qq|
@@ -317,7 +340,7 @@ sub fa_auswahl {
               <td>
                  <select size="1" name="elsterFFFF_new">|;
   if ($elsterFFFF eq '') {
-    $fa_auswahl .= qq|<option value="Auswahl" $checked>hier auswählen...</option>|;
+    $fa_auswahl .= qq|<option value="Auswahl" $checked>| . $main::locale->text('Select tax office...') . qq|</option>|;
   } else {
     foreach $ffff (sort { $elster_land_fa{$a} cmp $elster_land_fa{$b} }
                    keys(%elster_land_fa)
@@ -338,6 +361,7 @@ sub fa_auswahl {
             </select>|;
 
   $main::lxdebug->leave_sub();
+
   return $fa_auswahl;
 }
 
@@ -355,7 +379,7 @@ sub info {
     <br>
     <br>
     <hr>
-    <input type=button value="zurück" onClick="history.go(-1)">
+    <input type=button value="| . $main::locale->text('Back') . qq|" onClick="history.go(-1)">
     </body>
     |;
 
@@ -363,11 +387,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();
@@ -525,7 +545,7 @@ sub query_finanzamt {
     $land = 'Nordrhein Westfalen'    if (@$FA_finanzamt[0] eq '5');
     $land = 'Hessen'                 if (@$FA_finanzamt[0] eq '6');
     $land = 'Rheinland Pfalz'        if (@$FA_finanzamt[0] eq '7');
-    $land = 'Baden Würtemberg'       if (@$FA_finanzamt[0] eq '8');
+    $land = 'Baden Württemberg'      if (@$FA_finanzamt[0] eq '8');
     $land = 'Bayern'                 if (@$FA_finanzamt[0] eq '9');
     $land = 'Saarland'               if (@$FA_finanzamt[0] eq '10');
     $land = 'Berlin'                 if (@$FA_finanzamt[0] eq '11');
@@ -535,6 +555,8 @@ sub query_finanzamt {
     $land = 'Sachsen Anhalt'         if (@$FA_finanzamt[0] eq '15');
     $land = 'Thüringen'              if (@$FA_finanzamt[0] eq '16');
 
+    $land = $main::locale->{iconv}->convert($land);
+
     my $ffff = @$FA_finanzamt[1];
 
     my $rec = {};
@@ -777,6 +799,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 +861,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 +894,7 @@ sub get_accounts_ustva {
    
   } else {
   
-    $self->error("Unknown tax method: $form->{method}")
+    $form->error("Unknown tax method: $form->{method}")
 
   }