commit ccd0b365250f57021a756203f65a4d153709b45d
Author: Udo Spallek <info@wissensvermittlung.com>
Date:   Wed Jul 18 09:12:11 2007 +0000

    Generischer USTVA Report für alle Kontenrahmen ausser Germany

diff --git a/SL/USTVA.pm b/SL/USTVA.pm
index 365520874..658e2c766 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);
 
diff --git a/bin/mozilla/ustva.pl b/bin/mozilla/ustva.pl
index b7b66fbbc..4229d24c3 100644
--- a/bin/mozilla/ustva.pl
+++ b/bin/mozilla/ustva.pl
@@ -197,12 +197,16 @@ sub report {
     }
   ];
  
+  # Which COA is in use? 
   
+  USTVA->get_coa($form, $myconfig);
+
   my $template_ref = {
     openings         => $openings,  
     company_given    => $company_given,
     address_given    => $address_given,     
     taxnumber_given  => $taxnumber_given,
+    taxnumber        => $myconfig->{taxnumber},
     select_year      => $select_year,      
     period_local     => $period_local,
     method_local     => $method_local,
@@ -210,6 +214,7 @@ sub report {
     checkbox_kz_10   => $checkbox_kz_10,
     tax_office_banks => $tax_office_banks_ref,    
     select_options   => &show_options,    
+
   };
   
   print($form->parse_html_template('ustva/report', $template_ref));
@@ -1005,39 +1010,45 @@ sub generate_ustva {
       exit(0);
     }
 
-  # Austria
-  } elsif ($form->{coa} eq 'Austria') {
-
-    #
-    # Outputformat specific customisation's
-    #
+  
+  } else  # Outputformat for generic output
+  {
 
-    my @category_euro = qw(
-      511 861 36   80   971  931  98   96   53   74
-      85  65  66   61   62   67   63   64   59   69 
-      39  83  811  891  Z43  Z45  Z53  Z62  Z65  Z67
-      41 44 49 43 48 51 86 35 77 76 91 89
-      97 93 95 94 42 60 45 52 73 84 81 
-    );
-    
+    my @category_cent = USTVA->report_variables({
+        myconfig    => \%myconfig,
+        form        => $form,
+        type        => '',
+        attribute   => 'position',
+        dec_places  => '2',
+    });
 
-    if ( $form->{format} eq 'html') { # Formatierungen f�r HTML Ausgabe
+    my @category_euro = USTVA->report_variables({
+        myconfig    => \%myconfig,
+        form        => $form,
+        type        => '',
+        attribute   => 'position',
+        dec_places  => '0',
+    });
 
-      $form->{IN} = $form->{type} . '.html';
-      $form->{padding} = "&nbsp;&nbsp;";
-      $form->{bold}    = "<b>";
-      $form->{endbold} = "</b>";
-      $form->{br}      = "<br>";
-      $form->{address} =~ s/\\n/\n/g;
+    $form->{"Watchdog::USTVA"} = 1;
+    $form->{USTVA} = [];
 
-      foreach $number (@category_euro) {
-        $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '0');
+    if ( $form->{format} eq 'generic') { # Formatierungen f�r HTML Ausgabe
+      
+      my $rec_ref = {};
+      for my $kennziffer (@category_cent, @category_euro) {
+        $rec_ref = {};
+        $rec_ref->{id} = $kennziffer;
+        $rec_ref->{amount} = $form->format_amount(\%myconfig, $form->{$kennziffer}, 2, '0');
+        
+        $lxdebug->message($LXDebug::DEBUG, "Kennziffer $kennziffer: '$form->{$kennziffer}'" );
+        $lxdebug->dump($LXDebug::DEBUG, $rec_ref );
+        push @ { $form->{USTVA} }, $rec_ref;
       }
+      
     }
-    
-  }
 
-  # end nation specific customisations
+  }
   
   if ( $form->{period} eq '13' and $form->{format} ne 'html') {
     $form->header;
@@ -1050,7 +1061,22 @@ sub generate_ustva {
   $form->{templates} = $myconfig{templates};
   $form->{templates} = "doc" if ( $form->{type} eq 'help' );
 
-  $form->parse_template(\%myconfig, $userspath);
+  if ($form->{format} eq 'generic'){
+
+    $form->header();
+
+    $template_ref = {
+        taxnumber => $myconfig{taxnumber},
+    };
+
+    print($form->parse_html_template2('ustva/generic_taxreport', $template_ref));
+
+  } else
+  { 
+
+    $form->parse_template(\%myconfig, $userspath);
+
+  }
 
   $lxdebug->leave_sub();
 }
@@ -1115,6 +1141,10 @@ sub config_step1 {
         { 'variable' => $variable, 'value' => $form->{$variable} };
   }
 
+# Which COA is in use? 
+  
+  USTVA->get_coa($form, \%myconfig);
+
   # h�? kann die weg?
   my $steuernummer_new = '';
 
@@ -1257,8 +1287,6 @@ sub config_step2 {
     saved                   callback
   );
 
-
-
   foreach my $variable (@_hidden_form_variables) {
     push @{ $_hidden_variables_ref}, 
         { 'variable' => $variable, 'value' => $form->{$variable} };
diff --git a/locale/de/all b/locale/de/all
index 6103e469f..c970c9e71 100644
--- a/locale/de/all
+++ b/locale/de/all
@@ -527,6 +527,7 @@ aktualisieren wollen?',
   'From'                        => 'Von',
   'GL Transaction'              => 'Dialogbuchung',
   'General Ledger'              => 'Finanzbuchhaltung',
+  'Generic Tax Report'          => 'USTVA Bericht',
   'Given Name'                  => 'Vorname',
   'Greeting'                    => 'Anrede',
   'Group'                       => 'Warengruppe',
@@ -543,8 +544,6 @@ aktualisieren wollen?',
   'Help'                        => 'Hilfe',
   'Here\'s an example command line:' => 'Hier ist eine Kommandozeile, die als Beispiel dient:',
   'Hide by default'             => 'Standardm&auml;&szlig;ig verstecken',
-  'Hint-Missing-Preferences'    => 'Bitte fehlende USTVA Einstellungen erg�nzen (Men�punkt: System-> UStVA Einstellungen)',
-  'Hints'                       => 'Hinweise',
   'History'                     => 'Historie',
   'History Search'              => 'Historien Suche',
   'History Search Engine'       => 'Historien Suchmaschine',
@@ -710,7 +709,6 @@ aktualisieren wollen?',
   'Missing \'description\' field.' => 'Fehlendes Feld \'description\'.',
   'Missing \'tag\' field.'      => 'Fehlendes Feld \'tag\'.',
   'Missing Method!'             => 'Fehlender Voranmeldungszeitraum',
-  'Missing Preferences: Outputroutine disabled' => 'Die Ausgabefunktionen sind wegen unzureichender Voreinstellungen deaktiviert!',
   'Missing Tax Authoritys Preferences' => 'Fehlende Angaben zum Finanzamt!',
   'Missing amount'              => 'Fehlbetrag',
   'Mitarbeiter'                 => 'Mitarbeiter',
@@ -851,6 +849,8 @@ aktualisieren wollen?',
   'Please enter a license key.' => 'Bitte geben Sie einen Lizenzschl�ssel an.',
   'Please enter a number of licenses.' => 'Bitte geben Sie die Anzahl Lizenzschl�ssel an.',
   'Please enter the name of the dataset you want to restore the backup in.' => 'Bitte geben Sie den Namen der Datenbank ein, in der Sie die Sicherung wiederherstellen wollen.',
+  'Please enter the taxnumber in the administration menu userpreferences' => 'Bitte bei den Einstellungen des aktuellen Benutzers im Administrationsmodul
+  angeben.',
   'Please enter values'         => 'Bitte Werte eingeben',
   'Please insert object dimensions below.' => 'Bitte geben Sie die Abmessungen unten ein',
   'Please insert your language values below' => 'Bitte die �bersetzungen unten eintragen',
@@ -1079,6 +1079,7 @@ aktualisieren wollen?',
   'Tax Percent is a number between 0 and 100' => 'Prozentsatz muss zwischen
   1% und 100% liegen',
   'Tax Period'                  => 'Voranmeldungszeitraum',
+  'Tax Position'                => 'Position',
   'Tax collected'               => 'vereinnahmte Steuer',
   'Tax deleted!'                => 'Steuer gel�scht!',
   'Tax number'                  => 'Steuernummer',
@@ -1096,6 +1097,7 @@ aktualisieren wollen?',
   'Taxkey_coa'                  => 'Steuerschl�ssel',
   'Taxkeys and Taxreport Preferences' => 'Steuerautomatik und UStVA',
   'Taxlink_coa'                 => 'Steuerautomatik',
+  'Taxnumber'                   => 'Steuernummer',
   'Taxrate missing!'            => 'Prozentsatz fehlt!',
   'Tel'                         => 'Tel',
   'Tel.'                        => 'Telefon',
diff --git a/templates/webpages/ustva/config_step1_de.html b/templates/webpages/ustva/config_step1_de.html
index 3ff7b9b62..9b05b7ce4 100644
--- a/templates/webpages/ustva/config_step1_de.html
+++ b/templates/webpages/ustva/config_step1_de.html
@@ -11,13 +11,14 @@
     <tr>
      <td>
        <br />
+<TMPL_IF COA_Germany>
        <fieldset>
        <legend><b>Angaben zum Finanzamt</b></legend>
        <br />
        <TMPL_VAR select_tax_office>
        </fieldset>
        <br />
-       
+</TMPL_IF>
        <fieldset>
        <legend><b>Versteuerungs Verfahren</b>
        </legend>
diff --git a/templates/webpages/ustva/config_step1_master.html b/templates/webpages/ustva/config_step1_master.html
index ab985b4ef..4f5421fbe 100644
--- a/templates/webpages/ustva/config_step1_master.html
+++ b/templates/webpages/ustva/config_step1_master.html
@@ -11,13 +11,14 @@
     <tr>
      <td>
        <br />
+<TMPL_IF COA_Germany>
        <fieldset>
        <legend><b><translate>Local Tax Office Preferences</translate></b></legend>
        <br />
        <TMPL_VAR select_tax_office>
        </fieldset>
        <br />
-       
+</TMPL_IF>
        <fieldset>
        <legend><b><translate>Taxation</translate></b>
        </legend>
diff --git a/templates/webpages/ustva/config_step2_de.html b/templates/webpages/ustva/config_step2_de.html
index 6f1290bdb..07c0d2682 100644
--- a/templates/webpages/ustva/config_step2_de.html
+++ b/templates/webpages/ustva/config_step2_de.html
@@ -155,7 +155,14 @@
            <font size="+1">Steuernummer</font>
            </legend>
            <br>
+<TMPL_IF COA_Germany>
            <TMPL_VAR input_steuernummer>
+<TMPL_ELSE>
+Bitte bei den Einstellungen des aktuellen Benutzers im Administrationsmodul
+  angeben.
+</TMPL_IF>
+
+
            </H2><br>
            </fieldset>
            <br>
diff --git a/templates/webpages/ustva/config_step2_master.html b/templates/webpages/ustva/config_step2_master.html
index 1ec0294fd..616a292dd 100644
--- a/templates/webpages/ustva/config_step2_master.html
+++ b/templates/webpages/ustva/config_step2_master.html
@@ -155,7 +155,14 @@
            <font size="+1"><translate>Tax Number</translate></font>
            </legend>
            <br>
+<TMPL_IF COA_Germany>
            <TMPL_VAR input_steuernummer>
+<TMPL_ELSE>
+<translate>Please enter the taxnumber in the administration menu user
+preferences</translate>
+</TMPL_IF>
+
+
            </H2><br>
            </fieldset>
            <br>
diff --git a/templates/webpages/ustva/generic_taxreport_de.html b/templates/webpages/ustva/generic_taxreport_de.html
new file mode 100644
index 000000000..cf5a021ac
--- /dev/null
+++ b/templates/webpages/ustva/generic_taxreport_de.html
@@ -0,0 +1,26 @@
+[% USE HTML %]<body>
+
+<h1>USTVA Bericht</h1>
+<p>Steuernummer: [% taxnumber %]</p>
+<p>Jahr: [% year %]</p>
+<p>Zeitraum: [% period %]</p>
+<br />
+<table width="33%">
+  <tr>
+    <th>Position</th>
+    <th>Betrag</th>
+  </tr>
+[% SET row_odd = '1' %]
+[% FOREACH row = USTVA %]
+  <tr class="listrow[% IF row_odd %]1[% SET row_odd = '0' %][% ELSE %]0[%
+SET row_odd = '1' %][% END %]">
+
+    <td align="left">[% HTML.escape(row.id) %]</td>
+    <td align="right">[% HTML.escape(row.amount) %]</td>
+  </tr>
+[% END %]
+
+</table>
+
+</html>
+</body>
diff --git a/templates/webpages/ustva/generic_taxreport_master.html b/templates/webpages/ustva/generic_taxreport_master.html
new file mode 100644
index 000000000..c93a95565
--- /dev/null
+++ b/templates/webpages/ustva/generic_taxreport_master.html
@@ -0,0 +1,26 @@
+[% USE HTML %]<body>
+
+<h1><translate>Generic Tax Report</translate></h1>
+<p><translate>Taxnumber</translate>: [% taxnumber %]</p>
+<p><translate>Year</translate>: [% year %]</p>
+<p><translate>Period</translate>: [% period %]</p>
+<br />
+<table width="33%">
+  <tr>
+    <th><translate>Tax Position</translate></th>
+    <th><translate>Amount</translate></th>
+  </tr>
+[% SET row_odd = '1' %]
+[% FOREACH row = USTVA %]
+  <tr class="listrow[% IF row_odd %]1[% SET row_odd = '0' %][% ELSE %]0[%
+SET row_odd = '1' %][% END %]">
+
+    <td align="left">[% HTML.escape(row.id) %]</td>
+    <td align="right">[% HTML.escape(row.amount) %]</td>
+  </tr>
+[% END %]
+
+</table>
+
+</html>
+</body>
\ No newline at end of file
diff --git a/templates/webpages/ustva/report_de.html b/templates/webpages/ustva/report_de.html
index 2411b4dde..dd4b75d0b 100644
--- a/templates/webpages/ustva/report_de.html
+++ b/templates/webpages/ustva/report_de.html
@@ -37,14 +37,18 @@
             <TMPL_VAR co_email ESCAPE=HTML>
             <br />
             <br />
+
             Steuernummer:&nbsp;
+<TMPL_IF COA_Germany>
             <TMPL_VAR taxnumber_given>
             <br />
             ELSTER-Steuernummer:&nbsp;
             <TMPL_VAR elstersteuernummer ESCAPE=HTML>
             <br />
             <br />
-
+<TMPL_ELSE>
+            <TMPL_VAR taxnumber>
+</TMPL_IF>
             </fieldset>
             <br />
             
@@ -52,12 +56,12 @@
               <fieldset>
               <legend>
                 <input checked="checked" 
-                 title = "Beraterdaten in UStVA �bernehmen?"
-                 name = "FA_steuerberater" 
-                 id = "steuerberater" 
-                 class = "checkbox" 
-                 type = "checkbox"
-                 value = "1" >
+                 title="Beraterdaten in UStVA �bernehmen?"
+                 name="FA_steuerberater" 
+                 id="steuerberater" 
+                 class="checkbox" 
+                 type="checkbox"
+                 value="1" >
                  &nbsp;<b>Steuerberater/-in</b>
                 </legend>
                 
@@ -91,9 +95,6 @@
             </fieldset>
           </td>
           <td width="50%" valign="top">	  
-
-<!--            TMPL_IF FA_Name                   -->
-
               <fieldset>
               <legend>
                  <b>Finanzamt</b>
@@ -160,26 +161,15 @@
               <legend>
               <b>Ausgabeformat</b>
               </legend>
+<TMPL_IF COA_Germany>
               <TMPL_VAR select_options>
-              </fieldset>
-              
-            <TMPL_ELSE>
+<TMPL_ELSE>
+              <SELECT name="format">
+                <option value="generic">Druckvorschau</option>
+              </SELECT>
+</TMPL_if>
 
-              <td width="50%" valign="bottom">
-              <fieldset>
-              <legend>
-              <b>Hinweise</b>
-              </legend>
-              <h2 class="confirm">
-              Die Ausgabefunktionen sind wegen unzureichender Voreinstellungen deaktiviert!
-              </h2>
-              <h3>Hilfe</h3>
-              <ul>
-              <li>Bitte fehlende USTVA Einstellungen erg�nzen (Men�punkt: System-> UStVA Einstellungen)</li>
-              </ul>
               </fieldset>
-
-            </TMPL_IF>
           </td>
         </tr>
       </table>
diff --git a/templates/webpages/ustva/report_master.html b/templates/webpages/ustva/report_master.html
index 9f195539e..09ae195a0 100644
--- a/templates/webpages/ustva/report_master.html
+++ b/templates/webpages/ustva/report_master.html
@@ -37,14 +37,18 @@
             <TMPL_VAR co_email ESCAPE=HTML>
             <br />
             <br />
+
             <translate>Tax Number</translate>:&nbsp;
+<TMPL_IF COA_Germany>
             <TMPL_VAR taxnumber_given>
             <br />
             <translate>ELSTER Tax Number</translate>:&nbsp;
             <TMPL_VAR elstersteuernummer ESCAPE=HTML>
             <br />
             <br />
-
+<TMPL_ELSE>
+            <TMPL_VAR taxnumber>
+</TMPL_IF>
             </fieldset>
             <br />
             
@@ -52,12 +56,12 @@
               <fieldset>
               <legend>
                 <input checked="checked" 
-                 title = "<translate>Assume Tax Consultant Data in Tax Computation?</translate>"
-                 name = "FA_steuerberater" 
-                 id = "steuerberater" 
-                 class = "checkbox" 
-                 type = "checkbox"
-                 value = "1" >
+                 title="<translate>Assume Tax Consultant Data in Tax Computation?</translate>"
+                 name="FA_steuerberater" 
+                 id="steuerberater" 
+                 class="checkbox" 
+                 type="checkbox"
+                 value="1" >
                  &nbsp;<b><translate>Tax Consultant</translate></b>
                 </legend>
                 
@@ -91,9 +95,6 @@
             </fieldset>
           </td>
           <td width="50%" valign="top">	  
-
-<!--            TMPL_IF FA_Name                   -->
-
               <fieldset>
               <legend>
                  <b><translate>Tax Office</translate></b>
@@ -160,27 +161,15 @@
               <legend>
               <b><translate>Outputformat</translate></b>
               </legend>
+<TMPL_IF COA_Germany>
               <TMPL_VAR select_options>
-              </fieldset>
-              
-            <TMPL_ELSE>
+<TMPL_ELSE>
+              <SELECT name="format">
+                <option value="generic"><translate>Preview</translate></option>
+              </SELECT>
+</TMPL_if>
 
-              <td width="50%" valign="bottom">
-              <fieldset>
-              <legend>
-              <b><translate>Hints</translate></b>
-              </legend>
-              <h2 class="confirm">
-              <translate>Missing Preferences: Outputroutine
-                 disabled</translate>
-              </h2>
-              <h3><translate>Help</translate></h3>
-              <ul>
-              <li><translate>Hint-Missing-Preferences</translate></li>
-              </ul>
               </fieldset>
-
-            </TMPL_IF>
           </td>
         </tr>
       </table>
