1 #=====================================================================
 
   3 # Copyright (c) 2004 by Udo Spallek, Aachen
 
   7 #     Web: http://www.lx-office.org
 
  10 # This program is free software; you can redistribute it and/or modify
 
  11 # it under the terms of the GNU General Public License as published by
 
  12 # the Free Software Foundation; either version 2 of the License, or
 
  13 # (at your option) any later version.
 
  15 # This program is distributed in the hope that it will be useful,
 
  16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  18 # GNU General Public License for more details.
 
  19 # You should have received a copy of the GNU General Public License
 
  20 # along with this program; if not, write to the Free Software
 
  21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
  22 #======================================================================
 
  23 # German Tax authority Module and later ELSTER Interface
 
  24 #======================================================================
 
  29 require "bin/mozilla/common.pl";
 
  34 #use warnings; # FATAL=> 'all';
 
  35 #use vars qw($locale $form %myconfig);
 
  37 #use CGI::Carp "fatalsToBrowser";
 
  39 use List::Util qw(first);
 
  47 # this is for our long dates
 
  48 # $locale->text('January')
 
  49 # $locale->text('February')
 
  50 # $locale->text('March')
 
  51 # $locale->text('April')
 
  52 # $locale->text('May ')
 
  53 # $locale->text('June')
 
  54 # $locale->text('July')
 
  55 # $locale->text('August')
 
  56 # $locale->text('September')
 
  57 # $locale->text('October')
 
  58 # $locale->text('November')
 
  59 # $locale->text('December')
 
  61 # this is for our short month
 
  62 # $locale->text('Jan')
 
  63 # $locale->text('Feb')
 
  64 # $locale->text('Mar')
 
  65 # $locale->text('Apr')
 
  66 # $locale->text('May')
 
  67 # $locale->text('Jun')
 
  68 # $locale->text('Jul')
 
  69 # $locale->text('Aug')
 
  70 # $locale->text('Sep')
 
  71 # $locale->text('Oct')
 
  72 # $locale->text('Nov')
 
  73 # $locale->text('Dec')
 
  75 #############################
 
  78   $::lxdebug->enter_sub();
 
  81   my $locale   = $::locale;
 
  82   my %myconfig = %::myconfig;
 
  84   $::auth->assert('advance_turnover_tax_return');
 
  86   $form->{title} = $locale->text('UStVA');
 
  87   $form->{kz10}  = '';                       #Berichtigte Anmeldung? Ja =1 Nein=0
 
  89   my $year = substr($form->datetonum($form->current_date(\%myconfig), \%myconfig ),
 
  96   # Einlesen der Finanzamtdaten
 
  97   my $ustva = USTVA->new();
 
  98   $ustva->get_config($::lx_office_conf{paths}{userspath}, 'finanzamt.ini');
 
 100   # Hier Einlesen der user-config
 
 101   # steuernummer entfernt für prerelease
 
 103     signature      name          company       address        businessnumber
 
 104     tel            fax           email         co_chief       co_department
 
 105     co_custom1     co_custom2    co_custom3    co_custom4     co_custom5
 
 106     co_name1       co_name2      co_street     co_street1     co_zip
 
 107     co_city        co_city1      co_country    co_tel         co_tel1
 
 108     co_tel2        co_fax        co_fax1       co_email       co_email1
 
 109     co_url         co_url1       ustid         duns           co_bankname
 
 110     co_bankname1   co_bankname2  co_bankname3  co_blz         co_blz1
 
 111     co_blz2        co_blz3       co_accountnr  co_accountnr1  co_accountnr2
 
 115   map { $form->{$_} = $myconfig{$_} } @a;
 
 117   my $openings = $form->{FA_Oeffnungszeiten};
 
 118   $openings =~ s/\\\\n/<br>/g;
 
 120   my $company_given = ($form->{company} ne '')
 
 121     ? qq|<h3>$form->{company}</h3>\n|
 
 122     : qq|<a href="am.pl?action=config">|
 
 123       . $locale->text('No Company Name given') . qq|!</a><br>|;
 
 126   # Anpassungen der Variablennamen auf pre 2.1.1 Namen
 
 127   # klären, ob $form->{company_street|_address} gesetzt sind
 
 128   if ($form->{address} ne '') {
 
 129     my $temp = $form->{address};
 
 130     $temp =~ s/\n/<br \/>/;
 
 131     ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp);
 
 132     $form->{co_city} =~ s/\n//g;
 
 137     ($form->{co_street} && ($form->{co_zip} || $form->{co_city}))
 
 138     ? qq|$form->{co_street}<br>|
 
 139         . qq|$form->{co_street1}<br>|
 
 140         . qq|$form->{co_zip} $form->{co_city}|
 
 141     : qq|<a href="am.pl?action=config|
 
 142         . qq|&level=Programm--Preferences">|
 
 143         . $locale->text('No Company Address given')
 
 146   $form->{co_email} = $form->{email} unless $form->{co_email};
 
 147   $form->{co_tel}   = $form->{tel}   unless $form->{co_tel};
 
 148   $form->{co_fax}   = $form->{fax}   unless $form->{co_fax};
 
 149   $form->{co_url}   = $form->{urlx}  unless $form->{co_url};
 
 151   my $taxnumber_given = ($form->{steuernummer} ne '') ? $form->{steuernummer} : qq|<a href="ustva.pl?action=config_step1">Keine Steuernummer hinterlegt!</a><br>|;
 
 153   my $ustva_vorauswahl = &ustva_vorauswahl();
 
 155   my @all_years = $form->all_years(\%myconfig);
 
 157   my $select_year = qq|<select name=year title="|
 
 158     . $locale->text('Year') . qq|">|;
 
 159   foreach my $key (@all_years) {
 
 160     $select_year .= qq|<option |;
 
 161     $select_year .= qq|selected| if ($key eq $form->{year});
 
 162     $select_year .= qq| >$key</option>|;
 
 164   $select_year   .=  qq|</select>|;
 
 167   $_checked = "checked" if ($form->{kz10} eq '1');
 
 168   my $checkbox_kz_10 = qq|<input name="FA_10" id=FA_10 class=checkbox|
 
 169     . qq| type=checkbox value="1" $_checked title = "|
 
 170     . $locale->text('Amended Advance Turnover Tax Return (Nr. 10)')
 
 172     . $locale->text('Amended Advance Turnover Tax Return');
 
 174   my $method_local = ($form->{method} eq 'accrual') ? $locale->text('accrual')
 
 175                    : ($form->{method} eq 'cash')    ? $locale->text('cash')
 
 178   my $period_local = ( $form->{FA_voranmeld} eq 'month')   ? $locale->text('month')
 
 179                    : ( $form->{FA_voranmeld} eq 'quarter') ? $locale->text('quarter')
 
 182   my $tax_office_banks_ref = [
 
 183     { BLZ             => $form->{FA_BLZ_1},
 
 184       Kontonummer     => $form->{FA_Kontonummer_1},
 
 185       Bankbezeichnung => $form->{FA_Bankbezeichnung_1}
 
 187     { BLZ             => $form->{FA_BLZ_2},
 
 188       Kontonummer     => $form->{FA_Kontonummer_2},
 
 189       Bankbezeichnung => $form->{FA_Bankbezeichnung_oertlich}
 
 193   # Which COA is in use?
 
 195   $ustva->get_coa($form, \%myconfig);
 
 198     openings         => $openings,
 
 199     company_given    => $company_given,
 
 200     address_given    => $address_given,
 
 201     taxnumber_given  => $taxnumber_given,
 
 202     taxnumber        => $myconfig{taxnumber},
 
 203     select_year      => $select_year,
 
 204     period_local     => $period_local,
 
 205     method_local     => $method_local,
 
 206     ustva_vorauswahl => $ustva_vorauswahl,
 
 207     checkbox_kz_10   => $checkbox_kz_10,
 
 208     tax_office_banks => $tax_office_banks_ref,
 
 209     select_options   => &show_options,
 
 213   print($form->parse_html_template('ustva/report', $template_ref));
 
 217   $::lxdebug->leave_sub();
 
 223   $::lxdebug->enter_sub();
 
 225   $::auth->assert('advance_turnover_tax_return');
 
 227   # parse help documents under doc
 
 228   my $tmp = $::form->{templates};
 
 229   $::form->{templates} = 'doc';
 
 230   $::form->{help}      = 'ustva';
 
 231   $::form->{type}      = 'help';
 
 232   $::form->{format}    = 'html';
 
 235   #$form->{templates} = $tmp;
 
 236   $::lxdebug->leave_sub();
 
 240   $::lxdebug->enter_sub();
 
 242   $::auth->assert('advance_turnover_tax_return');
 
 245   $::lxdebug->leave_sub();
 
 246   call_sub($::form->{"nextsub"});
 
 249 sub ustva_vorauswahl {
 
 250   $::lxdebug->enter_sub();
 
 253   my $locale   = $::locale;
 
 254   my %myconfig = %::myconfig;
 
 256   $::auth->assert('advance_turnover_tax_return');
 
 258   my $select_vorauswahl;
 
 260   #Aktuelles Datum zerlegen:
 
 261   my $date = $form->datetonum($form->current_date(\%myconfig), \%myconfig);
 
 263   #$locale->date($myconfig, $form->current_date($myconfig), 0)=~ /(\d\d).(\d\d).(\d\d\d\d)/;
 
 264   $form->{day}   = substr($date, 6, 2);
 
 265   $form->{month} = substr($date, 4, 2);
 
 266   $form->{year}  = substr($date, 0, 4);
 
 267   $::lxdebug->message(LXDebug->DEBUG1, qq|
 
 268     Actual date from Database: $date\n
 
 269     Actual year from Database: $form->{year}\n
 
 270     Actual day from Database: $form->{day}\n
 
 271     Actual month from Database: $form->{month}\n|);
 
 276   # Testdaten erzeugen:
 
 278   #$form->{month}= '01';
 
 279   #$form->{year}= 2004;
 
 280   $select_vorauswahl = qq|
 
 281      <input type=hidden name=day value=$form->{day}>
 
 282      <input type=hidden name=month value=$form->{month}>
 
 283      <input type=hidden name=yymmdd value=$yymmdd>
 
 284      <input type=hidden name=sel value=$sel>
 
 287   if ($form->{FA_voranmeld} eq 'month') {
 
 289     # Vorauswahl bei monatlichem Voranmeldungszeitraum
 
 291     my %liste = ('01' => $locale->text('January'),
 
 292                  '02' => $locale->text('February'),
 
 293                  '03' => $locale->text('March'),
 
 294                  '04' => $locale->text('April'),
 
 295                  '05' => $locale->text('May'),
 
 296                  '06' => $locale->text('June'),
 
 297                  '07' => $locale->text('July'),
 
 298                  '08' => $locale->text('August'),
 
 299                  '09' => $locale->text('September'),
 
 300                  '10' => $locale->text('October'),
 
 301                  '11' => $locale->text('November'),
 
 302                  '12' => $locale->text('December'),
 
 303                  '13' => $locale->text('Yearly'),
 
 306     my $yy = $form->{year} * 10000;
 
 307     $yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
 
 311     # Offset für Dauerfristverlängerung
 
 312     $dfv = '100' if ($form->{FA_dauerfrist} eq '1');
 
 315       $yymmdd <= ($yy + 110 + $dfv) && do {
 
 316         $form->{year} = $form->{year} - 1;
 
 320       $yymmdd <= ($yy + 210 + $dfv) && do {
 
 324       $yymmdd <= ($yy + 310 + $dfv) && do {
 
 328       $yymmdd <= ($yy + 410 + $dfv) && do {
 
 332       $yymmdd <= ($yy + 510 + $dfv) && do {
 
 336       $yymmdd <= ($yy + 610 + $dfv) && do {
 
 340       $yymmdd <= ($yy + 710 + $dfv) && do {
 
 344       $yymmdd <= ($yy + 810 + $dfv) && do {
 
 348       $yymmdd <= ($yy + 910 + $dfv) && do {
 
 352       $yymmdd <= ($yy + 1010 + $dfv) && do {
 
 356       $yymmdd <= ($yy + 1110 + $dfv) && do {
 
 360       $yymmdd <= ($yy + 1210) && do {
 
 364       $yymmdd <= ($yy + 1231) && do {
 
 370     $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
 
 371   . $locale->text('Select a period') . qq|" >|;
 
 374     foreach $key (sort keys %liste) {
 
 376       $selected = 'selected' if ($sel eq $key);
 
 377       $select_vorauswahl .= qq|
 
 378          <option value="$key" $selected> $liste{$key}</option>
 
 381     $select_vorauswahl .= qq|</select>|;
 
 383   } elsif ($form->{FA_voranmeld} eq 'quarter') {
 
 385     # Vorauswahl bei quartalsweisem Voranmeldungszeitraum
 
 386     my %liste = ('41'  => $locale->text('1. Quarter'),
 
 387                  '42'  => $locale->text('2. Quarter'),
 
 388                  '43'  => $locale->text('3. Quarter'),
 
 389                  '44'  => $locale->text('4. Quarter'),
 
 390                  '13' => $locale->text('Yearly'),);
 
 392     my $yy = $form->{year} * 10000;
 
 393     $yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
 
 395     my $dfv = '';    # Offset für Dauerfristverlängerung
 
 396     $dfv = '100' if ($form->{FA_dauerfrist} eq '1');
 
 399       $yymmdd <= ($yy + 110 + $dfv) && do {
 
 400         $form->{year} = $form->{year} - 1;
 
 404       $yymmdd <= ($yy + 410 + $dfv) && do {
 
 408       $yymmdd <= ($yy + 710 + $dfv) && do {
 
 412       $yymmdd <= ($yy + 1010 + $dfv) && do {
 
 416       $yymmdd <= ($yy + 1231) && do {
 
 421     $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
 
 422       . $locale->text('Select a period') . qq|" >|;
 
 424     foreach $key (sort keys %liste) {
 
 426       $selected = 'selected' if ($sel eq $key);
 
 427       $select_vorauswahl .= qq|
 
 428          <option value="$key" $selected>$liste{$key}</option>
 
 431     $select_vorauswahl .= qq|\n</select>
 
 436     # keine Vorauswahl bei Voranmeldungszeitraum
 
 437     $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
 
 438       . $locale->text('Select a period') . qq|" >|;
 
 440     my %listea = ('41' => '1. Quarter',
 
 441                   '42' => '2. Quarter',
 
 442                   '43' => '3. Quarter',
 
 443                   '44' => '4. Quarter',);
 
 445     my %listeb = ('01' => 'January',
 
 459     foreach $key (sort keys %listea) {
 
 460       $select_vorauswahl .= qq|
 
 461          <option value="$key">|
 
 462         . $locale->text("$listea{$key}")
 
 466     foreach $key (sort keys %listeb) {
 
 467       $select_vorauswahl .= qq|
 
 468          <option value="$key">|
 
 469         . $locale->text("$listeb{$key}")
 
 472     $select_vorauswahl .= qq|</select>|;
 
 474   $::lxdebug->leave_sub();
 
 476   return $select_vorauswahl;
 
 480 #  $::lxdebug->enter_sub();
 
 482 #  $::lxdebug->leave_sub();
 
 486   $::lxdebug->enter_sub();
 
 488   $::lxdebug->leave_sub();
 
 492   $::lxdebug->enter_sub();
 
 494   $::auth->assert('advance_turnover_tax_return');
 
 496   #  $form->{PD}{$form->{type}} = "selected";
 
 497   #  $form->{DF}{$form->{format}} = "selected";
 
 498   #  $form->{OP}{$form->{media}} = "selected";
 
 499   #  $form->{SM}{$form->{sendmode}} = "selected";
 
 500   my $type   = qq|      <input type=hidden name="type" value="ustva">|;
 
 501   my $media  = qq|      <input type=hidden name="media" value="screen">|;
 
 503       qq|       <option value=html selected>|
 
 504     . $::locale->text('Preview')
 
 506   if ($::lx_office_conf{print_templates}{latex}) {
 
 508         qq|    <option value=pdf>|
 
 509       . $::locale->text('UStVA (PDF-Dokument)')
 
 513   #my $disabled= qq|disabled="disabled"|;
 
 514   #$disabled='' if ($form->{elster} eq '1' );
 
 515   if ($::form->{elster} eq '1') {
 
 517         qq|<option value=elsterwinston>|
 
 518       . $::locale->text('ELSTER Export (Winston)')
 
 520       . qq|<option value=elstertaxbird>|
 
 521       . $::locale->text('ELSTER Export (Taxbird)')
 
 525   #$format .= qq|<option value=elster>|.$locale->text('ELSTER Export nach Winston').qq|</option>|;
 
 526   my $show_options = qq|
 
 529     <select name=format title = "|
 
 530     . $::locale->text('Choose Outputformat') . qq|">$format</select>
 
 532   $::lxdebug->leave_sub();
 
 534   return $show_options;
 
 538   $::lxdebug->enter_sub();
 
 541   my $locale   = $::locale;
 
 542   my %myconfig = %::myconfig;
 
 544   $::auth->assert('advance_turnover_tax_return');
 
 546   # Aufruf von get_config zum Einlesen der Finanzamtdaten aus finanzamt.ini
 
 548   my $ustva = USTVA->new();
 
 549   $ustva->get_config($::lx_office_conf{paths}{userspath}, 'finanzamt.ini');
 
 551   # init some form vars
 
 552   my @anmeldungszeitraum =
 
 553     qw('0401' '0402' '0403'
 
 557        '0441' '0442' '0443' '0444');
 
 559   foreach my $item (@anmeldungszeitraum) {
 
 563     #forgotten the year --> thisyear
 
 564     if ($form->{year} !~ m/^\d\d\d\d$/) {
 
 565       $form->{year} = substr(
 
 567                                     $form->current_date(\%myconfig), \%myconfig
 
 570       $::lxdebug->message(LXDebug->DEBUG1,
 
 571                         qq|Actual year from Database: $form->{year}\n|);
 
 575     # using dates in ISO-8601 format: yyyymmmdd  for Postgres...
 
 579     if ($form->{period} eq "13") {
 
 580       $form->{fromdate} = "$form->{year}0101";
 
 581       $form->{todate}   = "$form->{year}1231";
 
 585     if ($form->{period} eq "41") {
 
 586       $form->{fromdate} = "$form->{year}0101";
 
 587       $form->{todate}   = "$form->{year}0331";
 
 588       $form->{'0441'}   = "X";
 
 590     if ($form->{period} eq "42") {
 
 591       $form->{fromdate} = "$form->{year}0401";
 
 592       $form->{todate}   = "$form->{year}0630";
 
 593       $form->{'0442'}   = "X";
 
 595     if ($form->{period} eq "43") {
 
 596       $form->{fromdate} = "$form->{year}0701";
 
 597       $form->{todate}   = "$form->{year}0930";
 
 598       $form->{'0443'}   = "X";
 
 600     if ($form->{period} eq "44") {
 
 601       $form->{fromdate} = "$form->{year}1001";
 
 602       $form->{todate}   = "$form->{year}1231";
 
 603       $form->{'0444'}   = "X";
 
 608       $form->{period} eq "01" && do {
 
 609         $form->{fromdate} = "$form->{year}0101";
 
 610         $form->{todate}   = "$form->{year}0131";
 
 611         $form->{'0401'}   = "X";
 
 614       $form->{period} eq "02" && do {
 
 615         $form->{fromdate} = "$form->{year}0201";
 
 617         #this works from 1901 to 2099, 1900 and 2100 fail.
 
 618         my $leap = ($form->{year} % 4 == 0) ? "29" : "28";
 
 619         $form->{todate} = "$form->{year}02$leap";
 
 620         $form->{"0402"} = "X";
 
 623       $form->{period} eq "03" && do {
 
 624         $form->{fromdate} = "$form->{year}0301";
 
 625         $form->{todate}   = "$form->{year}0331";
 
 626         $form->{"0403"}   = "X";
 
 629       $form->{period} eq "04" && do {
 
 630         $form->{fromdate} = "$form->{year}0401";
 
 631         $form->{todate}   = "$form->{year}0430";
 
 632         $form->{"0404"}   = "X";
 
 635       $form->{period} eq "05" && do {
 
 636         $form->{fromdate} = "$form->{year}0501";
 
 637         $form->{todate}   = "$form->{year}0531";
 
 638         $form->{"0405"}   = "X";
 
 641       $form->{period} eq "06" && do {
 
 642         $form->{fromdate} = "$form->{year}0601";
 
 643         $form->{todate}   = "$form->{year}0630";
 
 644         $form->{"0406"}   = "X";
 
 647       $form->{period} eq "07" && do {
 
 648         $form->{fromdate} = "$form->{year}0701";
 
 649         $form->{todate}   = "$form->{year}0731";
 
 650         $form->{"0407"}   = "X";
 
 653       $form->{period} eq "08" && do {
 
 654         $form->{fromdate} = "$form->{year}0801";
 
 655         $form->{todate}   = "$form->{year}0831";
 
 656         $form->{"0408"}   = "X";
 
 659       $form->{period} eq "09" && do {
 
 660         $form->{fromdate} = "$form->{year}0901";
 
 661         $form->{todate}   = "$form->{year}0930";
 
 662         $form->{"0409"}   = "X";
 
 665       $form->{period} eq "10" && do {
 
 666         $form->{fromdate} = "$form->{year}1001";
 
 667         $form->{todate}   = "$form->{year}1031";
 
 668         $form->{"0410"}   = "X";
 
 671       $form->{period} eq "11" && do {
 
 672         $form->{fromdate} = "$form->{year}1101";
 
 673         $form->{todate}   = "$form->{year}1130";
 
 674         $form->{"0411"}   = "X";
 
 677       $form->{period} eq "12" && do {
 
 678         $form->{fromdate} = "$form->{year}1201";
 
 679         $form->{todate}   = "$form->{year}1231";
 
 680         $form->{"0412"}   = "X";
 
 685   # Kontrollvariablen für die Templates
 
 686   $form->{"year$_"} = ($form->{year} >= $_ ) ? "1":"0" for 2007..2107;
 
 689   $ustva->ustva(\%myconfig, \%$form);
 
 691   # reformat Dates to dateformat
 
 692   $form->{fromdate} = $locale->date(\%myconfig, $form->{fromdate}, 0, 0, 0);
 
 694   $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
 
 695   $form->{todate} = $locale->date(\%myconfig, $form->{todate}, 0, 0, 0);
 
 697   $form->{longperiod} =
 
 698     $locale->date(\%myconfig, $form->current_date(\%myconfig), 1, 0, 0);
 
 700   # if there are any dates construct a where
 
 701   if ($form->{fromdate} || $form->{todate}) {
 
 703     $form->{todate} = $form->current_date(\%myconfig)  unless ($form->{todate});
 
 705     my $longtodate  = $locale->date(\%myconfig, $form->{todate}, 1, 0, 0);
 
 706     my $shorttodate = $locale->date(\%myconfig, $form->{todate}, 0, 0, 0);
 
 708     my $longfromdate  = $locale->date(\%myconfig, $form->{fromdate}, 1, 0, 0);
 
 709     my $shortfromdate = $locale->date(\%myconfig, $form->{fromdate}, 0, 0, 0);
 
 711     $form->{this_period} = "$shortfromdate<br>\n$shorttodate";
 
 712     $form->{longperiod}      =
 
 713         $locale->text('for Period')
 
 714       . qq|<br>\n$longfromdate |
 
 715       . $locale->text('to (date)')
 
 719   if ($form->{comparefromdate} || $form->{comparetodate}) {
 
 720     my $longcomparefromdate =
 
 721       $locale->date(\%myconfig, $form->{comparefromdate}, 1, 0, 0);
 
 722     my $shortcomparefromdate =
 
 723       $locale->date(\%myconfig, $form->{comparefromdate}, 0, 0, 0);
 
 725     my $longcomparetodate =
 
 726       $locale->date(\%myconfig, $form->{comparetodate}, 1, 0, 0);
 
 727     my $shortcomparetodate =
 
 728       $locale->date(\%myconfig, $form->{comparetodate}, 0, 0, 0);
 
 730     $form->{last_period} = "$shortcomparefromdate<br>\n$shortcomparetodate";
 
 731     $form->{longperiod} .=
 
 732         "<br>\n$longcomparefromdate "
 
 733       . $locale->text('to (date)')
 
 734       . qq| $longcomparetodate|;
 
 737   $form->{Datum_heute} =
 
 738     $locale->date(\%myconfig, $form->current_date(\%myconfig), 0, 0, 0);
 
 740   # setup variables for the form
 
 741   my @a = qw(company businessnumber tel fax email
 
 742     co_chief co_department co_custom1 co_custom2 co_custom3 co_custom4 co_custom5
 
 743     co_name1 co_name2  co_street co_street1 co_zip co_city co_city1 co_country co_tel co_tel1 co_tel2
 
 744     co_fax co_fax1 co_email co_email1 co_url co_url1 ustid duns
 
 745     co_bankname co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1
 
 746     co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2 co_accountnr3);
 
 748   map { $form->{$_} = $myconfig{$_} } @a;
 
 750   if ($form->{address} ne '') {
 
 751     my $temp = $form->{address};
 
 752     $temp =~ s/\\n/<br \/>/;
 
 753     ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp);
 
 754     $form->{co_city} =~ s/\\n//g;
 
 757   ################################
 
 759   # Nation specific customisations
 
 761   ################################
 
 765   if ( $form->{coa} eq 'Germany-DATEV-SKR03EU' or $form->{coa} eq 'Germany-DATEV-SKR04EU') {
 
 768     # Outputformat specific customisation's
 
 771     my @category_cent = $ustva->report_variables({
 
 772         myconfig    => \%myconfig,
 
 775         attribute   => 'position',
 
 779     push @category_cent, qw(83  Z43  Z45  Z53  Z62  Z65  Z67);
 
 781     my @category_euro = $ustva->report_variables({
 
 782         myconfig    => \%myconfig,
 
 785         attribute   => 'position',
 
 790     $form->{amount} = [];
 
 792     if ( $form->{format} eq 'pdf' or $form->{format} eq 'postscript') {
 
 794       $form->{IN} = "$form->{type}-$form->{year}.tex";
 
 795       $form->{padding} = "~~";
 
 796       $form->{bold}    = "\textbf{";
 
 797       $form->{endbold} = "}";
 
 798       $form->{br}      = '\\\\';
 
 800       # Zahlenformatierung für Latex USTVA Formulare
 
 802       foreach my $number (@category_euro) {
 
 803         $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '');
 
 806       my ${decimal_comma} = ( $myconfig{numberformat} eq '1.000,00'
 
 807            or $myconfig{numberformat} eq '1000,00' ) ? ',':'.';
 
 809       foreach my $number (@category_cent) {
 
 810         $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '');
 
 811         $form->{$number} =~ s/${decimal_comma}/~~/g;
 
 814     } elsif ( $form->{format} eq 'html') { # Formatierungen für HTML Ausgabe
 
 816       $form->{IN} = $form->{type} . '.html';
 
 817       $form->{padding} = "  ";
 
 818       $form->{bold}    = "<b>";
 
 819       $form->{endbold} = "</b>";
 
 820       $form->{br}      = "<br>";
 
 821       $form->{address} =~ s/\\n/\n/g;
 
 823       foreach my $number (@category_cent) {
 
 824         $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '0');
 
 827       foreach my $number (@category_euro) {
 
 828         $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '0');
 
 831     } elsif ( $form->{format} eq 'elsterwinston' ) {
 
 833       $form->{IN} = 'winston.xml';
 
 836       # Build Winston filename
 
 839       my $file = 'U';     # 1. char 'U' = USTVA
 
 840       $file .= $form->{period};
 
 841       #4. and 5. char = year modulo 100
 
 842       $file .= sprintf("%02d", $form->{year} % 100);
 
 843       #6. to 18. char = Elstersteuernummer
 
 844       #Beispiel: Steuernummer in Bayern
 
 845       #111/222/33334 ergibt für UStVA Jan 2004: U01049111022233334
 
 846       $file .= $form->{elsterFFFF};
 
 847       $file .= $form->{elstersteuernummer};
 
 851       $form->{tmpfile} = "$::lx_office_conf{paths}{userspath}/$file";
 
 853       $form->{attachment_filename} = $file;
 
 855       # Zahlenformatierung für Winston
 
 857       my $temp_numberformat = $myconfig{numberformat};
 
 859       # Numberformat must be '1000.00' for Winston
 
 861       $myconfig{numberformat} = '1000.00';
 
 863       foreach my $number (@category_cent) {
 
 864         $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '2', '') : '';
 
 867       foreach my $number (@category_euro) {
 
 868         $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '0', '') : '';
 
 870       # Re-set Numberformat
 
 871       $myconfig{numberformat} = $temp_numberformat;
 
 873       # push Kennziffern to <%foreach Array fo easyer
 
 874       # output in xml format. Thx to Moritz.
 
 875       my %winston_id_for = (
 
 879       foreach my $kennziffer (@category_cent, @category_euro) {
 
 881         next if ( $kennziffer =~ m/Z\d\d/);
 
 882         next if (   $form->{$kennziffer} == 0 );
 
 884         if (defined $winston_id_for{$kennziffer} ) {
 
 885           push(@{ $form->{id}}, $winston_id_for{$kennziffer});
 
 887           push(@{ $form->{id}}, "Kz$kennziffer");
 
 889         push(@{ $form->{amount}}, $form->{$kennziffer});
 
 892     } elsif ( $form->{format} eq 'elstertaxbird' ) {
 
 894       # Define serveral filenames
 
 895       $form->{IN} = 'taxbird.txb';
 
 897       $form->{attachment_filename} = "USTVA-" . $form->{period}
 
 898       . sprintf("%02d", $form->{year} % 100) . ".txb";
 
 900       $form->{attachment_filename} =~ s|.*/||;
 
 901       $form->{tmpfile} = "$::lx_office_conf{paths}{userspath}/" . $form->{attachment_filename};
 
 903       # TODO: set Output to UTF-8 or system Preference
 
 904       #$form->{"iconv"} = Text::Iconv->new($myconfig{dbcharset}, "UTF-8");
 
 905       #my $iconv = $self->{"iconv"};
 
 906       #$iconv->convert($variable);
 
 907       if ($form->{period} =~ /^[4]\d$/ ){
 
 908         my %periods = ( # Lx => taxbird
 
 915         foreach my $quarter ( keys %periods ) {
 
 916           $form->{taxbird_period} = $periods{$quarter} if ( $form->{period} eq $quarter);
 
 918       } elsif ($form->{period} =~ /^\d+$/ ) {
 
 919         $form->{period} =~ s/^0//g;
 
 920         my $period = $form->{period};
 
 923         $form->{taxbird_period} = $period;
 
 926         USTVA::error( $locale->text('Wrong Period' ));
 
 930       # heuristics for address splitting
 
 931       # lx-office holds the entire address in a single field.
 
 932       # taxbird expects it to be splitted into street, zipcode and city
 
 933       if ($form->{co_street} =~ /\n/) {
 
 935         for (split /\n/, $form->{co_street}) {
 
 936           if (/(\d{3,5})\s+(\w+)/) {
 
 937             $form->{co_zip}  = $1;
 
 938             $form->{co_city} = $2;
 
 940             $new_co_street .= $_;
 
 943         $form->{co_street} = $new_co_street;
 
 945         $form->{co_zip} = $form->{co_city};
 
 946         $form->{co_zip} =~ s/\D//g;
 
 947         $form->{co_city} =~ s/\d//g;
 
 948         $form->{co_city} =~ s/^\s//g;
 
 951       my $tax_office           = first { $_->{name} eq $form->{elsterland} } @{ $ustva->{tax_office_information} };
 
 952       $form->{taxbird_land_nr} = $tax_office->{taxbird_nr} if $tax_office;
 
 954       ($form->{co_phone_prefix}, $form->{co_phone}) = split("-", $form->{tel});
 
 955       $form->{co_phone_prefix} =~ s/\s//g;
 
 956       $form->{co_phone} =~ s/\s//g;
 
 958        $form->{taxbird_steuernummer} = $form->{steuernummer};
 
 959       #      $form->{taxbird_steuernummer} =~ s/\D//g;
 
 960 #      $form->{taxbird_steuernummer} =~ s/\///; # ersten Querstrich ersetzen
 
 962       # Numberformatting for Taxbird
 
 963       my $temp_numberformat = $myconfig{numberformat};
 
 964       # Numberformat must be '1000,00' for Taxbird ?!
 
 965       $myconfig{numberformat} = '1000,00';
 
 966       foreach my $number (@category_cent) {
 
 967         $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '2', '') : '';
 
 970       foreach my $number (@category_euro) {
 
 971         $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '0', '') : '';
 
 973       # Re-set Numberformat
 
 974       $myconfig{numberformat} = $temp_numberformat;
 
 976       # push Kennziffern to <%foreach Array fo easyer
 
 977       # output in xml format. Thx to Moritz.
 
 978       my %taxbird_id_for = (
 
 980           '511'  =>  'Kz51-calc',
 
 981           '861'  =>  'Kz86-calc',
 
 982           '971'  =>  'Kz97-calc',
 
 983           '931'  =>  'Kz93-calc',
 
 984           '811'  =>  'Kz81-calc',
 
 985           '891'  =>  'Kz89-calc',
 
 986           'Z45'  =>  'uebertrag',
 
 988           'Z62'  =>  'ust-minus-vost',
 
 989           'Z65'  =>  'ust-sum+69',
 
 994       for my $kennziffer (@category_cent, @category_euro) {
 
 996         next if ($kennziffer eq 'Z43');
 
 998         if ($form->{$kennziffer} != 0){
 
 999           if (defined $taxbird_id_for{$kennziffer}) {
 
1000             push(@{ $form->{id}}, $taxbird_id_for{$kennziffer});
 
1002             push(@{ $form->{id}}, "Kz$kennziffer");
 
1004           push(@{ $form->{amount}}, $form->{$kennziffer});
 
1008     } elsif ( $form->{format} eq '' ){ # No format error.
 
1010       USTVA::error( $locale->text('Application Error. No Format given' ) . "!");
 
1013     } else { # All other Formats are wrong
 
1015       USTVA::error( $locale->text('Application Error. Wrong Format') . ": " . $form->{format} );
 
1020   } else  # Outputformat for generic output
 
1023     my @category_cent = $ustva->report_variables({
 
1024         myconfig    => \%myconfig,
 
1027         attribute   => 'position',
 
1031     my @category_euro = $ustva->report_variables({
 
1032         myconfig    => \%myconfig,
 
1035         attribute   => 'position',
 
1039     $form->{USTVA} = [];
 
1041     if ( $form->{format} eq 'generic') { # Formatierungen für HTML Ausgabe
 
1044       for my $kennziffer (@category_cent, @category_euro) {
 
1046         $rec_ref->{id} = $kennziffer;
 
1047         $rec_ref->{amount} = $form->format_amount(\%myconfig, $form->{$kennziffer}, 2, '0');
 
1049         $::lxdebug->message($LXDebug::DEBUG, "Kennziffer $kennziffer: '$form->{$kennziffer}'" );
 
1050         $::lxdebug->dump($LXDebug::DEBUG, $rec_ref );
 
1051         push @ { $form->{USTVA} }, $rec_ref;
 
1058   if ( $form->{period} eq '13' and $form->{format} ne 'html') {
 
1062       'Yearly taxreport not yet implemented')
 
1066   $form->{templates} = $myconfig{templates};
 
1067   $form->{templates} = "doc" if ( $form->{type} eq 'help' );
 
1069   if ($form->{format} eq 'generic'){
 
1073     my $template_ref = {
 
1074         taxnumber => $myconfig{taxnumber},
 
1077     print($form->parse_html_template('ustva/generic_taxreport', $template_ref));
 
1082     $form->parse_template(\%myconfig, $::lx_office_conf{paths}{userspath});
 
1086   $::lxdebug->leave_sub();
 
1090   $::lxdebug->enter_sub();
 
1092   $::auth->assert('advance_turnover_tax_return');
 
1094 $::form->{title} = $::locale->text('Tax Office Preferences');
 
1096   # edit all taxauthority prefs
 
1100   my $ustva = USTVA->new();
 
1101   $ustva->get_config($::lx_office_conf{paths}{userspath}, 'finanzamt.ini');
 
1103   my $land = $::form->{elsterland};
 
1104   my $amt  = $::form->{elsterFFFF};
 
1107   $::form->{title} = $::locale->text('Tax Office Preferences');
 
1110   my $select_tax_office = $ustva->fa_auswahl($land, $amt, $ustva->query_finanzamt(\%::myconfig, $::form));
 
1111   my $checked_accrual = q|checked="checked"| if ($::form->{method} eq 'accrual');
 
1112   my $checked_cash = q|checked="checked"| if ($::form->{method} eq 'cash');
 
1113   my $checked_monthly = "checked" if ($::form->{FA_voranmeld} eq 'month');
 
1114   my $checked_quarterly = "checked" if ($::form->{FA_voranmeld} eq 'quarter');
 
1115   my $checked_dauerfristverlaengerung = "checked" if ($::form->{FA_dauerfrist} eq '1');
 
1116   my $checked_kz_71 = "checked" if ($::form->{FA_71} eq 'X');
 
1118   my $_hidden_variables_ref;
 
1120   my %_hidden_local_variables = (
 
1121     'saved'       => $::locale->text('Check Details'),
 
1122     'nextsub'     => 'config_step2',
 
1126   foreach my $variable (keys %_hidden_local_variables) {
 
1127     push @{ $_hidden_variables_ref },
 
1128         { 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
 
1131   my @_hidden_form_variables = qw(
 
1132     FA_Name             FA_Strasse        FA_PLZ
 
1133     FA_Ort              FA_Telefon        FA_Fax
 
1134     FA_PLZ_Grosskunden  FA_PLZ_Postfach   FA_Postfach
 
1135     FA_BLZ_1            FA_Kontonummer_1  FA_Bankbezeichnung_1
 
1136     FA_BLZ_2            FA_Kontonummer_2  FA_Bankbezeichnung_oertlich
 
1137     FA_Oeffnungszeiten  FA_Email          FA_Internet
 
1138     steuernummer        elsterland        elstersteuernummer
 
1142   foreach my $variable (@_hidden_form_variables) {
 
1143     push @{ $_hidden_variables_ref},
 
1144         { 'variable' => $variable, 'value' => $::form->{$variable} };
 
1147 # Which COA is in use?
 
1149   $ustva->get_coa($::form, \%::myconfig);
 
1152   my $steuernummer_new = '';
 
1154   # Variablen für das Template zur Verfügung stellen
 
1155   my $template_ref = {
 
1156      select_tax_office               => $select_tax_office,
 
1157      checked_accrual                 => $checked_accrual,
 
1158      checked_cash                    => $checked_cash,
 
1159      checked_monthly                 => $checked_monthly,
 
1160      checked_quarterly               => $checked_quarterly,
 
1161      checked_dauerfristverlaengerung => $checked_dauerfristverlaengerung,
 
1162      hidden_variables                => $_hidden_variables_ref,
 
1166   # Ausgabe des Templates
 
1167   print($::form->parse_html_template('ustva/config_step1', $template_ref));
 
1169   $::lxdebug->leave_sub();
 
1173   $::lxdebug->enter_sub();
 
1176   my $locale   = $::locale;
 
1177   my %myconfig = %::myconfig;
 
1179   $::auth->assert('advance_turnover_tax_return');
 
1187   my $elsterland         = '';
 
1188   my $elster_amt         = '';
 
1189   my $elsterFFFF         = '';
 
1190   my $elstersteuernummer = '';
 
1192   my $ustva = USTVA->new();
 
1193   $ustva->get_config($::lx_office_conf{paths}{userspath}, 'finanzamt.ini')
 
1194     if ($form->{saved} eq $locale->text('saved'));
 
1196   # Auf Übergabefehler checken
 
1197   USTVA::info(  $locale->text('Missing Tax Authoritys Preferences') . "\n"
 
1198               . $locale->text('USTVA-Hint: Tax Authoritys'))
 
1199     if (   $form->{elsterFFFF_new} eq 'Auswahl'
 
1200         || $form->{elsterland_new} eq 'Auswahl');
 
1201   USTVA::info(  $locale->text('Missing Method!') . "\n"
 
1202               . $locale->text('USTVA-Hint: Method'))
 
1203     if ($form->{method} eq '');
 
1205   # Klären, ob Variablen bereits befüllt sind UND ob veräderungen auf
 
1206   # der vorherigen Maske stattfanden: $change = 1(in der edit sub,
 
1207   # mittels get_config)
 
1209   my $change = $form->{elsterland} eq $form->{elsterland_new}
 
1210     && $form->{elsterFFFF} eq $form->{elsterFFFF_new} ? '0' : '1';
 
1211   $change = '0' if ($form->{saved} eq $locale->text('saved'));
 
1212   my $elster_init = $ustva->query_finanzamt(\%myconfig, $form);
 
1214   my %elster_init = %$elster_init;
 
1216   if ($change eq '1') {
 
1219     $elsterland           = $form->{elsterland_new};
 
1220     $elsterFFFF           = $form->{elsterFFFF_new};
 
1221     $form->{elsterland}   = $elsterland;
 
1222     $form->{elsterFFFF}   = $elsterFFFF;
 
1223     $form->{steuernummer} = '';
 
1225     create_steuernummer();
 
1227     # rebuild elster_amt
 
1229     foreach $amt (keys %{ $elster_init{ $form->{elsterland} } }) {
 
1231         if ($elster_init{ $form->{elsterland}{$amt} eq $form->{elsterFFFF} });
 
1234     # load the predefined hash data into the FA_* Vars
 
1235     my @variables = qw(FA_Name FA_Strasse FA_PLZ FA_Ort
 
1236       FA_Telefon FA_Fax FA_PLZ_Grosskunden FA_PLZ_Postfach
 
1238       FA_BLZ_1 FA_Kontonummer_1 FA_Bankbezeichnung_1
 
1239       FA_BLZ_2 FA_Kontonummer_2 FA_Bankbezeichnung_oertlich
 
1240       FA_Oeffnungszeiten FA_Email FA_Internet);
 
1242     for (my $i = 0; $i <= 20; $i++) {
 
1243       $form->{ $variables[$i] } =
 
1244         $elster_init->{$elsterland}->{$elsterFFFF}->[$i];
 
1249     $elsterland = $form->{elsterland};
 
1250     $elsterFFFF = $form->{elsterFFFF};
 
1253   my $stnr = $form->{steuernummer};
 
1255   my $patterncount   = $form->{patterncount};
 
1256   my $elster_pattern = $form->{elster_pattern};
 
1257   my $delimiter      = $form->{delimiter};
 
1258   my $steuernummer = $form->{steuernummer} if ($stnr eq '');
 
1260   $form->{FA_Oeffnungszeiten} =~ s/\\\\n/\n/g;
 
1263   $ustva->get_coa($form, \%myconfig);
 
1265   my $input_steuernummer = $ustva->steuernummer_input(
 
1266                              $form->{elsterland},
 
1267                              $form->{elsterFFFF},
 
1268                              $form->{steuernummer}
 
1271   $::lxdebug->message(LXDebug->DEBUG1, qq|$input_steuernummer|);
 
1274   my $_hidden_variables_ref;
 
1276   my %_hidden_local_variables = (
 
1277       'elsterland'          => $elsterland,
 
1278       'elsterFFFF'          => $elsterFFFF,
 
1280       'elstersteuernummer'  => $elstersteuernummer,
 
1281       'steuernummer'        => $stnr,
 
1282       'lastsub'             => 'config_step1',
 
1283       'nextsub'             => 'save',
 
1287   foreach my $variable (keys %_hidden_local_variables) {
 
1288     push @{ $_hidden_variables_ref },
 
1289         { 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
 
1292   my @_hidden_form_variables = qw(
 
1293     FA_steuerberater_name   FA_steuerberater_street
 
1294     FA_steuerberater_city   FA_steuerberater_tel
 
1302   foreach my $variable (@_hidden_form_variables) {
 
1303     push @{ $_hidden_variables_ref},
 
1304         { 'variable' => $variable, 'value' => $form->{$variable} };
 
1307   my $template_ref = {
 
1308      input_steuernummer              => $input_steuernummer,
 
1309      readonly                        => '', #q|disabled="disabled"|,
 
1310      callback                        => $form->{callback},
 
1311      hidden_variables                => $_hidden_variables_ref,
 
1314   # Ausgabe des Templates
 
1315   print($form->parse_html_template('ustva/config_step2', $template_ref));
 
1318   $::lxdebug->leave_sub();
 
1321 sub create_steuernummer {
 
1322   $::lxdebug->enter_sub();
 
1324   $::auth->assert('advance_turnover_tax_return');
 
1326   my $part           = $::form->{part};
 
1327   my $patterncount   = $::form->{patterncount};
 
1328   my $delimiter      = $::form->{delimiter};
 
1329   my $elster_pattern = $::form->{elster_pattern};
 
1331   # rebuild steuernummer and elstersteuernummer
 
1332   # es gibt eine gespeicherte steuernummer $form->{steuernummer}
 
1333   # und die parts und delimiter
 
1338   my $steuernummer_new       = $part;
 
1339   my $elstersteuernummer_new = $::form->{elster_FFFF};
 
1340   $elstersteuernummer_new .= '0';
 
1342   for ($h = 1; $h < $patterncount; $h++) {
 
1343     $steuernummer_new .= qq|$delimiter|;
 
1344     for (my $i = 1; $i <= length($elster_pattern); $i++) {
 
1345       $steuernummer_new       .= $::form->{"part_$h\_$i"};
 
1346       $elstersteuernummer_new .= $::form->{"part_$h\_$i"};
 
1349   if ($::form->{steuernummer} ne $steuernummer_new) {
 
1350     $::form->{steuernummer}       = $steuernummer_new;
 
1351     $::form->{elstersteuernummer} = $elstersteuernummer_new;
 
1352     $::form->{steuernummer_new}   = $steuernummer_new;
 
1354     $::form->{steuernummer_new}       = '';
 
1355     $::form->{elstersteuernummer_new} = '';
 
1357   $::lxdebug->leave_sub();
 
1361   $::lxdebug->enter_sub();
 
1363   $::auth->assert('advance_turnover_tax_return');
 
1365   my $filename = "$::form->{login}_$::form->{filename}";
 
1366   $filename =~ s|.*/||;
 
1368   #zuerst die steuernummer aus den part, parts_X_Y und delimiter herstellen
 
1369   create_steuernummer();
 
1371   # Textboxen formatieren: Linebreaks entfernen
 
1373   $::form->{FA_Oeffnungszeiten} =~ s/\r\n/\\n/g;
 
1375   #URL mit http:// davor?
 
1376   $::form->{FA_Internet} =~ s/^http:\/\///;
 
1377   $::form->{FA_Internet} = 'http://' . $::form->{FA_Internet};
 
1380     elster              elsterland            elstersteuernummer  steuernummer
 
1381     elsteramt           elsterFFFF            FA_Name             FA_Strasse
 
1382     FA_PLZ              FA_Ort                FA_Telefon          FA_Fax
 
1383     FA_PLZ_Grosskunden  FA_PLZ_Postfach       FA_Postfach         FA_BLZ_1
 
1384     FA_Kontonummer_1    FA_Bankbezeichnung_1  FA_BLZ_2            FA_Kontonummer_2
 
1385     FA_Bankbezeichnung_oertlich FA_Oeffnungszeiten
 
1386     FA_Email FA_Internet FA_voranmeld method FA_steuerberater_name
 
1387     FA_steuerberater_street FA_steuerberater_city FA_steuerberater_tel
 
1388     FA_71 FA_dauerfrist);
 
1390   # Hier kommt dann die Plausibilitätsprüfung der ELSTERSteuernummer
 
1391   if ($::form->{elstersteuernummer} ne '000000000') {
 
1393     $::form->{elster} = '1';
 
1395     open my $ustvaconfig, ">", "$::lx_office_conf{paths}{userspath}/$filename" or $::form->error("$filename : $!");
 
1397     # create the config file
 
1398     print {$ustvaconfig} qq|# Configuration file for USTVA\n\n|;
 
1400     foreach $key (sort @config) {
 
1401       $::form->{$key} =~ s/\\/\\\\/g;
 
1403       $::form->{$key} =~ s/\r\n/\n/g;
 
1405       print {$ustvaconfig} qq|$key=|;
 
1406       if ($::form->{$key} ne 'Y') {
 
1407         print {$ustvaconfig} qq|$::form->{$key}\n|;
 
1409       if ($::form->{$key} eq 'Y') {
 
1410         print {$ustvaconfig} qq|checked \n|;
 
1413     print {$ustvaconfig} qq|\n\n|;
 
1415     $::form->{saved} = $::locale->text('saved');
 
1419     $::form->{saved} = $::locale->text('Choose a Tax Number');
 
1423   $::lxdebug->leave_sub();
 
1428   $::lxdebug->enter_sub();
 
1430   # allow Symbolic references just here:
 
1431   call_sub($::form->{"nextsub"});
 
1432   $::lxdebug->leave_sub();
 
1436   $::lxdebug->enter_sub();
 
1437   call_sub($::form->{"lastsub"});
 
1438   $::lxdebug->leave_sub();