Spoolen: Spool-Dateien nach Erzeugen des temp. Namens nicht direkt wieder löschen
[kivitendo-erp.git] / bin / mozilla / ustva.pl
index 9953806..d5c42a0 100644 (file)
@@ -23,6 +23,7 @@
 # German Tax authority Module and later ELSTER Interface
 #======================================================================
 
+use strict;
 use utf8;
 
 require "bin/mozilla/common.pl";
@@ -94,7 +95,7 @@ sub report {
 
   # Einlesen der Finanzamtdaten
   my $ustva = USTVA->new();
-  $ustva->get_config($::userspath, 'finanzamt.ini');
+  $ustva->get_config($::lx_office_conf{paths}{userspath}, 'finanzamt.ini');
 
   # Hier Einlesen der user-config
   # steuernummer entfernt für prerelease
@@ -502,7 +503,7 @@ sub show_options {
       qq|       <option value=html selected>|
     . $::locale->text('Preview')
     . qq|</option>|;
-  if ($::latex_templates) {
+  if ($::lx_office_conf{print_templates}{latex}) {
     $format .=
         qq|    <option value=pdf>|
       . $::locale->text('UStVA (PDF-Dokument)')
@@ -545,7 +546,7 @@ sub generate_ustva {
   # Aufruf von get_config zum Einlesen der Finanzamtdaten aus finanzamt.ini
 
   my $ustva = USTVA->new();
-  $ustva->get_config($::userspath, 'finanzamt.ini');
+  $ustva->get_config($::lx_office_conf{paths}{userspath}, 'finanzamt.ini');
 
   # init some form vars
   my @anmeldungszeitraum =
@@ -775,7 +776,7 @@ sub generate_ustva {
         dec_places  => '2',
     });
 
-    push @category_cent, qw(83  Z43  Z45  Z53  Z62  Z65  Z67);
+    push @category_cent, qw(Z43  Z45  Z53  Z62  Z65  Z67);
 
     my @category_euro = $ustva->report_variables({
         myconfig    => \%myconfig,
@@ -847,7 +848,6 @@ sub generate_ustva {
       #file suffix
       $file .= '.xml';
       $file =~ s|.*/||;
-      $form->{tmpfile} = "$::userspath/$file";
 
       $form->{attachment_filename} = $file;
 
@@ -855,9 +855,9 @@ sub generate_ustva {
 
       my $temp_numberformat = $myconfig{numberformat};
 
-      # Numberformat must be '1000.00' for Winston
+      # Numberformat must be '1000,00' for Winston
 
-      $myconfig{numberformat} = '1000.00';
+      $myconfig{numberformat} = '1000,00';
 
       foreach my $number (@category_cent) {
         $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '2', '') : '';
@@ -893,11 +893,9 @@ sub generate_ustva {
       # Define serveral filenames
       $form->{IN} = 'taxbird.txb';
 
-      $form->{attachment_filename} = "USTVA-" . $form->{period}
-      . sprintf("%02d", $form->{year} % 100) . ".txb";
+      $form->{attachment_filename} = "USTVA-" . ($form->{period} * 1) . sprintf("%02d", $form->{year} % 100) . ".txb";
 
       $form->{attachment_filename} =~ s|.*/||;
-      $form->{tmpfile} = "$::userspath/" . $form->{attachment_filename};
 
       # TODO: set Output to UTF-8 or system Preference
       #$form->{"iconv"} = Text::Iconv->new($myconfig{dbcharset}, "UTF-8");
@@ -1078,7 +1076,7 @@ sub generate_ustva {
   } else
   {
 
-    $form->parse_template(\%myconfig, $::userspath);
+    $form->parse_template(\%myconfig, $::lx_office_conf{paths}{userspath});
 
   }
 
@@ -1097,7 +1095,7 @@ $::form->{title} = $::locale->text('Tax Office Preferences');
   $::form->header;
 
   my $ustva = USTVA->new();
-  $ustva->get_config($::userspath, 'finanzamt.ini');
+  $ustva->get_config($::lx_office_conf{paths}{userspath}, 'finanzamt.ini');
 
   my $land = $::form->{elsterland};
   my $amt  = $::form->{elsterFFFF};
@@ -1106,13 +1104,13 @@ $::form->{title} = $::locale->text('Tax Office Preferences');
   $::form->{title} = $::locale->text('Tax Office Preferences');
 
 
-  my $select_tax_office = $ustva->fa_auswahl($land, $amt, $ustva->query_finanzamt(\%::myconfig, $::form));
-  my $checked_accrual = q|checked="checked"| if ($::form->{method} eq 'accrual');
-  my $checked_cash = q|checked="checked"| if ($::form->{method} eq 'cash');
-  my $checked_monthly = "checked" if ($::form->{FA_voranmeld} eq 'month');
-  my $checked_quarterly = "checked" if ($::form->{FA_voranmeld} eq 'quarter');
-  my $checked_dauerfristverlaengerung = "checked" if ($::form->{FA_dauerfrist} eq '1');
-  my $checked_kz_71 = "checked" if ($::form->{FA_71} eq 'X');
+  my $select_tax_office               = $ustva->fa_auswahl($land, $amt, $ustva->query_finanzamt(\%::myconfig, $::form));
+  my $checked_accrual                 = $::form->{method}        eq 'accrual' ? q|checked="checked"| : '';
+  my $checked_cash                    = $::form->{method}        eq 'cash'    ? q|checked="checked"| : '';
+  my $checked_monthly                 = $::form->{FA_voranmeld}  eq 'month'   ? "checked"            : '';
+  my $checked_quarterly               = $::form->{FA_voranmeld}  eq 'quarter' ? "checked"            : '';
+  my $checked_dauerfristverlaengerung = $::form->{FA_dauerfrist} eq '1'       ? "checked"            : '';
+  my $checked_kz_71                   = $::form->{FA_71}         eq 'X'       ? "checked"            : '';
 
   my $_hidden_variables_ref;
 
@@ -1179,17 +1177,13 @@ sub config_step2 {
 
   $form->header();
 
-#  print qq|
-#    <body>
-#  |;
-
   my $elsterland         = '';
   my $elster_amt         = '';
   my $elsterFFFF         = '';
   my $elstersteuernummer = '';
 
   my $ustva = USTVA->new();
-  $ustva->get_config($::userspath, 'finanzamt.ini')
+  $ustva->get_config($::lx_office_conf{paths}{userspath}, 'finanzamt.ini')
     if ($form->{saved} eq $locale->text('saved'));
 
   # Auf Übergabefehler checken
@@ -1224,11 +1218,7 @@ sub config_step2 {
     create_steuernummer();
 
     # rebuild elster_amt
-    my $amt = '';
-    foreach $amt (keys %{ $elster_init{ $form->{elsterland} } }) {
-      $elster_amt = $amt
-        if ($elster_init{ $form->{elsterland}{$amt} eq $form->{elsterFFFF} });
-    }
+    my $amt = $elster_init{$elsterFFFF};
 
     # load the predefined hash data into the FA_* Vars
     my @variables = qw(FA_Name FA_Strasse FA_PLZ FA_Ort
@@ -1254,7 +1244,7 @@ sub config_step2 {
   my $patterncount   = $form->{patterncount};
   my $elster_pattern = $form->{elster_pattern};
   my $delimiter      = $form->{delimiter};
-  my $steuernummer = $form->{steuernummer} if ($stnr eq '');
+  my $steuernummer   = $stnr eq '' ? $form->{steuernummer} : '';
 
   $form->{FA_Oeffnungszeiten} =~ s/\\\\n/\n/g;
 
@@ -1391,7 +1381,7 @@ sub save {
 
     $::form->{elster} = '1';
 
-    open my $ustvaconfig, ">", "$::userspath/$filename" or $::form->error("$filename : $!");
+    open my $ustvaconfig, ">", "$::lx_office_conf{paths}{userspath}/$filename" or $::form->error("$filename : $!");
 
     # create the config file
     print {$ustvaconfig} qq|# Configuration file for USTVA\n\n|;