2 #=====================================================================
4 # Copyright (c) 2004 by Udo Spallek, Aachen
8 # Web: http://www.lx-office.org
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #======================================================================
24 # German Tax authority Module and later ELSTER Interface
25 #======================================================================
27 require "$form->{path}/arap.pl";
32 #use warnings; # FATAL=> 'all';
33 #use vars qw($locale $form %myconfig);
35 #use CGI::Carp "fatalsToBrowser";
43 # this is for our long dates
44 # $locale->text('January')
45 # $locale->text('February')
46 # $locale->text('March')
47 # $locale->text('April')
48 # $locale->text('May ')
49 # $locale->text('June')
50 # $locale->text('July')
51 # $locale->text('August')
52 # $locale->text('September')
53 # $locale->text('October')
54 # $locale->text('November')
55 # $locale->text('December')
57 # this is for our short month
58 # $locale->text('Jan')
59 # $locale->text('Feb')
60 # $locale->text('Mar')
61 # $locale->text('Apr')
62 # $locale->text('May')
63 # $locale->text('Jun')
64 # $locale->text('Jul')
65 # $locale->text('Aug')
66 # $locale->text('Sep')
67 # $locale->text('Oct')
68 # $locale->text('Nov')
69 # $locale->text('Dec')
71 # $form->parse_html_template('generic/util_hidden_variables');
73 #############################
76 $lxdebug->enter_sub();
78 my $myconfig = \%myconfig;
80 $form->{title} = $locale->text('UStVA');
81 $form->{kz10} = ''; #Berichtigte Anmeldung? Ja =1 Nein=0
83 my $year = substr($form->datetonum($form->current_date(\%myconfig), \%myconfig ),
90 # Einlesen der Finanzamtdaten
91 &get_config($userspath, 'finanzamt.ini');
93 # Hier Einlesen der user-config
94 # steuernummer entfernt für prerelease
96 signature name company address businessnumber
97 tel fax email co_chief co_department
98 co_custom1 co_custom2 co_custom3 co_custom4 co_custom5
99 co_name1 co_name2 co_street co_street1 co_zip
100 co_city co_city1 co_country co_tel co_tel1
101 co_tel2 co_fax co_fax1 co_email co_email1
102 co_url co_url1 ustid duns co_bankname
103 co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1
104 co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2
108 map { $form->{$_} = $myconfig->{$_} } @a;
110 my $openings = $form->{FA_Oeffnungszeiten};
111 $openings =~ s/\\\\n/<br>/g;
113 my $company_given = ($form->{company} ne '')
114 ? qq|<h3>$form->{company}</h3>\n|
115 : qq|<a href=am.pl?path=$form->{path}&action=config|
116 . qq|&level=Programm--Preferences&login=$form->{login}|
117 . qq|&password=$form->{password}>|
118 . $locale->text('No Company Name given') . qq|!</a><br>|;
121 # Anpassungen der Variablennamen auf pre 2.1.1 Namen
122 # klären, ob $form->{company_street|_address} gesetzt sind
123 if ($form->{address} ne '') {
124 my $temp = $form->{address};
125 $temp =~ s/\\n/<br \/>/;
126 ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp);
127 $form->{co_city} =~ s/\\n//g;
132 ($form->{co_street} ne ''
134 $form->{co_zip} ne ''
135 or $form->{co_city} ne ''
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?path=$form->{path}&action=config|
142 . qq|&level=Programm--Preferences&login=$form->{login}|
143 . qq|&password=$form->{password}>|
144 . $locale->text('No Company Address given')
147 $form->{co_email} = $form->{email} unless $form->{co_email};
148 $form->{co_tel} = $form->{tel} unless $form->{co_tel};
149 $form->{co_fax} = $form->{fax} unless $form->{co_fax};
150 $form->{co_url} = $form->{urlx} unless $form->{co_url};
152 my $taxnumber_given = ($form->{steuernummer} ne '')
153 ? qq|$form->{steuernummer}|
154 : qq|<a href="ustva.pl?path=$form->{path}&action="config_step1"|
155 . qq|&level=Programm--Finanzamteinstellungen&login=$form->{login}|
156 . qq|&password=$form->{password}">Keine Steuernummer hinterlegt!|
159 my $ustva_vorauswahl = &ustva_vorauswahl();
161 my @all_years = $form->all_years(\%myconfig);
163 my $select_year = qq|<select name=year title="|
164 . $locale->text('Year') . qq|">|;
165 foreach my $key (@all_years) {
166 $select_year .= qq|<option |;
167 $select_year .= qq|selected| if ($key eq $form->{year});
168 $select_year .= qq| >$key</option>|;
170 $select_year .= qq|</select>|;
173 $_checked = "checked" if ($form->{kz10} eq '1');
174 my $checkbox_kz_10 = qq|<input name="FA_10" id=FA_10 class=checkbox|
175 . qq| type=checkbox value="1" $_checked title = "|
176 . $locale->text('Amended Advance Turnover Tax Return (Nr. 10)')
178 . $locale->text('Amended Advance Turnover Tax Return');
180 my $method_local = ($form->{method} eq 'accrual') ? $locale->text('accrual')
181 : ($form->{method} eq 'cash') ? $locale->text('cash')
184 my $period_local = ( $form->{FA_voranmeld} eq 'month') ? $locale->text('month')
185 : ( $form->{FA_voranmeld} eq 'quarter') ? $locale->text('quarter')
188 my $tax_office_banks_ref = [
189 { BLZ => $form->{FA_BLZ_1},
190 Kontonummer => $form->{FA_Kontonummer_1},
191 Bankbezeichnung => $form->{FA_Bankbezeichnung_1}
193 { BLZ => $form->{FA_BLZ_2},
194 Kontonummer => $form->{FA_Kontonummer_2},
195 Bankbezeichnung => $form->{FA_Bankbezeichnung_oertlich}
201 openings => $openings,
202 company_given => $company_given,
203 address_given => $address_given,
204 taxnumber_given => $taxnumber_given,
205 select_year => $select_year,
206 period_local => $period_local,
207 method_local => $method_local,
208 ustva_vorauswahl => $ustva_vorauswahl,
209 checkbox_kz_10 => $checkbox_kz_10,
210 tax_office_banks => $tax_office_banks_ref,
211 select_options => &show_options,
214 print($form->parse_html_template('ustva/report', $template_ref));
218 $lxdebug->leave_sub();
224 $lxdebug->enter_sub();
226 # parse help documents under doc
227 my $tmp = $form->{templates};
228 $form->{templates} = 'doc';
229 $form->{help} = 'ustva';
230 $form->{type} = 'help';
231 $form->{format} = 'html';
234 #$form->{templates} = $tmp;
235 $lxdebug->leave_sub();
239 $lxdebug->enter_sub();
243 $lxdebug->leave_sub();
244 &{ $form->{nextsub} };
248 sub ustva_vorauswahl {
249 $lxdebug->enter_sub();
251 my $select_vorauswahl;
253 #Aktuelles Datum zerlegen:
254 my $date = $form->datetonum($form->current_date(\%myconfig), \%myconfig);
256 #$locale->date($myconfig, $form->current_date($myconfig), 0)=~ /(\d\d).(\d\d).(\d\d\d\d)/;
257 $form->{day} = substr($date, 6, 2);
258 $form->{month} = substr($date, 4, 2);
259 $form->{year} = substr($date, 0, 4);
260 $lxdebug->message(LXDebug::DEBUG1, qq|
261 Actual date from Database: $date\n
262 Actual year from Database: $form->{year}\n
263 Actual day from Database: $form->{day}\n
264 Actual month from Database: $form->{month}\n|);
269 # Testdaten erzeugen:
271 #$form->{month}= '01';
272 #$form->{year}= 2004;
273 $select_vorauswahl = qq|
274 <input type=hidden name=day value=$form->{day}>
275 <input type=hidden name=month value=$form->{month}>
276 <input type=hidden name=yymmdd value=$yymmdd>
277 <input type=hidden name=sel value=$sel>
280 if ($form->{FA_voranmeld} eq 'month') {
282 # Vorauswahl bei monatlichem Voranmeldungszeitraum
284 my %liste = ('01' => $locale->text('January'),
285 '02' => $locale->text('February'),
286 '03' => $locale->text('March'),
287 '04' => $locale->text('April'),
288 '05' => $locale->text('May'),
289 '06' => $locale->text('June'),
290 '07' => $locale->text('July'),
291 '08' => $locale->text('August'),
292 '09' => $locale->text('September'),
293 '10' => $locale->text('October'),
294 '11' => $locale->text('November'),
295 '12' => $locale->text('December'),
296 '13' => $locale->text('Yearly'),
299 my $yy = $form->{year} * 10000;
300 $yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
304 # Offset für Dauerfristverlängerung
305 $dfv = '100' if ($form->{FA_dauerfrist} eq '1');
308 $yymmdd <= ($yy + 110 + $dfv) && do {
309 $form->{year} = $form->{year} - 1;
313 $yymmdd <= ($yy + 210 + $dfv) && do {
317 $yymmdd <= ($yy + 310 + $dfv) && do {
321 $yymmdd <= ($yy + 410 + $dfv) && do {
325 $yymmdd <= ($yy + 510 + $dfv) && do {
329 $yymmdd <= ($yy + 610 + $dfv) && do {
333 $yymmdd <= ($yy + 710 + $dfv) && do {
337 $yymmdd <= ($yy + 810 + $dfv) && do {
341 $yymmdd <= ($yy + 910 + $dfv) && do {
345 $yymmdd <= ($yy + 1010 + $dfv) && do {
349 $yymmdd <= ($yy + 1110 + $dfv) && do {
353 $yymmdd <= ($yy + 1210) && do {
357 $yymmdd <= ($yy + 1231) && do {
363 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
364 . $locale->text('Select a period') . qq|" >|;
367 foreach $key (sort keys %liste) {
369 $selected = 'selected' if ($sel eq $key);
370 $select_vorauswahl .= qq|
371 <option value="$key" $selected> $liste{$key}</option>
374 $select_vorauswahl .= qq|</select>|;
376 } elsif ($form->{FA_voranmeld} eq 'quarter') {
378 # Vorauswahl bei quartalsweisem Voranmeldungszeitraum
379 my %liste = ('41' => $locale->text('1. Quarter'),
380 '42' => $locale->text('2. Quarter'),
381 '43' => $locale->text('3. Quarter'),
382 '44' => $locale->text('4. Quarter'),
383 '13' => $locale->text('Yearly'),);
385 my $yy = $form->{year} * 10000;
386 $yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
388 my $dfv = ''; # Offset für Dauerfristverlängerung
389 $dfv = '100' if ($form->{FA_dauerfrist} eq '1');
392 $yymmdd <= ($yy + 110 + $dfv) && do {
393 $form->{year} = $form->{year} - 1;
397 $yymmdd <= ($yy + 410 + $dfv) && do {
401 $yymmdd <= ($yy + 710 + $dfv) && do {
405 $yymmdd <= ($yy + 1010 + $dfv) && do {
409 $yymmdd <= ($yy + 1231) && do {
414 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
415 . $locale->text('Select a period') . qq|" >|;
417 foreach $key (sort keys %liste) {
419 $selected = 'selected' if ($sel eq $key);
420 $select_vorauswahl .= qq|
421 <option value="$key" $selected>$liste{$key}</option>
424 $select_vorauswahl .= qq|\n</select>
429 # keine Vorauswahl bei Voranmeldungszeitraum
430 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
431 . $locale->text('Select a period') . qq|" >|;
433 my %listea = ('41' => '1. Quarter',
434 '42' => '2. Quarter',
435 '43' => '3. Quarter',
436 '44' => '4. Quarter',);
438 my %listeb = ('01' => 'January',
452 foreach $key (sort keys %listea) {
453 $select_vorauswahl .= qq|
454 <option value="$key">|
455 . $locale->text("$listea{$key}")
459 foreach $key (sort keys %listeb) {
460 $select_vorauswahl .= qq|
461 <option value="$key">|
462 . $locale->text("$listeb{$key}")
465 $select_vorauswahl .= qq|</select>|;
467 $lxdebug->leave_sub();
469 return $select_vorauswahl;
473 # $lxdebug->enter_sub();
475 # $lxdebug->leave_sub();
479 $lxdebug->enter_sub();
481 $lxdebug->leave_sub();
485 $lxdebug->enter_sub();
487 # $form->{PD}{$form->{type}} = "selected";
488 # $form->{DF}{$form->{format}} = "selected";
489 # $form->{OP}{$form->{media}} = "selected";
490 # $form->{SM}{$form->{sendmode}} = "selected";
491 my $type = qq| <input type=hidden name="type" value="ustva">|;
492 my $media = qq| <input type=hidden name="media" value="screen">|;
494 qq| <option value=html selected>|
495 . $locale->text('Preview')
497 if ($latex_templates) {
499 qq| <option value=pdf>|
500 . $locale->text('UStVA (PDF-Dokument)')
504 #my $disabled= qq|disabled="disabled"|;
505 #$disabled='' if ($form->{elster} eq '1' );
506 if ($form->{elster} eq '1') {
508 qq|<option value=elsterwinston>|
509 . $locale->text('ELSTER Export (Winston)')
511 . qq|<option value=elstertaxbird>|
512 . $locale->text('ELSTER Export (Taxbird)')
516 #$format .= qq|<option value=elster>|.$locale->text('ELSTER Export nach Winston').qq|</option>|;
517 my $show_options = qq|
520 <select name=format title = "|
521 . $locale->text('Choose Outputformat') . qq|">$format</select>
523 $lxdebug->leave_sub();
525 return $show_options;
529 $lxdebug->enter_sub();
531 # Aufruf von get_config aus bin/mozilla/ustva.pl zum
532 # Einlesen der Finanzamtdaten aus finanzamt.ini
534 get_config($userspath, 'finanzamt.ini');
536 # init some form vars
537 my @anmeldungszeitraum =
538 qw('0401' '0402' '0403' '0404' '0405' '0405' '0406' '0407' '0408' '0409' '0410' '0411' '0412' '0441' '0442' '0443' '0444');
539 foreach my $item (@anmeldungszeitraum) {
543 #forgotten the year --> thisyear
544 if ($form->{year} !~ m/^\d\d\d\d$/) {
545 $form->{year} = substr(
547 $form->current_date(\%myconfig), \%myconfig
550 $lxdebug->message(LXDebug::DEBUG1,
551 qq|Actual year from Database: $form->{year}\n|);
555 # using dates in ISO-8601 format: yyyymmmdd for Postgres...
559 if ($form->{period} eq "13") {
560 $form->{fromdate} = "$form->{year}0101";
561 $form->{todate} = "$form->{year}1231";
565 if ($form->{period} eq "41") {
566 $form->{fromdate} = "$form->{year}0101";
567 $form->{todate} = "$form->{year}0331";
568 $form->{'0441'} = "X";
570 if ($form->{period} eq "42") {
571 $form->{fromdate} = "$form->{year}0401";
572 $form->{todate} = "$form->{year}0630";
573 $form->{'0442'} = "X";
575 if ($form->{period} eq "43") {
576 $form->{fromdate} = "$form->{year}0701";
577 $form->{todate} = "$form->{year}0930";
578 $form->{'0443'} = "X";
580 if ($form->{period} eq "44") {
581 $form->{fromdate} = "$form->{year}1001";
582 $form->{todate} = "$form->{year}1231";
583 $form->{'0444'} = "X";
588 $form->{period} eq "01" && do {
589 $form->{fromdate} = "$form->{year}0101";
590 $form->{todate} = "$form->{year}0131";
591 $form->{'0401'} = "X";
594 $form->{period} eq "02" && do {
595 $form->{fromdate} = "$form->{year}0201";
597 #this works from 1901 to 2099, 1900 and 2100 fail.
598 my $leap = ($form->{year} % 4 == 0) ? "29" : "28";
599 $form->{todate} = "$form->{year}02$leap";
600 $form->{"0402"} = "X";
603 $form->{period} eq "03" && do {
604 $form->{fromdate} = "$form->{year}0301";
605 $form->{todate} = "$form->{year}0331";
606 $form->{"0403"} = "X";
609 $form->{period} eq "04" && do {
610 $form->{fromdate} = "$form->{year}0401";
611 $form->{todate} = "$form->{year}0430";
612 $form->{"0404"} = "X";
615 $form->{period} eq "05" && do {
616 $form->{fromdate} = "$form->{year}0501";
617 $form->{todate} = "$form->{year}0531";
618 $form->{"0405"} = "X";
621 $form->{period} eq "06" && do {
622 $form->{fromdate} = "$form->{year}0601";
623 $form->{todate} = "$form->{year}0630";
624 $form->{"0406"} = "X";
627 $form->{period} eq "07" && do {
628 $form->{fromdate} = "$form->{year}0701";
629 $form->{todate} = "$form->{year}0731";
630 $form->{"0407"} = "X";
633 $form->{period} eq "08" && do {
634 $form->{fromdate} = "$form->{year}0801";
635 $form->{todate} = "$form->{year}0831";
636 $form->{"0408"} = "X";
639 $form->{period} eq "09" && do {
640 $form->{fromdate} = "$form->{year}0901";
641 $form->{todate} = "$form->{year}0930";
642 $form->{"0409"} = "X";
645 $form->{period} eq "10" && do {
646 $form->{fromdate} = "$form->{year}1001";
647 $form->{todate} = "$form->{year}1031";
648 $form->{"0410"} = "X";
651 $form->{period} eq "11" && do {
652 $form->{fromdate} = "$form->{year}1101";
653 $form->{todate} = "$form->{year}1130";
654 $form->{"0411"} = "X";
657 $form->{period} eq "12" && do {
658 $form->{fromdate} = "$form->{year}1201";
659 $form->{todate} = "$form->{year}1231";
660 $form->{"0412"} = "X";
669 USTVA->ustva(\%myconfig, \%$form);
671 # reformat Dates to dateformat
672 $form->{fromdate} = $locale->date(\%myconfig, $form->{fromdate}, 0, 0, 0);
674 $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
675 $form->{todate} = $locale->date(\%myconfig, $form->{todate}, 0, 0, 0);
677 $form->{longperiod} =
678 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1, 0, 0);
680 # if there are any dates construct a where
681 if ($form->{fromdate} || $form->{todate}) {
683 $form->{todate} = $form->current_date($myconfig) unless ($form->{todate});
685 my $longtodate = $locale->date($myconfig, $form->{todate}, 1, 0, 0);
686 my $shorttodate = $locale->date($myconfig, $form->{todate}, 0, 0, 0);
688 my $longfromdate = $locale->date($myconfig, $form->{fromdate}, 1, 0, 0);
689 my $shortfromdate = $locale->date($myconfig, $form->{fromdate}, 0, 0, 0);
691 $form->{this_period} = "$shortfromdate<br>\n$shorttodate";
692 $form->{longperiod} =
693 $locale->text('for Period')
694 . qq|<br>\n$longfromdate |
695 . $locale->text('to (date)')
699 if ($form->{comparefromdate} || $form->{comparetodate}) {
700 my $longcomparefromdate =
701 $locale->date(\%myconfig, $form->{comparefromdate}, 1, 0, 0);
702 my $shortcomparefromdate =
703 $locale->date(\%myconfig, $form->{comparefromdate}, 0, 0, 0);
705 my $longcomparetodate =
706 $locale->date(\%myconfig, $form->{comparetodate}, 1, 0, 0);
707 my $shortcomparetodate =
708 $locale->date(\%myconfig, $form->{comparetodate}, 0, 0, 0);
710 $form->{last_period} = "$shortcomparefromdate<br>\n$shortcomparetodate";
711 $form->{longperiod} .=
712 "<br>\n$longcomparefromdate "
713 . $locale->text('to (date)')
714 . qq| $longcomparetodate|;
717 $form->{Datum_heute} =
718 $locale->date(\%myconfig, $form->current_date(\%myconfig), 0, 0, 0);
720 # setup variables for the form
721 my @a = qw(company businessnumber tel fax email
722 co_chief co_department co_custom1 co_custom2 co_custom3 co_custom4 co_custom5
723 co_name1 co_name2 co_street co_street1 co_zip co_city co_city1 co_country co_tel co_tel1 co_tel2
724 co_fax co_fax1 co_email co_email1 co_url co_url1 ustid duns
725 co_bankname co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1
726 co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2 co_accountnr3);
728 map { $form->{$_} = $myconfig{$_} } @a;
730 if ($form->{address} ne '') {
731 my $temp = $form->{address};
732 $temp =~ s/\\n/<br \/>/;
733 ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp);
734 $form->{co_city} =~ s/\\n//g;
738 # Outputformat specific customisation's
741 my @category_cent = qw(
742 511 861 36 80 971 931 98 96 53 74
743 85 65 66 61 62 67 63 64 59 69
744 39 83 Z43 Z45 Z53 Z62 Z65 Z67
747 my @category_euro = qw(
748 41 44 49 43 48 51 86 35 77 76 91
749 97 93 95 94 42 60 45 52 73 84
752 if ( $form->{format} eq 'pdf' or $form->{format} eq 'postscript') {
754 $form->{IN} = "$form->{type}-$form->{year}.tex";
755 $form->{padding} = "~~";
756 $form->{bold} = "\textbf{";
757 $form->{endbold} = "}";
758 $form->{br} = '\\\\';
760 # Zahlenformatierung für Latex USTVA Formulare
762 foreach my $number (@category_euro) {
763 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '');
766 my ${decimal_comma} = ( $myconfig{numberformat} eq '1.000,00'
767 or $myconfig{numberformat} eq '1000,00' ) ? ',':'.';
769 foreach my $number (@category_cent) {
770 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '');
771 $form->{$number} =~ s/${decimal_comma}/~~/g;
774 } elsif ( $form->{format} eq 'html') { # Formatierungen für HTML Ausgabe
776 $form->{IN} = $form->{type} . '.html';
777 $form->{padding} = " ";
778 $form->{bold} = "<b>";
779 $form->{endbold} = "</b>";
780 $form->{br} = "<br>";
781 $form->{address} =~ s/\\n/\n/g;
783 foreach $number (@category_cent) {
784 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '0');
787 foreach $number (@category_euro) {
788 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '0');
791 } elsif ( $form->{format} eq 'elsterwinston' ) {
793 $form->{IN} = 'winston.xml';
796 # Build Winston filename
799 my $file = 'U'; # 1. char 'U' = USTVA
800 $file .= $form->{period};
801 #4. and 5. char = year modulo 100
802 $file .= sprintf("%02d", $form->{year} % 100);
803 #6. to 18. char = Elstersteuernummer
804 #Beispiel: Steuernummer in Bayern
805 #111/222/33334 ergibt für UStVA Jan 2004: U01049111022233334
806 $file .= $form->{elsterFFFF};
807 $file .= $form->{elstersteuernummer};
810 $form->{tmpfile} = "$userspath/$file";
812 $form->{attachment_filename} = "$file";
814 # Zahlenformatierung für Winston
816 my $temp_numberformat = $myconfig{numberformat};
818 # Numberformat must be '1000.00' for Winston
820 $myconfig{numberformat} = '1000.00';
822 foreach my $number (@category_cent) {
823 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '2', '') : '';
826 foreach my $number (@category_euro) {
827 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '0', '') : '';
829 # Re-set Numberformat
830 $myconfig{numberformat} = $temp_numberformat;
834 elsif ( $form->{format} eq 'elstertaxbird' ) {
836 # Define serveral filenames
837 $form->{IN} = 'taxbird.txb';
839 $form->{attachment_filename} = "USTVA-" . $form->{period}
840 . sprintf("%02d", $form->{year} % 100) . ".txb";
842 $form->{tmpfile} = "$userspath/" . $form->{attachment_filename};
844 # TODO: set Output to UTF-8 or system Preference
845 #$form->{"iconv"} = Text::Iconv->new($myconfig{dbcharset}, "UTF-8");
846 #my $iconv = $self->{"iconv"};
847 #$iconv->convert($variable);
849 if ($form->{period} =~ /^[4]\d$/ ){
850 my %periods = ( # Lx => taxbird
857 foreach my $quarter ( keys %periods ) {
858 $form->{taxbird_period} = $periods{$quarter} if ( $form->{period} eq $quarter);
861 my %lands = ( # Lx => taxbird # TODO: besser als array...
862 'Baden Würtemberg' => '0',
865 'Brandenburg' => '3',
869 'Mecklenburg Vorpommern' => '7',
870 'Niedersachsen' => '8',
871 'Nordrhein Westfalen' => '9',
872 'Rheinland Pfalz' => '10',
875 'Sachsen Anhalt' => '13',
876 'Schleswig Holstein' => '14',
880 foreach my $land ( keys %lands ){
881 $form->{taxbird_land_nr} = $lands{$land} if ($form->{elsterland} eq $land );
884 $form->{co_zip} = $form->{co_city};
885 $form->{co_zip} =~ s/\D//g;
886 $form->{co_city} =~ s/\d//g;
887 $form->{co_city} =~ s/^\s//g;
889 ($form->{co_phone_prefix}, $form->{co_phone}) = split("-", $form->{tel});
890 $form->{co_phone_prefix} =~ s/\s//g;
891 $form->{co_phone} =~ s/\s//g;
893 $form->{taxbird_steuernummer} = $form->{steuernummer};
894 # $form->{taxbird_steuernummer} =~ s/\D//g;
895 $form->{taxbird_steuernummer} =~ s/\///; # ersten Querstrich ersetzen
897 # Numberformatting for Taxbird
898 my $temp_numberformat = $myconfig{numberformat};
900 # Numberformat must be '1000,00' for Taxbird ?!
901 $myconfig{numberformat} = '1000,00';
903 foreach my $number (@category_cent) {
904 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '2', '') : '';
907 foreach my $number (@category_euro) {
908 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '0', '') : '';
910 # Re-set Numberformat
911 $myconfig{numberformat} = $temp_numberformat;
913 } elsif ($form->{period} =~ /^\d+$/ ) {
914 $form->{period} =~ s/^0//g;
915 my $period = $form->{period};
918 $form->{period} = $period;
921 USTVA::error( $locale->text('Wrong Period' ));
925 } elsif ( $form->{format} eq '' ){ # No format error.
927 USTVA::error( $locale->text('Application Error. No Format given' ) . "!");
930 } else { # All other Formats are wrong
932 USTVA::error( $locale->text('Application Error. Wrong Format') . ": " . $form->{format} );
936 if ( $form->{period} eq '13' and $form->{format} ne 'html') {
940 'Yearly taxreport not yet implemented')
944 $form->{templates} = $myconfig{templates};
945 $form->{templates} = "doc" if ( $form->{type} eq 'help' );
947 $form->parse_template(\%myconfig, $userspath);
949 $lxdebug->leave_sub();
953 $lxdebug->enter_sub();
955 # edit all taxauthority prefs
958 &get_config($userspath, 'finanzamt.ini');
960 my $land = $form->{elsterland};
961 my $amt = $form->{elsterFFFF};
964 if ($form->{cbscript} ne '' and $form->{cblogin} ne '') {
965 $callback = qq|$form->{cbscript}|
966 .qq|?action="config_step1"|
967 .qq|&login="$form->{cblogin}"|
968 .qq|&path="$form->{cbpath}"|
969 .qq|&root="$form->{cbroot}"|
970 .qq|&rpw="$form->{cbrpw}"|;
973 $form->{title} = $locale->text('Tax Office Preferences');
976 my $select_tax_office = USTVA->fa_auswahl($land, $amt, &elster_hash());
977 my $checked_accrual = q|checked="checked"| if ($form->{method} eq 'accrual');
978 my $checked_cash = q|checked="checked"| if ($form->{method} eq 'cash');
979 my $checked_monthly = "checked" if ($form->{FA_voranmeld} eq 'month');
980 my $checked_quarterly = "checked" if ($form->{FA_voranmeld} eq 'quarter');
981 my $checked_dauerfristverlaengerung = "checked" if ($form->{FA_dauerfrist} eq '1');
982 my $checked_kz_71 = "checked" if ($form->{FA_71} eq 'X');
984 my $_hidden_variables_ref;
986 my %_hidden_local_variables = (
987 'saved' => $locale->text('Check Details'),
988 'nextsub' => 'config_step2',
992 foreach my $variable (keys %_hidden_local_variables) {
993 push @{ $_hidden_variables_ref },
994 { 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
997 my @_hidden_form_variables = qw(
998 FA_Name FA_Strasse FA_PLZ
999 FA_Ort FA_Telefon FA_Fax
1000 FA_PLZ_Grosskunden FA_PLZ_Postfach FA_Postfach
1001 FA_BLZ_1 FA_Kontonummer_1 FA_Bankbezeichnung_1
1002 FA_BLZ_2 FA_Kontonummer_2 FA_Bankbezeichnung_oertlich
1003 FA_Oeffnungszeiten FA_Email FA_Internet
1004 steuernummer elsterland elstersteuernummer
1005 elsterFFFF path login
1009 foreach my $variable (@_hidden_form_variables) {
1010 push @{ $_hidden_variables_ref},
1011 { 'variable' => $variable, 'value' => $form->{$variable} };
1015 my $steuernummer_new = '';
1017 # Variablen für das Template zur Verfügung stellen
1018 my $template_ref = {
1019 select_tax_office => $select_tax_office,
1020 checked_accrual => $checked_accrual,
1021 checked_cash => $checked_cash,
1022 checked_monthly => $checked_monthly,
1023 checked_quarterly => $checked_quarterly,
1024 checked_dauerfristverlaengerung => $checked_dauerfristverlaengerung,
1025 hidden_variables => $_hidden_variables_ref,
1029 # Ausgabe des Templates
1030 print($form->parse_html_template('ustva/config_step1', $template_ref));
1032 $lxdebug->leave_sub();
1036 $lxdebug->enter_sub();
1043 my $elsterland = '';
1044 my $elster_amt = '';
1045 my $elsterFFFF = '';
1046 my $elstersteuernummer = '';
1047 &get_config($userspath, 'finanzamt.ini')
1048 if ($form->{saved} eq $locale->text('saved'));
1050 # Auf Übergabefehler checken
1051 USTVA::info( $locale->text('Missing Tax Authoritys Preferences') . "\n"
1052 . $locale->text('USTVA-Hint: Tax Authoritys'))
1053 if ( $form->{elsterFFFF_new} eq 'Auswahl'
1054 || $form->{elsterland_new} eq 'Auswahl');
1055 USTVA::info( $locale->text('Missing Method!') . "\n"
1056 . $locale->text('USTVA-Hint: Method'))
1057 if ($form->{method} eq '');
1059 # Klären, ob Variablen bereits befüllt sind UND ob veräderungen auf
1060 # der vorherigen Maske stattfanden: $change = 1(in der edit sub,
1061 # mittels get_config)
1063 my $change = $form->{elsterland} eq $form->{elsterland_new}
1064 && $form->{elsterFFFF} eq $form->{elsterFFFF_new} ? '0' : '1';
1065 $change = '0' if ($form->{saved} eq $locale->text('saved'));
1066 my $elster_init = &elster_hash();
1068 my %elster_init = %$elster_init;
1070 if ($change eq '1') {
1073 $elsterland = $form->{elsterland_new};
1074 $elsterFFFF = $form->{elsterFFFF_new};
1075 $form->{elsterland} = $elsterland;
1076 $form->{elsterFFFF} = $elsterFFFF;
1077 $form->{steuernummer} = '';
1079 create_steuernummer();
1081 # rebuild elster_amt
1083 foreach $amt (keys %{ $elster_init{ $form->{elsterland} } }) {
1085 if ($elster_init{ $form->{elsterland}{$amt} eq $form->{elsterFFFF} });
1088 # load the predefined hash data into the FA_* Vars
1089 my @variables = qw(FA_Name FA_Strasse FA_PLZ FA_Ort
1090 FA_Telefon FA_Fax FA_PLZ_Grosskunden FA_PLZ_Postfach
1092 FA_BLZ_1 FA_Kontonummer_1 FA_Bankbezeichnung_1
1093 FA_BLZ_2 FA_Kontonummer_2 FA_Bankbezeichnung_oertlich
1094 FA_Oeffnungszeiten FA_Email FA_Internet);
1096 for (my $i = 0; $i <= 20; $i++) {
1097 $form->{ $variables[$i] } =
1098 $elster_init->{$elsterland}->{$elsterFFFF}->[$i];
1103 $elsterland = $form->{elsterland};
1104 $elsterFFFF = $form->{elsterFFFF};
1107 my $stnr = $form->{steuernummer};
1109 my $patterncount = $form->{patterncount};
1110 my $elster_pattern = $form->{elster_pattern};
1111 my $delimiter = $form->{delimiter};
1112 my $steuernummer = $form->{steuernummer} if ($steuernummer eq '');
1114 $form->{FA_Oeffnungszeiten} =~ s/\\\\n/\n/g;
1118 my $input_steuernummer = USTVA->steuernummer_input(
1119 $form->{elsterland},
1120 $form->{elsterFFFF},
1121 $form->{steuernummer}
1124 $lxdebug->message(LXDebug::DEBUG1, qq|$input_steuernummer|);
1127 my $_hidden_variables_ref;
1129 my %_hidden_local_variables = (
1130 'elsterland' => $elsterland,
1131 'elsterFFFF' => $elsterFFFF,
1132 'warnung' => $warnung,
1133 'elstersteuernummer' => $elstersteuernummer,
1134 'steuernummer' => $stnr,
1135 'lastsub' => 'config_step1',
1136 'nextsub' => 'save',
1140 foreach my $variable (keys %_hidden_local_variables) {
1141 push @{ $_hidden_variables_ref },
1142 { 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
1145 my @_hidden_form_variables = qw(
1146 FA_steuerberater_name FA_steuerberater_street
1147 FA_steuerberater_city FA_steuerberater_tel
1158 foreach my $variable (@_hidden_form_variables) {
1159 push @{ $_hidden_variables_ref},
1160 { 'variable' => $variable, 'value' => $form->{$variable} };
1163 my $template_ref = {
1164 tax_office_data => $tax_office_data,
1165 input_steuernummer => $input_steuernummer,
1166 readonly => '', #q|disabled="disabled"|,
1167 callback => $callback,
1168 hidden_variables => $_hidden_variables_ref,
1171 # Ausgabe des Templates
1172 print($form->parse_html_template('ustva/config_step2', $template_ref));
1175 $lxdebug->leave_sub();
1178 sub create_steuernummer {
1179 $lxdebug->enter_sub();
1180 my $part = $form->{part};
1181 my $patterncount = $form->{patterncount};
1182 my $delimiter = $form->{delimiter};
1183 my $elster_pattern = $form->{elster_pattern};
1185 # rebuild steuernummer and elstersteuernummer
1186 # es gibt eine gespeicherte steuernummer $form->{steuernummer}
1187 # und die parts und delimiter
1192 my $steuernummer_new = $part;
1193 my $elstersteuernummer_new = $form->{elster_FFFF};
1194 $elstersteuernummer_new .= '0';
1196 for ($h = 1; $h < $patterncount; $h++) {
1197 $steuernummer_new .= qq|$delimiter|;
1198 for (my $i = 1; $i <= length($elster_pattern); $i++) {
1199 $steuernummer_new .= $form->{"part_$h\_$i"};
1200 $elstersteuernummer_new .= $form->{"part_$h\_$i"};
1203 if ($form->{steuernummer} ne $steuernummer_new) {
1204 $form->{steuernummer} = $steuernummer_new;
1205 $form->{elstersteuernummer} = $elstersteuernummer_new;
1206 $form->{steuernummer_new} = $steuernummer_new;
1208 $form->{steuernummer_new} = '';
1209 $form->{elstersteuernummer_new} = '';
1211 $lxdebug->leave_sub();
1215 $lxdebug->enter_sub();
1217 my ($userpath, $filename) = @_;
1218 my ($key, $value) = '';
1219 open(FACONF, "$userpath/$form->{login}_$filename")
1220 or #falls Datei nicht vorhanden ist
1222 open(FANEW, ">$userpath/$form->{login}_$filename")
1223 or $form->error("$userpath/$filename : $!");
1225 open(FACONF, "$userpath/$form->{login}_$filename")
1226 or $form->error("$userpath/$form->{username}_$filename : $!");
1235 # remove any trailing whitespace
1236 s/^\s*(.*?)\s*$/$1/;
1237 ($key, $value) = split /=/, $_, 2;
1239 $form->{$key} = "$value";
1244 $lxdebug->leave_sub();
1248 $lxdebug->enter_sub();
1249 my $filename = "$form->{login}_$form->{filename}";
1251 #zuerst die steuernummer aus den part, parts_X_Y und delimiter herstellen
1252 create_steuernummer();
1254 # Textboxen formatieren: Linebreaks entfernen
1256 $form->{FA_Oeffnungszeiten} =~ s/\r\n/\\n/g;
1258 #URL mit http:// davor?
1259 $form->{FA_Internet} =~ s/^http:\/\///;
1260 $form->{FA_Internet} = 'http://' . $form->{FA_Internet};
1262 my @config = qw(elster elsterland elstersteuernummer steuernummer
1263 elsteramt elsterFFFF FA_Name FA_Strasse
1264 FA_PLZ FA_Ort FA_Telefon FA_Fax FA_PLZ_Grosskunden
1265 FA_PLZ_Postfach FA_Postfach FA_BLZ_1 FA_Kontonummer_1
1266 FA_Bankbezeichnung_1 FA_BLZ_2 FA_Kontonummer_2
1267 FA_Bankbezeichnung_oertlich FA_Oeffnungszeiten
1268 FA_Email FA_Internet FA_voranmeld method FA_steuerberater_name
1269 FA_steuerberater_street FA_steuerberater_city FA_steuerberater_tel
1270 FA_71 FA_dauerfrist);
1272 # Hier kommt dann die Plausibilitätsprüfung der ELSTERSteuernummer
1273 if ($form->{elstersteuernummer} ne '000000000') {
1274 $form->{elster} = '1';
1275 open(CONF, ">$userspath/$filename") or $form->error("$filename : $!");
1277 # create the config file
1278 print CONF qq|# Configuration file for USTVA\n\n|;
1280 foreach $key (sort @config) {
1281 $form->{$key} =~ s/\\/\\\\/g;
1283 $form->{$key} =~ s/\r\n/\n/g;
1285 print CONF qq|$key=|;
1286 if ($form->{$key} ne 'Y') {
1287 print CONF qq|$form->{$key}\n|;
1289 if ($form->{$key} eq 'Y') {
1290 print CONF qq|checked \n|;
1293 print CONF qq|\n\n|;
1295 $form->{saved} = $locale->text('saved');
1299 $form->{saved} = $locale->text('Choose a Tax Number');
1303 $lxdebug->leave_sub();
1308 $lxdebug->enter_sub();
1310 # allow Symbolic references just here:
1312 &{ $form->{nextsub} };
1314 $lxdebug->leave_sub();
1318 $lxdebug->enter_sub();
1319 &{ $form->{lastsub} };
1320 $lxdebug->leave_sub();
1324 $lxdebug->enter_sub();
1325 my $finanzamt = USTVA->query_finanzamt(\%myconfig, \%$form);
1326 $lxdebug->leave_sub();