Ein oben angedocktes, auf CSS basierendes Menü hinzugefügt.
[kivitendo-erp.git] / bin / mozilla / ustva.pl
index e04bc45..6f097c7 100644 (file)
@@ -29,7 +29,7 @@ require "$form->{path}/arap.pl";
 #use strict;
 #no strict 'refs';
 #use diagnostics;
-#use warnings FATAL=> 'all';
+#use warnings; # FATAL=> 'all';
 #use vars qw($locale $form %myconfig);
 #our ($myconfig);
 #use CGI::Carp "fatalsToBrowser";
@@ -73,16 +73,15 @@ sub report {
   $lxdebug->enter_sub();
   my $myconfig = \%myconfig;
   use CGI;
+
   $form->{title} = $locale->text('UStVA');
-  $form->{kz10}  = '';                       #Berichtigte Anmeldung? Ja =1
+  $form->{kz10}  = '';                       #Berichtigte Anmeldung? Ja =1 Nein=0
 
-  #  $accrual = ($eur) ? "" : "checked";
-  #  $cash = ($eur) ? "checked" : "";
-  my $year = '';
-  my $null = '';
-  ($null, $null, $null, $null, $null, $year, $null, $null, $null) =
-    localtime();
-  $year += 1900;
+  my $year = substr(
+                    $form->datetonum($form->current_date(\%myconfig),
+                                     \%myconfig
+                    ),
+                    0, 4);
 
   my $department = '';
   local $hide = '';
@@ -90,7 +89,6 @@ sub report {
 
   print qq|
 <body>
-
 <form method=post action=$form->{script}>
 
 <input type=hidden name=title value="$form->{title}">
@@ -110,8 +108,16 @@ sub report {
   # Einlesen der Finanzamtdaten
   &get_config($userspath, 'finanzamt.ini');
 
+  # Hier Einlesen der user-config
+  # steuernummer entfernt für prerelease
   my @a = qw(signature name company address businessnumber tel fax email
-    company_street company_city company_email);
+    co_chief co_department co_custom1 co_custom2 co_custom3 co_custom4 co_custom5
+    co_name1 co_name2
+    co_street co_street1 co_zip co_city co_city1 co_country co_tel co_tel1 co_tel2
+    co_fax co_fax1 co_email co_email1 co_url co_url1 ustid duns
+    co_bankname co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1
+    co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2 co_accountnr3);
+
   map { $form->{$_} = $myconfig->{$_} } @a;
 
   my $oeffnungszeiten = $form->{FA_Oeffnungszeiten};
@@ -133,34 +139,46 @@ sub report {
     |;
   }
 
-  #klären, ob $form->{company_street|_address} gesetzt sind
-  ###
+  # Anpassungen der Variablennamen auf pre 2.1.1 Namen
+  # klären, ob $form->{company_street|_address} gesetzt sind
+  #
+
   if ($form->{address} ne '') {
     my $temp = $form->{address};
     $temp =~ s/\\n/<br \/>/;
-    print qq|$temp|;
-    ($form->{company_street}, $form->{company_city}) = split("<br \/", $temp);
-  } elsif ($form->{address} eq ''
-         and ($form->{company_street} ne '' and $form->{company_city} ne '')) {
-    print qq|$form->{company_street}<br>\n| if ($form->{company_street} ne '');
-    print qq|$form->{company_city}\n|       if ($form->{company_city}   ne '');
-         } elsif ($form->{company_street} eq '' or $form->{company_city} eq '') {
+    ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp);
+    $form->{co_city} =~ s/\\n//g;
+  }
+
+  if ($form->{co_street} ne ''
+      and (   $form->{co_zip} ne ''
+           or $form->{co_city} ne '')
+    ) {
+    print qq|
+    $form->{co_street}<br>
+    $form->{co_street1}<br>
+    $form->{co_zip} $form->{co_city}|;
+    } else {
     print qq|
          <a href=am.pl?path=$form->{path}&action=config&level=Programm--Preferences&login=$form->{login}&password=$form->{password}>
          | . $locale->text('Keine Firmenadresse hinterlegt!') . qq|</a>\n|;
   }
+  $form->{co_email} = $form->{email} unless $form->{co_email};
+  $form->{co_tel}   = $form->{tel}   unless $form->{co_tel};
+  $form->{co_fax}   = $form->{fax}   unless $form->{co_fax};
+  $form->{co_url}   = $form->{urlx}  unless $form->{co_url};
 
   print qq|
          <br>
          <br>
          | . $locale->text('Tel.: ') . qq|
-         $form->{tel}
+         $form->{co_tel}
          <br>
          | . $locale->text('Fax.: ') . qq|
-         $form->{fax}    
+         $form->{co_fax}         
          <br>
          <br>
-         $form->{email}          
+         $form->{co_email}       
          <br>
          <br>
          | . $locale->text('Steuernummer: ') . qq|
@@ -174,10 +192,10 @@ sub report {
          Keine Steuernummer hinterlegt!</a><br>|;
   }
   print qq|
-         <!--<br>
+         <br>
          | . $locale->text('ELSTER-Steuernummer: ') . qq|
          $form->{elstersteuernummer}
-          <br>-->
+          <br>
           <br>
 
          </fieldset>
@@ -214,7 +232,7 @@ sub report {
 
     # accounting years if SQL-Ledger Version < 2.4.1
     #    $year = $form->{year} * 1;
-    @years = sort { $b <=> $a } (2000 .. ($year));
+    @years = sort { $b <=> $a } (2003 .. ($year + 1));
     $form->{all_years} = \@years;
   }
   map { $form->{selectaccountingyear} .= qq|<option>$_\n| }
@@ -395,31 +413,6 @@ sub report {
          </fieldset>
       |;
 
-    # Stichtag der nächsten USTVA berechnen
-    #
-    # ($stichtag, $tage_bis, $ical) = FA->stichtag($today[dd.mm.yyyy],
-    #                                              $FA_dauerfrist[1,0],
-    #                                              $FA_voranmeld[month, quarter])
-    #$tmpdateform= $myconfig{dateformat};
-    #  $myconfig{dateformat}= "dd.mm.yyyy";
-    #  $form->{today} = $form->datetonum($form->current_date(\%myconfig), \%myconfig);
-    #  ($stichtag, $description, $tage_bis, $ical) = FA::stichtag($form->{today}, $form->{FA_dauerfrist},$form->{FA_voranmeld});
-    #   $form->{today} = $form->date($stichtag, \%myconfig );
-    #$myconfig{dateformat}= $tmpdateform;
-
-    #print qq|
-    #   <br>
-    #   <br>
-    #   <fieldset>
-    #    <label>
-    #    |.$locale->text('Anstehende Voranmeldungen').qq|
-    #    </label>
-    #     <h2 class="confirm">$stichtag<h2>
-    #     <h3>$description</h3>
-    #     <h4>$form->{today}</h4>
-    #
-    #   </fieldset>|;
-
   } else {
     print qq|
      <td width="50%" valign="bottom">
@@ -427,14 +420,12 @@ sub report {
      <legend>
      <b>| . $locale->text('Hinweise') . qq|</b>
      </legend>
-      <h2 class="confirm">Die Ausgabefunktionen sind wegen fehlender Daten deaktiviert.</h2>
-      <h3>Hilfe:</h3>
+      <h2 class="confirm">|
+      . $locale->text('Missing Preferences: Outputroutine disabled')
+      . qq|</h2>
+      <h3>| . $locale->text('Help:') . qq|</h3>
       <ul>
-      <li><a href="ustva.pl?path=$form->{path}&action=edit&level=Programm--Finanzamteinstellungen&login=$form->{login}&password=$form->{password}">
-      Bitte 'Einstellungen' wählen um die Erweiterten UStVa Funktionen nutzen zu können.</a></li>
-      <br>
-      <li><a href="am.pl?path=$form->{path}&action=config&level=Programm--Preferences&login=$form->{login}&password=$form->{password}">
-      Firmendaten können bei den Benutzereinstellungen verändert werden.</a></li>
+      <li>| . $locale->text('Hint-Missing-Preferences') . qq|</li>
       </ul>
       </fieldset>
      |;
@@ -461,8 +452,8 @@ sub report {
   <br>
   <input type="hidden" name="address" value="$form->{address}">
   <input type="hidden" name="reporttype" value="custom">
-  <input type="hidden" name="company_street" value="$form->{company_street}">
-  <input type="hidden" name="company_city" value="$form->{company_city}">
+  <input type="hidden" name="co_street" value="$form->{co_street}">
+  <input type="hidden" name="co_city" value="$form->{co_city}">
   <input type="hidden" name="path" value="$form->{path}">
   <input type="hidden" name="login" value="$form->{login}">
   <input type="hidden" name="password" value="$form->{password}">
@@ -472,8 +463,6 @@ sub report {
      <input type=hidden name=nextsub value=generate_ustva>
      <input $hide type=submit class=submit name=action value="|
     . $locale->text('Show') . qq|">
-     <input type=submit class=submit name=action value="|
-    . $locale->text('Config') . qq|">
    </td>
    <td align="right">
 
@@ -493,7 +482,6 @@ sub report {
   </body>
   </html>
   |;
-
   $lxdebug->leave_sub();
 }
 
@@ -519,22 +507,27 @@ sub show {
 
   #&generate_ustva();
   no strict 'refs';
+  $lxdebug->leave_sub();
   &{ $form->{nextsub} };
   use strict 'refs';
-  $lxdebug->leave_sub();
 }
 
 sub ustva_vorauswahl {
   $lxdebug->enter_sub();
 
   #Aktuelles Datum zerlegen:
-  $locale->date(\%myconfig, $form->current_date(\%myconfig, '0', '0'), 0) =~
-    /(\d\d).(\d\d).(\d\d\d\d)/;
+  my $date = $form->datetonum($form->current_date(\%myconfig), \%myconfig);
 
   #$locale->date($myconfig, $form->current_date($myconfig), 0)=~ /(\d\d).(\d\d).(\d\d\d\d)/;
-  $form->{day}   = $1;
-  $form->{month} = $2;
-  $form->{year}  = $3;
+  $form->{day}   = substr($date, 6, 2);
+  $form->{month} = substr($date, 4, 2);
+  $form->{year}  = substr($date, 0, 4);
+  $lxdebug->message(LXDebug::DEBUG1, qq|
+    Actual date from Database: $date\n    
+    Actual year from Database: $form->{year}\n
+    Actual day from Database: $form->{day}\n
+    Actual month from Database: $form->{month}\n|);
+
   my $sel    = '';
   my $yymmdd = '';
 
@@ -552,29 +545,29 @@ sub ustva_vorauswahl {
   if ($form->{FA_voranmeld} eq 'month') {
 
     # Vorauswahl bei monatlichem Voranmeldungszeitraum
-    print qq|
-     <select name="duetyp" id=zeitraum title="|
-      . $locale->text('Hier den Berechnungszeitraum auswählen...') . qq|">
-   |;
 
-    my %liste = ('01' => 'January',
-                 '02' => 'February',
-                 '03' => 'March',
-                 '04' => 'April',
-                 '05' => 'May',
-                 '06' => 'June',
-                 '07' => 'July',
-                 '08' => 'August',
-                 '09' => 'September',
-                 '10' => 'October',
-                 '11' => 'November',
-                 '12' => 'December');
+    my %liste = ('01' => $locale->text('January'),
+                 '02' => $locale->text('February'),
+                 '03' => $locale->text('March'),
+                 '04' => $locale->text('April'),
+                 '05' => $locale->text('May'),
+                 '06' => $locale->text('June'),
+                 '07' => $locale->text('July'),
+                 '08' => $locale->text('August'),
+                 '09' => $locale->text('September'),
+                 '10' => $locale->text('October'),
+                 '11' => $locale->text('November'),
+                 '12' => $locale->text('December'),
+                 '13' => $locale->text('Yearly'),
+                );
 
     my $yy = $form->{year} * 10000;
     $yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
     $sel    = '';
-    my $dfv = '0';    # Offset für Dauerfristverlängerung
-                      #$dfv = '100' if ($form->{FA_dauerfrist} eq '1');
+    my $dfv = '';
+
+    # Offset für Dauerfristverlängerung
+    $dfv = '100' if ($form->{FA_dauerfrist} eq '1');
 
   SWITCH: {
       $yymmdd <= ($yy + 110 + $dfv) && do {
@@ -632,15 +625,15 @@ sub ustva_vorauswahl {
       };
 
     }
+    print qq|<select id="zeitraum" name="period" title="|
+  . $locale->text('Select a period') . qq|" >|;
+
     my $key = '';
     foreach $key (sort keys %liste) {
       my $selected = '';
       $selected = 'selected' if ($sel eq $key);
       print qq|
-         <option value="$key" $selected>|
-        . $locale->text("$liste{$key}")
-        . qq|</option>
-         
+         <option value="$key" $selected> $liste{$key}</option>
    |;
     }
     print qq|</select>|;
@@ -648,10 +641,11 @@ sub ustva_vorauswahl {
   } elsif ($form->{FA_voranmeld} eq 'quarter') {
 
     # Vorauswahl bei quartalsweisem Voranmeldungszeitraum
-    my %liste = ('A' => '1.',
-                 'B' => '2.',
-                 'C' => '3.',
-                 'D' => '4.',);
+    my %liste = ('41'  => $locale->text('1. Quarter'),
+                 '42'  => $locale->text('2. Quarter'),
+                 '43'  => $locale->text('3. Quarter'),
+                 '44'  => $locale->text('4. Quarter'),
+                 '13' => $locale->text('Yearly'),);
 
     my $yy = $form->{year} * 10000;
     $yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
@@ -682,16 +676,14 @@ sub ustva_vorauswahl {
       };
     }
 
-    print qq|<select id="zeitraum" name="duetyp" title="|
+    print qq|<select id="zeitraum" name="period" title="|
       . $locale->text('Select a period') . qq|" >|;
     my $key = '';
     foreach $key (sort keys %liste) {
       my $selected = '';
       $selected = 'selected' if ($sel eq $key);
       print qq|
-         <option value="$key" $selected>$liste{$key} |
-        . $locale->text('Quarter')
-        . qq|</option>
+         <option value="$key" $selected>$liste{$key}</option>
      |;
     }
     print qq|\n</select>
@@ -700,13 +692,13 @@ sub ustva_vorauswahl {
   } else {
 
     # keine Vorauswahl bei Voranmeldungszeitraum
-    print qq|<select id="zeitraum" name="duetyp" title="|
+    print qq|<select id="zeitraum" name="period" title="|
       . $locale->text('Select a period') . qq|" >|;
 
-    my %listea = ('A' => '1.',
-                  'B' => '2.',
-                  'C' => '3.',
-                  'D' => '4.',);
+    my %listea = ('41' => '1. Quarter',
+                  '42' => '2. Quarter',
+                  '43' => '3. Quarter',
+                  '44' => '4. Quarter',);
 
     my %listeb = ('01' => 'January',
                   '02' => 'February',
@@ -719,22 +711,21 @@ sub ustva_vorauswahl {
                   '09' => 'September',
                   '10' => 'October',
                   '11' => 'November',
-                  '12' => 'December',);
+                  '12' => 'December',
+                  '13' => 'Yearly',);
     my $key = '';
     foreach $key (sort keys %listea) {
       print qq|
-         <option value="$key">$listea{$key} |
-        . $locale->text('Quarter')
-        . qq|</option>
-         
-     |;
+         <option value="$key">|
+        . $locale->text("$listea{$key}")
+        . qq|</option>\n|;
     }
 
     foreach $key (sort keys %listeb) {
       print qq|
-         <option value="$key">| . $locale->text("$listeb{$key}") . qq|</option>
-         
-     |;
+         <option value="$key">|
+        . $locale->text("$listeb{$key}")
+        . qq|</option>\n|;
     }
     print qq|</select>|;
   }
@@ -748,7 +739,9 @@ sub config {
 }
 
 sub debug {
+  $lxdebug->enter_sub();
   $form->debug();
+  $lxdebug->leave_sub();
 }
 
 sub show_options {
@@ -764,7 +757,7 @@ sub show_options {
       qq|       <option value=html selected>|
     . $locale->text('Vorschau')
     . qq|</option>|;
-  if ($latex) {
+  if ($latex_templates) {
     $format .=
         qq|    <option value=pdf>|
       . $locale->text('UStVA als PDF-Dokument')
@@ -775,9 +768,12 @@ sub show_options {
   #$disabled='' if ($form->{elster} eq '1' );
   if ($form->{elster} eq '1') {
     $format .=
-        qq|<option value=elster>|
+        qq|<option value=elsterwinston>|
       . $locale->text('ELSTER Export nach Winston')
-      . qq|</option>|;
+      . qq|</option>|
+      . qq|<option value=elstertaxbird>|
+      . $locale->text('ELSTER Export nach Taxbird')
+      . qq|</option>|;      
   }
 
   #$format .= qq|<option value=elster>|.$locale->text('ELSTER Export nach Winston').qq|</option>|;
@@ -785,8 +781,7 @@ sub show_options {
     $type
     $media
     <select name=format title = "|
-    . $locale->text('Ausgabeformat auswählen...')
-    . qq|">$format</select>
+    . $locale->text('Ausgabeformat auswählen...') . qq|">$format</select>
   |;
   $lxdebug->leave_sub();
 }
@@ -802,142 +797,144 @@ sub generate_ustva {
   # form vars initialisieren
   my @anmeldungszeitraum =
     qw('0401' '0402' '0403' '0404' '0405' '0405' '0406' '0407' '0408' '0409' '0410' '0411' '0412' '0441' '0442' '0443' '0444');
-  my $item = '';
-  foreach $item (@anmeldungszeitraum) {
+  foreach my $item (@anmeldungszeitraum) {
     $form->{$item} = "";
   }
-  if ($form->{reporttype} eq "custom") {
 
     #forgotten the year --> thisyear
     if ($form->{year} !~ m/^\d\d\d\d$/) {
-      $locale->date(\$myconfig, $form->current_date(\$myconfig), 0) =~
-        /(\d\d\d\d)/;
-      $form->{year} = $1;
+      $form->{year} = substr(
+                             $form->datetonum(
+                                    $form->current_date(\%myconfig), \%myconfig
+                             ),
+                             0, 4);
+      $lxdebug->message(LXDebug::DEBUG1,
+                        qq|Actual year from Database: $form->{year}\n|);
     }
 
     #yearly report
-    if ($form->{duetyp} eq "13") {
-      $form->{fromdate} = "1.1.$form->{year}";
-      $form->{todate}   = "31.12.$form->{year}";
+    if ($form->{period} eq "13") {
+      $form->{fromdate} = "$form->{year}0101";
+      $form->{todate}   = "$form->{year}1231";
     }
 
     #Quater reports
-    if ($form->{duetyp} eq "A") {
-      $form->{fromdate} = "1.1.$form->{year}";
-      $form->{todate}   = "31.3.$form->{year}";
+    if ($form->{period} eq "41") {
+      $form->{fromdate} = "$form->{year}0101";
+      $form->{todate}   = "$form->{year}0331";
       $form->{'0441'}   = "X";
     }
-    if ($form->{duetyp} eq "B") {
-      $form->{fromdate} = "1.4.$form->{year}";
-      $form->{todate}   = "30.6.$form->{year}";
+    if ($form->{period} eq "42") {
+      $form->{fromdate} = "$form->{year}0401";
+      $form->{todate}   = "$form->{year}0630";
       $form->{'0442'}   = "X";
     }
-    if ($form->{duetyp} eq "C") {
-      $form->{fromdate} = "1.7.$form->{year}";
-      $form->{todate}   = "30.9.$form->{year}";
+    if ($form->{period} eq "43") {
+      $form->{fromdate} = "$form->{year}0701";
+      $form->{todate}   = "$form->{year}0930";
       $form->{'0443'}   = "X";
     }
-    if ($form->{duetyp} eq "D") {
-      $form->{fromdate} = "1.10.$form->{year}";
-      $form->{todate}   = "31.12.$form->{year}";
+    if ($form->{period} eq "44") {
+      $form->{fromdate} = "$form->{year}1001";
+      $form->{todate}   = "$form->{year}1231";
       $form->{'0444'}   = "X";
     }
 
     #Monthly reports
   SWITCH: {
-      $form->{duetyp} eq "01" && do {
-        $form->{fromdate} = "1.1.$form->{year}";
-        $form->{todate}   = "31.1.$form->{year}";
+      $form->{period} eq "01" && do {
+        $form->{fromdate} = "$form->{year}0101";
+        $form->{todate}   = "$form->{year}0131";
         $form->{'0401'}   = "X";
         last SWITCH;
       };
-      $form->{duetyp} eq "02" && do {
-        $form->{fromdate} = "1.2.$form->{year}";
+      $form->{period} eq "02" && do {
+        $form->{fromdate} = "$form->{year}0201";
 
         #this works from 1901 to 2099, 1900 and 2100 fail.
         my $leap = ($form->{year} % 4 == 0) ? "29" : "28";
-        $form->{todate} = "$leap.2.$form->{year}";
+        $form->{todate} = "$form->{year}02$leap";
         $form->{"0402"} = "X";
         last SWITCH;
       };
-      $form->{duetyp} eq "03" && do {
-        $form->{fromdate} = "1.3.$form->{year}";
-        $form->{todate}   = "31.3.$form->{year}";
+      $form->{period} eq "03" && do {
+        $form->{fromdate} = "$form->{year}0301";
+        $form->{todate}   = "$form->{year}0331";
         $form->{"0403"}   = "X";
         last SWITCH;
       };
-      $form->{duetyp} eq "04" && do {
-        $form->{fromdate} = "1.4.$form->{year}";
-        $form->{todate}   = "30.4.$form->{year}";
+      $form->{period} eq "04" && do {
+        $form->{fromdate} = "$form->{year}0401";
+        $form->{todate}   = "$form->{year}0430";
         $form->{"0404"}   = "X";
         last SWITCH;
       };
-      $form->{duetyp} eq "05" && do {
-        $form->{fromdate} = "1.5.$form->{year}";
-        $form->{todate}   = "31.5.$form->{year}";
+      $form->{period} eq "05" && do {
+        $form->{fromdate} = "$form->{year}0501";
+        $form->{todate}   = "$form->{year}0531";
         $form->{"0405"}   = "X";
         last SWITCH;
       };
-      $form->{duetyp} eq "06" && do {
-        $form->{fromdate} = "1.6.$form->{year}";
-        $form->{todate}   = "30.6.$form->{year}";
+      $form->{period} eq "06" && do {
+        $form->{fromdate} = "$form->{year}0601";
+        $form->{todate}   = "$form->{year}0630";
         $form->{"0406"}   = "X";
         last SWITCH;
       };
-      $form->{duetyp} eq "07" && do {
-        $form->{fromdate} = "1.7.$form->{year}";
-        $form->{todate}   = "31.7.$form->{year}";
+      $form->{period} eq "07" && do {
+        $form->{fromdate} = "$form->{year}0701";
+        $form->{todate}   = "$form->{year}0731";
         $form->{"0407"}   = "X";
         last SWITCH;
       };
-      $form->{duetyp} eq "08" && do {
-        $form->{fromdate} = "1.8.$form->{year}";
-        $form->{todate}   = "31.8.$form->{year}";
+      $form->{period} eq "08" && do {
+        $form->{fromdate} = "$form->{year}0801";
+        $form->{todate}   = "$form->{year}0831";
         $form->{"0408"}   = "X";
         last SWITCH;
       };
-      $form->{duetyp} eq "09" && do {
-        $form->{fromdate} = "1.9.$form->{year}";
-        $form->{todate}   = "30.9.$form->{year}";
+      $form->{period} eq "09" && do {
+        $form->{fromdate} = "$form->{year}0901";
+        $form->{todate}   = "$form->{year}0930";
         $form->{"0409"}   = "X";
         last SWITCH;
       };
-      $form->{duetyp} eq "10" && do {
-        $form->{fromdate} = "1.10.$form->{year}";
-        $form->{todate}   = "31.10.$form->{year}";
+      $form->{period} eq "10" && do {
+        $form->{fromdate} = "$form->{year}1001";
+        $form->{todate}   = "$form->{year}1031";
         $form->{"0410"}   = "X";
         last SWITCH;
       };
-      $form->{duetyp} eq "11" && do {
-        $form->{fromdate} = "1.11.$form->{year}";
-        $form->{todate}   = "30.11.$form->{year}";
+      $form->{period} eq "11" && do {
+        $form->{fromdate} = "$form->{year}1101";
+        $form->{todate}   = "$form->{year}1130";
         $form->{"0411"}   = "X";
         last SWITCH;
       };
-      $form->{duetyp} eq "12" && do {
-        $form->{fromdate} = "1.12.$form->{year}";
-        $form->{todate}   = "31.12.$form->{year}";
+      $form->{period} eq "12" && do {
+        $form->{fromdate} = "$form->{year}1201";
+        $form->{todate}   = "$form->{year}1231";
         $form->{"0412"}   = "X";
         last SWITCH;
       };
     }
-  }
 
-  #$myconfig = \%myconfig;
-  RP->ustva(\%myconfig, \%$form);
+  # using dates in ISO-8601 format: yyyymmmdd  for Postgres...
+  USTVA->ustva(\%myconfig, \%$form);
 
-  #??($form->{department}) = split /--/, $form->{department};
+  # reformat Dates to dateformat
+  $form->{fromdate} = $locale->date(\%myconfig, $form->{fromdate}, 0, 0, 0);
 
-  $form->{period} =
-    $locale->date(\%myconfig, $form->current_date(\%myconfig), 1, 0, 0);
   $form->{todate} = $form->current_date($myconfig) unless $form->{todate};
+  $form->{todate} = $locale->date(\%myconfig, $form->{todate}, 0, 0, 0);
+
+  $form->{longperiod} =
+    $locale->date(\%myconfig, $form->current_date(\%myconfig), 1, 0, 0);
 
   # if there are any dates construct a where
   if ($form->{fromdate} || $form->{todate}) {
 
-    unless ($form->{todate}) {
-      $form->{todate} = $form->current_date($myconfig);
-    }
+    $form->{todate} = $form->current_date($myconfig)  unless ($form->{todate});
 
     my $longtodate  = $locale->date($myconfig, $form->{todate}, 1, 0, 0);
     my $shorttodate = $locale->date($myconfig, $form->{todate}, 0, 0, 0);
@@ -946,7 +943,7 @@ sub generate_ustva {
     my $shortfromdate = $locale->date($myconfig, $form->{fromdate}, 0, 0, 0);
 
     $form->{this_period} = "$shortfromdate<br>\n$shorttodate";
-    $form->{period}      =
+    $form->{longperiod}      =
         $locale->text('for Period')
       . qq|<br>\n$longfromdate |
       . $locale->text('bis')
@@ -965,7 +962,7 @@ sub generate_ustva {
       $locale->date(\%myconfig, $form->{comparetodate}, 0, 0, 0);
 
     $form->{last_period} = "$shortcomparefromdate<br>\n$shortcomparetodate";
-    $form->{period} .=
+    $form->{longperiod} .=
         "<br>\n$longcomparefromdate "
       . $locale->text('bis')
       . qq| $longcomparetodate|;
@@ -975,60 +972,173 @@ sub generate_ustva {
     $locale->date(\%myconfig, $form->current_date(\%myconfig), 0, 0, 0);
 
   # setup variables for the form
-  my @a = ();
-  @a = qw(company businessnumber tel fax email company_email);
+  # steuernummer für prerelease entfernt
+  my @a = qw(company businessnumber tel fax email
+    co_chief co_department co_custom1 co_custom2 co_custom3 co_custom4 co_custom5
+    co_name1 co_name2  co_street co_street1 co_zip co_city co_city1 co_country co_tel co_tel1 co_tel2
+    co_fax co_fax1 co_email co_email1 co_url co_url1 ustid duns
+    co_bankname co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1
+    co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2 co_accountnr3);
+
   map { $form->{$_} = $myconfig{$_} } @a;
 
   if ($form->{address} ne '') {
     my $temp = $form->{address};
     $temp =~ s/\\n/<br \/>/;
-    ($form->{company_street}, $form->{company_city}) = split("<br \/>", $temp);
+    ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp);
+    $form->{co_city} =~ s/\\n//g;
   }
 
-  if (   $form->{format} eq 'pdf'
-      or $form->{format} eq 'postscript') {
+  if ( $form->{format} eq 'pdf' or $form->{format} eq 'postscript') {
+
+    $form->{IN} = "$form->{type}-$form->{year}.tex";
+
     $form->{padding} = "~~";
     $form->{bold}    = "\textbf{";
     $form->{endbold} = "}";
     $form->{br}      = '\\\\';
 
-    my @numbers = qw(51r 86r 97r 93r 96 43 45
-      66 62 67);
+    my @numbers = qw(511 861 36 80 971 931 98 96 53 74
+      85 65 66 61 62 Z67 63 64 59 69 39 83
+      Z43 Z45 Z53 Z62 Z65);
+
     my $number = '';
-    foreach $number (@numbers) {
-      $form->{$number} =~ s/,/~~/g;
+
+    # Zahlenformatierung für Latex USTVA Formulare
+    if (   $myconfig{numberformat} eq '1.000,00'
+           or $myconfig{numberformat} eq '1000,00') {
+      foreach $number (@numbers) {
+        $form->{$number} =~ s/,/~~/g;
+      }
     }
-      } elsif ($form->{format} eq 'html') {
+    if (   $myconfig{numberformat} eq '1000.00'
+        or $myconfig{numberformat} eq '1,000.00') {
+      foreach $number (@numbers) {
+        $form->{$number} =~ s/\./~~/g;
+      }
+    }
+    if ( $form->{period} eq '13'){ #Catch yearly USTE for now, not yet implemented.
+      $form->header;
+      USTVA::error(
+        $locale->text(
+        'Impossible to create yearly Tax Report as PDF or Postscript<br \> Not yet implemented!'
+        )
+      );
+    }
+      
+  } elsif ( $form->{format} eq 'html') { # Formatierungen für HTML Ausgabe
+
+    $form->{IN} = $form->{type} . '.html';
     $form->{padding} = "&nbsp;&nbsp;";
     $form->{bold}    = "<b>";
     $form->{endbold} = "</b>";
     $form->{br}      = "<br>";
-    $form->{address} =~ s/\\n/<br \/>/;
+    $form->{address} =~ s/\\n/\n/g;
 
-  }
+  } elsif ($form->{format} =~ /^elster/) {
 
-  if ($form->{format} eq 'elster') {
-    &create_winston();
-  } else {
-    $form->{templates} = $myconfig{templates};
-    $form->{templates} = "doc" if ($form->{type} eq 'help');
+    if ( $form->{period} eq '13' ) {
+      $form->header;
+      USTVA::info(
+        $locale->text(
+        'Impossible to create yearly Tax Report via Winston or Taxbird.<br \> Not yet implemented!'
+      ));
+    }
 
-    $form->{IN} = "$form->{type}";
-    $form->{IN} = "$form->{help}" if ($form->{type} eq 'help');
-    $form->{IN} .= "-$form->{year}"
-      if (   $form->{format} eq 'pdf'
-          or $form->{format} eq 'postscript');
+    if ( $form->{format} eq 'elsterwinston' ) {
+
+      $form->{IN} = 'winston.xml';
+     
+      # Build Winston filename
+      my $file = 'U';     # 1. char 'U' = USTVA
+      $file .= $form->{period};
+      #4. and 5. char = year modulo 100
+      $file .= sprintf("%02d", $form->{year} % 100);
+      #6. to 18. char = Elstersteuernummer
+      #Beispiel: Steuernummer in Bayern
+      #111/222/33334 ergibt für UStVA Jan 2004: U01049111022233334
+      $file .= $form->{elsterFFFF};
+      $file .= $form->{elstersteuernummer};
+      #file suffix
+      $file .= '.xml';
+      $form->{tmpfile} = "$userspath/$file";
+    }
 
-    $form->{IN} .= '.tex'
-      if (   $form->{format} eq 'pdf'
-          or $form->{format} eq 'postscript');
+    if ( $form->{format} eq 'elstertaxbird' ) {
+
+      $form->{IN} = 'taxbird.txb';
+     
+      $form->{tmpfile} = "$userspath/USTVA-" . $form->{period} 
+      . sprintf("%02d", $form->{year} % 100) . ".txb";
+
+      if ($form->{period} =~ /^[4]\d$/ ){
+        my %periods = ( # Lx => taxbird
+                     '41' => '12',
+                     '42' => '13',
+                     '43' => '14',
+                     '44' => '15',
+                   );
+      
+        foreach my $quarter ( keys %periods ) {
+          $form->{period} = $periods{$quarter} if ( $form->{period} eq $quarter);
+        }
+        
+        my %lands = ( # Lx => taxbird # TODO: besser als array...
+                    'Baden Würtemberg'       => '0',
+                    'Bayern'                 => '1',
+                    'Berlin'                 => '2',
+                    'Brandenburg'            => '3',
+                    'Bremen'                 => '4',
+                    'Hamburg'                => '5',
+                    'Hessen'                 => '6',
+                    'Mecklenburg Vorpommern' => '7',
+                    'Niedersachsen'          => '8',
+                    'Nordrhein Westfalen'    => '9',
+                    'Rheinland Pfalz'        => '10',
+                    'Saarland'               => '11',
+                    'Sachsen'                => '12',
+                    'Sachsen Anhalt'         => '13',
+                    'Schleswig Holstein'     => '14',
+                    'Thüringen'              => '15',
+              );
+
+
+        foreach my $land ( keys %lands ){
+          $form->{elsterland} = $lands{$land} if ($form->{elsterland} eq $land );
+        }
+      } elsif ($form->{period} =~ /^\d+$/ ) {
+        $form->{period} =~ s/^0//g;
+        my $period = $form->{period};
+        $period * 1;
+        $period--;
+        $form->{period} = $period;
+       } else {
+         $form->header;
+         USTVA::error( $locale->text('Wrong Period' ));
+         exit(0);
+                
+       }
+      
+    }
+    # Other Elster formats follow here...
+    
+  } elsif ( $form->{format} eq '' ){ # No format error.
+    $form->header;
+    USTVA::error( $locale->text('Application Error. No Format given!' ));
+    exit(0);
+  } else { # All other Formats are wrong
+    $form->header;
+    USTVA::error( $locale->text('Application Error. Wrong Format: ') . $form->{format} );
+    exit(0);
+  }
+    
+  
+  $form->{templates} = $myconfig{templates};
+  $form->{templates} = "doc" if ( $form->{type} eq 'help' );
 
-    $form->{IN} .= '.html' if ($form->{format} eq 'html');
+  $form->parse_template($myconfig, $userspath);
 
-    #$form->header;
-    #print qq|$myconfig<br>$path|;
-    $form->parse_template($myconfig, $userspath);
-  }
   $lxdebug->leave_sub();
 }
 
@@ -1045,6 +1155,11 @@ sub edit {
   my $land = $form->{elsterland};
   my $amt  = $form->{elsterFFFF};
 
+  my $callback = '';
+  $callback =
+    "$form->{cbscript}?action=edit&login=$form->{cblogin}&path=$form->{cbpath}&root=$form->{cbroot}&rpw=$form->{cbrpw}"
+    if ($form->{cbscript} ne '' and $form->{cblogin} ne '');
+
   $form->{title} = $locale->text('Finanzamt - Einstellungen');
   print qq|
     <body>
@@ -1052,16 +1167,14 @@ sub edit {
      <table width=100%>
        <tr>
          <th class="listtop">|
-    . $locale->text('Finanzamt - Einstellungen')
-    . qq|</th>
+    . $locale->text('Finanzamt - Einstellungen') . qq|</th>
        </tr>
         <tr>
          <td>
            <br>
            <fieldset>
            <legend><b>|
-    . $locale->text('Angaben zum Finanzamt')
-    . qq|</b></legend>
+    . $locale->text('Angaben zum Finanzamt') . qq|</b></legend>
   |;
 
   #print qq|$form->{terminal}|;
@@ -1111,8 +1224,7 @@ sub edit {
   print qq|
            <input name="FA_dauerfrist" id=FA_dauerfrist class=checkbox type=checkbox value="1" $checked>
            <label for="">|
-    . $locale->text('Dauerfristverlängerung')
-    . qq|</label>
+    . $locale->text('Dauerfristverlängerung') . qq|</label>
            
            </fieldset>
            <br>
@@ -1165,10 +1277,17 @@ sub edit {
            <br>
            <hr>
            <!--<input type=submit class=submit name=action value="|
-    . $locale->text('debug')
-    . qq|">-->
+    . $locale->text('debug') . qq|">-->
+           |;
+  print qq|
+           <input type="button" name="Verweis" value="|
+    . $locale->text('Back to user config...') . qq|" 
+            onClick="self.location.href='$callback'">| if ($callback ne '');
+  print qq|
+           &nbsp; &nbsp;
            <input type=submit class=submit name=action value="|
     . $locale->text('continue') . qq|">
+
          </td>
        </tr>
      </table>
@@ -1184,7 +1303,7 @@ sub edit {
 
   #<input type=hidden name="steuernummer_new" value="$form->{$steuernummer_new}">
   print qq|
-
+          <input type=hidden name="callback" value="$callback">
           <input type=hidden name="nextsub" value="edit_form">
           <input type=hidden name="warnung" value="1">
           <input type=hidden name="saved" value="|
@@ -1227,26 +1346,19 @@ sub edit_form {
     if ($form->{saved} eq $locale->text('saved'));
 
   # Auf Übergabefehler checken
-  USTVA::info(
-    $locale->text(
-      'Bitte das Bundesland UND die Stadt bzw. den Einzugsbereich Ihres zuständigen Finanzamts auswählen.'
-    ))
+  USTVA::info(  $locale->text('Missing Tax Authoritys Preferences') . "\n"
+              . $locale->text('USTVA-Hint: Tax Authoritys'))
     if (   $form->{elsterFFFF_new} eq 'Auswahl'
         || $form->{elsterland_new} eq 'Auswahl');
-  USTVA::info(
-    $locale->text(
-      'Es fehlen Angaben zur Versteuerung. 
-  Wenn Sie Ist Versteuert sind, wählen Sie die Einnahmen/Überschuß-Rechnung aus. 
-  Sind Sie Soll-Versteuert und Bilanzverpflichtet, dann wählen Sie Bilanz aus.'
-    ))
+  USTVA::info(  $locale->text('Missing Method!') . "\n"
+              . $locale->text('USTVA-Hint: Method'))
     if ($form->{method} eq '');
 
   # Klären, ob Variablen bereits befüllt sind UND ob veräderungen auf
   # der vorherigen Maske stattfanden: $change = 1(in der edit sub,
   # mittels get_config)
 
-  my $change =
-       $form->{elsterland} eq $form->{elsterland_new}
+  my $change = $form->{elsterland} eq $form->{elsterland_new}
     && $form->{elsterFFFF} eq $form->{elsterFFFF_new} ? '0' : '1';
   $change = '0' if ($form->{saved} eq $locale->text('saved'));
   my $elster_init = &elster_hash();
@@ -1307,8 +1419,7 @@ sub edit_form {
    <table width="100%">
        <tr>
         <th colspan="2" class="listtop">|
-    . $locale->text('Finanzamt - Einstellungen')
-    . qq|</th>
+    . $locale->text('Finanzamt - Einstellungen') . qq|</th>
        </tr>
        <tr>
          <td colspan=2>
@@ -1341,18 +1452,17 @@ sub edit_form {
       <tr>
          <td align="left">
 
-
-          <!--<input type=hidden name=nextsub value="debug">
-          <input type=submit class=submit name=action value="|
-    . $locale->text('debug') . qq|">
-          <input type=hidden name=nextsub value="test">
-          <input type=submit class=submit name=action value="|
-    . $locale->text('test')
-    . qq|">-->
           <input type=hidden name=lastsub value="edit">
-          <input type=submit class=submit name=action value="|
-    . $locale->text('back') . qq|">
-  |;
+          |;
+  print qq|<input type=submit class=submit name=action value="|
+    . $locale->text('back') . qq|">|
+    if ($form->{callback} eq '');
+
+  print qq|
+           <input type="button" name="Verweis" value="|
+    . $locale->text('Back to user config...') . qq|" 
+            onClick="self.location.href='$form->{callback}'">|
+    if ($form->{callback} ne '');
 
   if ($form->{warnung} eq "1") {
     print qq|
@@ -1383,7 +1493,7 @@ sub edit_form {
   my @variables = qw(FA_steuerberater_name FA_steuerberater_street
     FA_steuerberater_city FA_steuerberater_tel
     FA_voranmeld method
-    FA_dauerfrist FA_71 FA_Name elster
+    FA_dauerfrist FA_71 elster
     path login password type elster_init saved
   );
   my $variable = '';
@@ -1397,6 +1507,7 @@ sub edit_form {
           <input type=hidden name="warnung" value="$warnung">
           <input type=hidden name="elstersteuernummer" value="$elstersteuernummer">
           <input type=hidden name="steuernummer" value="$stnr">
+          <input type=hidden name="callback" value="$form->{callback}">
   </form>
   |;
   $lxdebug->leave_sub();
@@ -1443,8 +1554,15 @@ sub get_config {
 
   my ($userpath, $filename) = @_;
   my ($key,      $value)    = '';
-  open(FACONF, "$userpath/$filename")
-    or $form->error("$userpath/$filename : $!");
+  open(FACONF, "$userpath/$form->{login}_$filename")
+    or    #falls Datei nicht vorhanden ist
+    sub {
+    open(FANEW, ">$userpath/$form->{login}_$filename")
+      or $form->error("$userpath/$filename : $!");
+    close FANEW;
+    open(FACONF, "$userpath/$form->{login}_$filename")
+      or $form->error("$userpath/$form->{username}_$filename : $!");
+    };
   while (<FACONF>) {
     last if /^\[/;
     next if /^(#|\s)/;
@@ -1473,7 +1591,7 @@ sub get_config {
 
 sub save {
   $lxdebug->enter_sub();
-  my $filename = $form->{filename};
+  my $filename = "$form->{login}_$form->{filename}";
 
   #zuerst die steuernummer aus den part, parts_X_Y und delimiter herstellen
   create_steuernummer;
@@ -1540,8 +1658,7 @@ sub show_fa_daten {
                <fieldset>
                <legend>
                <font size="+1">|
-    . $locale->text('Finanzamt')
-    . qq| $form->{FA_Name}</font>
+    . $locale->text('Finanzamt') . qq| $form->{FA_Name}</font>
                </legend>
   |;
 
@@ -1558,6 +1675,16 @@ sub show_fa_daten {
                     </legend>
 
                   <table width="100%">
+                   <tr>
+                    <td>
+                    | . $locale->text('Finanzamt') . qq|
+                    </td>
+                   </tr>
+                   <tr>
+                    <td colspan="2">
+                     <input name="FA_Name" size="40" title="FA_Name" value="$form->{FA_Name}" $readonly>
+                    <td>
+                   </tr>
                    <tr>
                     <td colspan="2">
                      <input name="FA_Strasse" size="40" title="FA_Strasse" value="$form->{FA_Strasse}" $readonly>
@@ -1711,185 +1838,6 @@ sub show_fa_daten {
   $lxdebug->leave_sub();
 }
 
-sub create_winston {
-  $lxdebug->enter_sub();
-  &get_config($userspath, 'finanzamt.ini');
-
-  # There is no generic Linux GNU/GPL solution out for using ELSTER.
-  # In lack of availability linux users may use windows pendants. I choose
-  # WINSTON, because it's free of coast, it has an API and its tested under
-  # Linux using WINE.
-  # The author of WINSTON developed some c-code to realize ELSTER under
-  # WINDOWS and Linux (http://www.felfri.de/fa_xml/). Next year (2005) I start to
-  # develop a server side solution for LX-Office ELSTER under Linux and
-  # WINDOWS based on this c-code.
-  #
-  # You need to download WINSTON from http://www.felfri.de/winston/
-  # There (http://www.felfri.de/winston/download.htm) you'll find instructions
-  # about WINSTON under Linux WINE
-  # More infos about Winstons API: http://www.felfri.de/winston/schnittstellen.htm
-  my $azr  = '';
-  my $file = '';    # Filename for Winstonfile
-  $file .= 'U';     # 1. char 'U' = USTVA
-
-SWITCH:
-  {    # 2. and 3. char 01-12= Month 41-44= Quarter (azr:Abrechnungszeitraum)
-    $form->{duetyp} eq "01" && do {
-      $azr = "01";
-      last SWITCH;
-    };
-    $form->{duetyp} eq "02" && do {
-      $azr = "02";
-      last SWITCH;
-    };
-    $form->{duetyp} eq "03" && do {
-      $azr = "03";
-      last SWITCH;
-    };
-    $form->{duetyp} eq "04" && do {
-      $azr = "04";
-      last SWITCH;
-    };
-    $form->{duetyp} eq "05" && do {
-      $azr = "05";
-      last SWITCH;
-    };
-    $form->{duetyp} eq "06" && do {
-      $azr = "06";
-      last SWITCH;
-    };
-    $form->{duetyp} eq "07" && do {
-      $azr = "07";
-      last SWITCH;
-    };
-    $form->{duetyp} eq "08" && do {
-      $azr = "08";
-      last SWITCH;
-    };
-    $form->{duetyp} eq "09" && do {
-      $azr = "09";
-      last SWITCH;
-    };
-    $form->{duetyp} eq "10" && do {
-      $azr = "10";
-      last SWITCH;
-    };
-    $form->{duetyp} eq "11" && do {
-      $azr = "11";
-      last SWITCH;
-    };
-    $form->{duetyp} eq "12" && do {
-      $azr = "12";
-      last SWITCH;
-    };
-    $form->{duetyp} eq "A" && do {
-      $azr = "41";
-      last SWITCH;
-    };
-    $form->{duetyp} eq "B" && do {
-      $azr = "42";
-      last SWITCH;
-    };
-    $form->{duetyp} eq "C" && do {
-      $azr = "43";
-      last SWITCH;
-    };
-    $form->{duetyp} eq "D" && do {
-      $azr = "44";
-      last SWITCH;
-    };
-    do {
-      $form->error(
-        "Ungültiger Anmeldezeitraum.\n
-                                        Sie können für ELSTER nur einen monatlichen oder 
-                                        quartalsweisen Anmeldezeitraum auswählen."
-      );
-    };
-  }
-
-  $file .= $azr;
-
-  #4. and 5. char = year modulo 100
-  $file .= sprintf("%02d", $form->{year} % 100);
-
-  #6. to 18. char = Elstersteuernummer
-  #Beispiel: Steuernummer in Bayern
-  #111/222/33334 ergibt für UStVA Jan 2004: U01049111022233334
-
-  $file .= $form->{elsterFFFF};
-  $file .= $form->{elstersteuernummer};
-
-  #file suffix
-
-  $file .= '.xml';
-  $form->{elsterfile} = $file;
-
-  #Calculations
-
-  my $k51 =
-    sprintf("%d", $form->parse_amount(\%myconfig, $form->{"51"}))
-    ;    # Umsätze zu 16% USt
-  my $k86 =
-    sprintf("%d", $form->parse_amount(\%myconfig, $form->{"86"}))
-    ;    # Umsätze zu 7% USt
-  my $k97 =
-    sprintf("%d", $form->parse_amount(\%myconfig, $form->{"97"}))
-    ;    # 16% Steuerpflichtige innergemeinsachftliche Erwerbe
-  my $k93 =
-    sprintf("%d", $form->parse_amount(\%myconfig, $form->{"93"}))
-    ;    # 16% Steuerpflichtige innergemeinsachftliche Erwerbe
-  my $k94 =
-    sprintf("%d", $form->parse_amount(\%myconfig, $form->{"94"}))
-    ;    # neuer Fahrzeuge von Lieferern
-  my $k66 =
-    $form->parse_amount(\%myconfig, $form->{"66"}) *
-    100;    # Vorsteuer 7% plus 16%
-  my $k83 =
-    $form->parse_amount(\%myconfig, $form->{"67"}) * 100;   # Umsätze zu 7% USt
-  my $k96 = $form->parse_amount(\%myconfig, $form->{"96"}) * 100;    #
-                                                                     #
-        # Now build the xml content
-        #
-
-  $form->{elster} = qq|<?xml version="1.0" encoding="ISO-8859-1" ?>
-<!-- Diese Datei ist mit Lx-Office $form->{version} generiert -->
-<WinstonAusgang>
- <Formular Typ="UST"></Formular>
- <Ordnungsnummer>$form->{elstersteuernummer}</Ordnungsnummer>
- <AnmeldeJahr>$form->{year}</AnmeldeJahr>
- <AnmeldeZeitraum>$azr</AnmeldeZeitraum>
-  |;
-
-  $form->{elster} .= qq|<Kennzahl Nr="51">$k51</Kennzahl>\n| if ($k51 ne '0');
-  $form->{elster} .= qq|<Kennzahl Nr="86">$k86</Kennzahl>\n| if ($k86 ne '0');
-  $form->{elster} .= qq|<Kennzahl Nr="97">$k97</Kennzahl>\n| if ($k97 ne '0');
-  $form->{elster} .= qq|<Kennzahl Nr="93">$k93</Kennzahl>\n| if ($k93 ne '0');
-  $form->{elster} .= qq|<Kennzahl Nr="94">$k94</Kennzahl>\n| if ($k94 ne '0');
-  $form->{elster} .= qq|<Kennzahl Nr="96">$k96</Kennzahl>\n| if ($k96 ne '0');
-  $form->{elster} .= qq|<Kennzahl Nr="66">$k66</Kennzahl>\n| if ($k66 ne '0');
-  $form->{elster} .= qq|<Kennzahl Nr="83">$k83</Kennzahl>\n| if ($k83 ne '0');
-  $form->{elster} .= qq|\n</WinstonAusgang>\n\n|;
-
-  #$form->header;
-  #print qq|$form->{elsterfile}|;
-  #print qq|$form->{elster}|;
-  $SIG{INT} = 'IGNORE';
-
-  &save_winston;
-  $lxdebug->leave_sub();
-}
-
-sub save_winston {
-  $lxdebug->enter_sub();
-  my $elster     = $form->{elster};
-  my $elsterfile = $form->{elsterfile};
-  open(OUT, ">-") or $form->error("STDOUT : $!");
-  print OUT qq|Content-Type: application/file;
-Content-Disposition: attachment; filename="$elsterfile"\n\n|;
-  print OUT $elster;
-  close(OUT);
-  $lxdebug->leave_sub();
-}
 
 sub continue {
   $lxdebug->enter_sub();
@@ -1901,250 +1849,17 @@ sub continue {
   $lxdebug->leave_sub();
 }
 
-sub back { &{ $form->{lastsub} } }
-
-sub elster_hash {
+sub back {
   $lxdebug->enter_sub();
-  my $finanzamt = USTVA::query_finanzamt(\%myconfig, \%$form);
+  &{ $form->{lastsub} };
   $lxdebug->leave_sub();
-  return $finanzamt;
 }
 
-sub test {
-  $lxdebug->enter_sub();
-
-  # biegt nur den Testeintrag in Programm->Test auf eine Routine um
-
-  $form->header;
-  &elster_send;
-  $lxdebug->leave_sub();
-}
-
-sub elster_send {
-  $lxdebug->enter_sub();
-
-  #read config
-  my $elster_conf = &elster_conf();
-  &elster_xml();
-  use Cwd;
-  $form->{cwd}     = cwd();
-  $form->{tmpdir}  = $form->{cwd} . '/' . $elster_conf->{'path'};
-  $form->{tmpfile} = $elster_conf->{'err'};
-  my $caller = $elster_conf->{'call'}[0];
-
-  chdir("$form->{tmpdir}") or $form->error($form->cleanup . "chdir : $!");
-  my $send =
-    "faxmlsend $caller -config etc/faxmlsend.cnf -xml faxmlsend.xml -tt faxmlsend.tt -debug";
-
-  system("$send > $form->{tmpfile}");
-  $form->{tmpdir} .= "$elster_conf->{'path'}/";
-  $form->{tmpfile} = "faxmlsend.err";
-  $form->error($form->cleanup
-        . "faxmlsend : OFD meldet: Error 404 \n Internetseite nicht vorhanden")
-    if ($? eq '1024');
-  $form->error($form->cleanup
-    . "faxmlsend : No such File: faxmlsend.xml \n Fehlernummer: $? \n Problem beim öffnen der faxmlsend.xml"
-    )
-    if ($?);
-
-  # foreach my $line (&elster_feedback("$elster_conf->{'path'}")){
-  #   print qq|$line\n|;
-  # }
-  print qq|Log:<br>|;
-
-  #for (my $i=0; $i<= )
-  &elster_readlog();
-  print qq|\n ende\n|;
-  $lxdebug->leave_sub();
-}
-
-sub elster_readlog {
-  $lxdebug->enter_sub();
-  my $elster_conf = &elster_conf();
-  open(LOG, "$elster_conf->{'logfile'}")
-    or $form->error("$elster_conf->{'logfile'}: $!");
-  print qq|<listing>|;
-  my $log = '';
-  my $xml = '';
-  my $tmp = '';
-  while (<LOG>) {
-    my $i = 0;
-
-    #$_ =~ s/</&lt\;/;
-    #$_ =~ s/>/&gt\;/;
-    $_ =~ s/\s+//mg;
-
-    #$_ =~ s/\015\012//mg;
-    $_ =~ s/</\n</mg;
-
-    #$_ =~ s/\n\n+//mg;
-    if ($_ =~ /^\d\d\d\d\d\d/g) {
-      $log .= qq|$_<br>|;
-
-      #} elsif ($_ =~ /(<([^\/]*?)>)/ ) {
-    } elsif ($_ =~ /(<([^\/].*?)>(.*))/g) {
-
-      #$xml .= qq|$2 = $3\n\n|;
-      #$_ =~ s/\015\012//mg;
-      $_ =~ s/\s+//;
-      $xml .= qq|$_\n|;
-
-    } else {
-      $tmp .= qq|$_<br>|;
-    }
-    $i++;
-  }
-
-  #second parse
-  #my $var='';
-  #while (<$xml>){
-  #  $var .= qq|$2 = $3\n\n|;
-  #}
-  #print qq|$log|;
-  print qq|$xml|;
-  print qq|</listing>|;
-
-  # $_=$log;
-  #  s{<(\w+)\b([^<>]*)>
-  #    ((?:.(?!</?\1\b))*.)
-  #      (<\1>) }
-  #   { print "markup=",$1," args=",$2," enclosed=",$3," final=",$4 ; "" }gsex;
-  close LOG;
-  $lxdebug->leave_sub();
-}
-
-sub elster_feedback {
-  $lxdebug->enter_sub();
-  my ($file) = @_;
-  my @content = ();
-  print qq|feedback:<br>|;
-  if (-f "$file") {
-    open(FH, "$file");
-    @content = <FH>;
-    close(FH);
-  }
-  $lxdebug->leave_sub();
-  return (@content);
-}
-
-sub elster_conf {
+sub elster_hash {
   $lxdebug->enter_sub();
-  my $elster_conf = { 'path'     => 'elster',
-                      'prg'      => 'faxmlsend',
-                      'err'      => 'faxmlsend.err',
-                      'ttfile'   => 'faxmlsend.tt',
-                      'xmlfile'  => 'faxmlsend.xml',
-                      'cline'    => '-tt $ttfile -xml $xmlfile',
-                      'call'     => ['send', 'protokoll', 'anmeldesteuern'],
-                      'logfile'  => 'log/faxmlsend.log',
-                      'conffile' => 'faxmlsend.cnf',
-                      'debug'    => '-debug' };
-
+  my $finanzamt = USTVA::query_finanzamt(\%myconfig, \%$form);
   $lxdebug->leave_sub();
-
-  return $elster_conf;
+  return $finanzamt;
 }
 
-sub elster_xml {
-  $lxdebug->enter_sub();
-
-  my $elster_conf = &elster_conf();
-
-  #  $k51 = sprintf("%d", $form->parse_amount(\%myconfig, $form->{"51"})); # Umsätze zu 16% USt
-  #  $k86 = sprintf("%d", $form->parse_amount(\%myconfig, $form->{"86"})); # Umsätze zu 7% USt
-  #  $k97 = sprintf("%d", $form->parse_amount(\%myconfig, $form->{"97"})); # 16% Steuerpflichtige innergemeinsachftliche Erwerbe
-  #  $k93 = sprintf("%d", $form->parse_amount(\%myconfig, $form->{"93"})); # 16% Steuerpflichtige innergemeinsachftliche Erwerbe
-  #  $k94 = sprintf("%d", $form->parse_amount(\%myconfig, $form->{"94"})); # neuer Fahrzeuge von Lieferern
-  #  $k66 = $form->parse_amount(\%myconfig, $form->{"66"}) * 100;# Vorsteuer 7% plus 16%
-  #  $k83 = $form->parse_amount(\%myconfig, $form->{"67"}) * 100;# Umsätze zu 7% USt
-  #  $k96 = $form->parse_amount(\%myconfig, $form->{"96"}) * 100;#
-
-  my $TransferHeader = qq|<?xml version="1.0" encoding="ISO-8859-1"?>
-<?xml-stylesheet type="text/xsl" href="..\\Stylesheet\\ustva.xsl"?>
-<Elster xmlns="http://www.elster.de/2002/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.elster.de/2002/XMLSchema
-..\\Schemata\\elster_UStA_200501_extern.xsd">
-   <TransferHeader version="7">
-      <Verfahren>ElsterAnmeldung</Verfahren>
-      <DatenArt>UStVA</DatenArt>
-      <Vorgang>send-NoSig</Vorgang>
-      <Testmerker>700000004</Testmerker>
-      <HerstellerID>74931</HerstellerID>
-      <DatenLieferant>Helmut</DatenLieferant>
-      <Datei>
-        <Verschluesselung>PKCS#7v1.5</Verschluesselung>
-        <Kompression>GZIP</Kompression>
-        <DatenGroesse>123456789012345678901234567890123456789012</DatenGroesse>
-        <TransportSchluessel/>
-      </Datei>
-      <RC>
-        <Rueckgabe>
-          <Code>0</Code>
-          <Text/>
-        </Rueckgabe>
-        <Stack>
-          <Code>0</Code>
-          <Text/>
-        </Stack>
-      </RC>
-      <VersionClient/>
-      <Zusatz>
-        <Info>test</Info>
-      </Zusatz>
-   </TransferHeader>|;
-
-  my $DatenTeil = qq|
-   <DatenTeil>
-      <Nutzdatenblock>
-         <NutzdatenHeader version="9">
-            <NutzdatenTicket>234234234</NutzdatenTicket>
-            <Empfaenger id="F">9198</Empfaenger>
-            <Hersteller>
-               <ProduktName>ElsterAnmeldung</ProduktName>
-               <ProduktVersion>V 1.4</ProduktVersion>
-            </Hersteller>
-            <DatenLieferant>String, der Lieferanteninfo enthaelt</DatenLieferant>
-            <Zusatz>
-              <Info>....</Info>
-            </Zusatz>
-         </NutzdatenHeader>
-         <Nutzdaten>
-            <!--die Version gibt Auskunft ueber das Jahr und die derzeit gueltige Versionsnummer-->
-            <Anmeldungssteuern art="UStVA" version="200501">
-               <DatenLieferant>
-                  <Name>OFD Muenchen</Name>
-                  <Strasse>Meiserstr. 6</Strasse>
-                  <PLZ>80335</PLZ>
-                  <Ort>München</Ort>
-               </DatenLieferant>
-               <Erstellungsdatum>20041127</Erstellungsdatum>
-               <Steuerfall>
-                  <Umsatzsteuervoranmeldung>
-                     <Jahr>2005</Jahr>
-                     <Zeitraum>01</Zeitraum>
-                     <Steuernummer>9198011310134</Steuernummer>
-                     <Kz09>74931*NameSteuerber.*Berufsbez.*089*59958327*Mandantenname</Kz09>
-                  </Umsatzsteuervoranmeldung>
-               </Steuerfall>
-            </Anmeldungssteuern>
-         </Nutzdaten>
-      </Nutzdatenblock>
-   </DatenTeil>
-</Elster>\n|;
-
-  #$DatenTeil .= qq|                              <Kz51>$k51</Kz51>\n| if ($k51 ne '0');
-  #$DatenTeil .= qq|                              <Kz86>$k86</Kz86>\n| if ($k86 ne '0');
-  #$DatenTeil .= qq|                              <Kz97>$k97</Kz97>\n| if ($k97 ne '0');
-  #$DatenTeil .= qq|                              <Kz93>$k93</Kz93>\n| if ($k93 ne '0');
-  #$DatenTeil .= qq|                              <Kz94>$k94</Kz94>\n| if ($k94 ne '0');
-  #$DatenTeil .= qq|                              <Kz96>$k96</Kz96>\n| if ($k96 ne '0');
-  #$DatenTeil .= qq|                              <Kz66>$k66</Kz66>\n| if ($k66 ne '0');
-  #$DatenTeil .= qq|                              <Kz83>$k83</Kz83>\n| if ($k83 ne '0');
-
-  my $filename = "$elster_conf->{'path'}/$elster_conf->{'xmlfile'}";
-  open(XML, ">$elster_conf->{'path'}/$elster_conf->{'xmlfile'}")
-    or $form->error("$filename : $!");
-  print XML qq|$TransferHeader $DatenTeil|;
-  close XML;
-  $lxdebug->leave_sub();
-}