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 "bin/mozilla/arap.pl";
28 require "bin/mozilla/common.pl";
33 #use warnings; # FATAL=> 'all';
34 #use vars qw($locale $form %myconfig);
36 #use CGI::Carp "fatalsToBrowser";
44 # this is for our long dates
45 # $locale->text('January')
46 # $locale->text('February')
47 # $locale->text('March')
48 # $locale->text('April')
49 # $locale->text('May ')
50 # $locale->text('June')
51 # $locale->text('July')
52 # $locale->text('August')
53 # $locale->text('September')
54 # $locale->text('October')
55 # $locale->text('November')
56 # $locale->text('December')
58 # this is for our short month
59 # $locale->text('Jan')
60 # $locale->text('Feb')
61 # $locale->text('Mar')
62 # $locale->text('Apr')
63 # $locale->text('May')
64 # $locale->text('Jun')
65 # $locale->text('Jul')
66 # $locale->text('Aug')
67 # $locale->text('Sep')
68 # $locale->text('Oct')
69 # $locale->text('Nov')
70 # $locale->text('Dec')
72 # $form->parse_html_template('generic/util_hidden_variables');
74 #############################
77 $lxdebug->enter_sub();
79 my $myconfig = \%myconfig;
81 $form->{title} = $locale->text('UStVA');
82 $form->{kz10} = ''; #Berichtigte Anmeldung? Ja =1 Nein=0
84 my $year = substr($form->datetonum($form->current_date(\%myconfig), \%myconfig ),
91 # Einlesen der Finanzamtdaten
92 USTVA->get_config($userspath, 'finanzamt.ini');
94 # Hier Einlesen der user-config
95 # steuernummer entfernt für prerelease
97 signature name company address businessnumber
98 tel fax email co_chief co_department
99 co_custom1 co_custom2 co_custom3 co_custom4 co_custom5
100 co_name1 co_name2 co_street co_street1 co_zip
101 co_city co_city1 co_country co_tel co_tel1
102 co_tel2 co_fax co_fax1 co_email co_email1
103 co_url co_url1 ustid duns co_bankname
104 co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1
105 co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2
109 map { $form->{$_} = $myconfig->{$_} } @a;
111 my $openings = $form->{FA_Oeffnungszeiten};
112 $openings =~ s/\\\\n/<br>/g;
114 my $company_given = ($form->{company} ne '')
115 ? qq|<h3>$form->{company}</h3>\n|
116 : qq|<a href=am.pl?action=config|
117 . qq|&level=Programm--Preferences&login=$form->{login}|
118 . qq|&password=$form->{password}>|
119 . $locale->text('No Company Name given') . qq|!</a><br>|;
122 # Anpassungen der Variablennamen auf pre 2.1.1 Namen
123 # klären, ob $form->{company_street|_address} gesetzt sind
124 if ($form->{address} ne '') {
125 my $temp = $form->{address};
126 $temp =~ s/\\n/<br \/>/;
127 ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp);
128 $form->{co_city} =~ s/\\n//g;
133 ($form->{co_street} ne ''
135 $form->{co_zip} ne ''
136 or $form->{co_city} ne ''
139 ? qq|$form->{co_street}<br>|
140 . qq|$form->{co_street1}<br>|
141 . qq|$form->{co_zip} $form->{co_city}|
142 : qq|<a href=am.pl?action=config|
143 . qq|&level=Programm--Preferences&login=$form->{login}|
144 . qq|&password=$form->{password}>|
145 . $locale->text('No Company Address given')
148 $form->{co_email} = $form->{email} unless $form->{co_email};
149 $form->{co_tel} = $form->{tel} unless $form->{co_tel};
150 $form->{co_fax} = $form->{fax} unless $form->{co_fax};
151 $form->{co_url} = $form->{urlx} unless $form->{co_url};
153 my $taxnumber_given = ($form->{steuernummer} ne '')
154 ? qq|$form->{steuernummer}|
155 : qq|<a href="ustva.pl?action="config_step1"|
156 . qq|&level=Programm--Finanzamteinstellungen&login=$form->{login}|
157 . qq|&password=$form->{password}">Keine Steuernummer hinterlegt!|
160 my $ustva_vorauswahl = &ustva_vorauswahl();
162 my @all_years = $form->all_years(\%myconfig);
164 my $select_year = qq|<select name=year title="|
165 . $locale->text('Year') . qq|">|;
166 foreach my $key (@all_years) {
167 $select_year .= qq|<option |;
168 $select_year .= qq|selected| if ($key eq $form->{year});
169 $select_year .= qq| >$key</option>|;
171 $select_year .= qq|</select>|;
174 $_checked = "checked" if ($form->{kz10} eq '1');
175 my $checkbox_kz_10 = qq|<input name="FA_10" id=FA_10 class=checkbox|
176 . qq| type=checkbox value="1" $_checked title = "|
177 . $locale->text('Amended Advance Turnover Tax Return (Nr. 10)')
179 . $locale->text('Amended Advance Turnover Tax Return');
181 my $method_local = ($form->{method} eq 'accrual') ? $locale->text('accrual')
182 : ($form->{method} eq 'cash') ? $locale->text('cash')
185 my $period_local = ( $form->{FA_voranmeld} eq 'month') ? $locale->text('month')
186 : ( $form->{FA_voranmeld} eq 'quarter') ? $locale->text('quarter')
189 my $tax_office_banks_ref = [
190 { BLZ => $form->{FA_BLZ_1},
191 Kontonummer => $form->{FA_Kontonummer_1},
192 Bankbezeichnung => $form->{FA_Bankbezeichnung_1}
194 { BLZ => $form->{FA_BLZ_2},
195 Kontonummer => $form->{FA_Kontonummer_2},
196 Bankbezeichnung => $form->{FA_Bankbezeichnung_oertlich}
202 openings => $openings,
203 company_given => $company_given,
204 address_given => $address_given,
205 taxnumber_given => $taxnumber_given,
206 select_year => $select_year,
207 period_local => $period_local,
208 method_local => $method_local,
209 ustva_vorauswahl => $ustva_vorauswahl,
210 checkbox_kz_10 => $checkbox_kz_10,
211 tax_office_banks => $tax_office_banks_ref,
212 select_options => &show_options,
215 print($form->parse_html_template('ustva/report', $template_ref));
219 $lxdebug->leave_sub();
225 $lxdebug->enter_sub();
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();
244 $lxdebug->leave_sub();
245 call_sub($form->{"nextsub"});
249 sub ustva_vorauswahl {
250 $lxdebug->enter_sub();
252 my $select_vorauswahl;
254 #Aktuelles Datum zerlegen:
255 my $date = $form->datetonum($form->current_date(\%myconfig), \%myconfig);
257 #$locale->date($myconfig, $form->current_date($myconfig), 0)=~ /(\d\d).(\d\d).(\d\d\d\d)/;
258 $form->{day} = substr($date, 6, 2);
259 $form->{month} = substr($date, 4, 2);
260 $form->{year} = substr($date, 0, 4);
261 $lxdebug->message(LXDebug::DEBUG1, qq|
262 Actual date from Database: $date\n
263 Actual year from Database: $form->{year}\n
264 Actual day from Database: $form->{day}\n
265 Actual month from Database: $form->{month}\n|);
270 # Testdaten erzeugen:
272 #$form->{month}= '01';
273 #$form->{year}= 2004;
274 $select_vorauswahl = qq|
275 <input type=hidden name=day value=$form->{day}>
276 <input type=hidden name=month value=$form->{month}>
277 <input type=hidden name=yymmdd value=$yymmdd>
278 <input type=hidden name=sel value=$sel>
281 if ($form->{FA_voranmeld} eq 'month') {
283 # Vorauswahl bei monatlichem Voranmeldungszeitraum
285 my %liste = ('01' => $locale->text('January'),
286 '02' => $locale->text('February'),
287 '03' => $locale->text('March'),
288 '04' => $locale->text('April'),
289 '05' => $locale->text('May'),
290 '06' => $locale->text('June'),
291 '07' => $locale->text('July'),
292 '08' => $locale->text('August'),
293 '09' => $locale->text('September'),
294 '10' => $locale->text('October'),
295 '11' => $locale->text('November'),
296 '12' => $locale->text('December'),
297 '13' => $locale->text('Yearly'),
300 my $yy = $form->{year} * 10000;
301 $yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
305 # Offset für Dauerfristverlängerung
306 $dfv = '100' if ($form->{FA_dauerfrist} eq '1');
309 $yymmdd <= ($yy + 110 + $dfv) && do {
310 $form->{year} = $form->{year} - 1;
314 $yymmdd <= ($yy + 210 + $dfv) && do {
318 $yymmdd <= ($yy + 310 + $dfv) && do {
322 $yymmdd <= ($yy + 410 + $dfv) && do {
326 $yymmdd <= ($yy + 510 + $dfv) && do {
330 $yymmdd <= ($yy + 610 + $dfv) && do {
334 $yymmdd <= ($yy + 710 + $dfv) && do {
338 $yymmdd <= ($yy + 810 + $dfv) && do {
342 $yymmdd <= ($yy + 910 + $dfv) && do {
346 $yymmdd <= ($yy + 1010 + $dfv) && do {
350 $yymmdd <= ($yy + 1110 + $dfv) && do {
354 $yymmdd <= ($yy + 1210) && do {
358 $yymmdd <= ($yy + 1231) && do {
364 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
365 . $locale->text('Select a period') . qq|" >|;
368 foreach $key (sort keys %liste) {
370 $selected = 'selected' if ($sel eq $key);
371 $select_vorauswahl .= qq|
372 <option value="$key" $selected> $liste{$key}</option>
375 $select_vorauswahl .= qq|</select>|;
377 } elsif ($form->{FA_voranmeld} eq 'quarter') {
379 # Vorauswahl bei quartalsweisem Voranmeldungszeitraum
380 my %liste = ('41' => $locale->text('1. Quarter'),
381 '42' => $locale->text('2. Quarter'),
382 '43' => $locale->text('3. Quarter'),
383 '44' => $locale->text('4. Quarter'),
384 '13' => $locale->text('Yearly'),);
386 my $yy = $form->{year} * 10000;
387 $yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
389 my $dfv = ''; # Offset für Dauerfristverlängerung
390 $dfv = '100' if ($form->{FA_dauerfrist} eq '1');
393 $yymmdd <= ($yy + 110 + $dfv) && do {
394 $form->{year} = $form->{year} - 1;
398 $yymmdd <= ($yy + 410 + $dfv) && do {
402 $yymmdd <= ($yy + 710 + $dfv) && do {
406 $yymmdd <= ($yy + 1010 + $dfv) && do {
410 $yymmdd <= ($yy + 1231) && do {
415 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
416 . $locale->text('Select a period') . qq|" >|;
418 foreach $key (sort keys %liste) {
420 $selected = 'selected' if ($sel eq $key);
421 $select_vorauswahl .= qq|
422 <option value="$key" $selected>$liste{$key}</option>
425 $select_vorauswahl .= qq|\n</select>
430 # keine Vorauswahl bei Voranmeldungszeitraum
431 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
432 . $locale->text('Select a period') . qq|" >|;
434 my %listea = ('41' => '1. Quarter',
435 '42' => '2. Quarter',
436 '43' => '3. Quarter',
437 '44' => '4. Quarter',);
439 my %listeb = ('01' => 'January',
453 foreach $key (sort keys %listea) {
454 $select_vorauswahl .= qq|
455 <option value="$key">|
456 . $locale->text("$listea{$key}")
460 foreach $key (sort keys %listeb) {
461 $select_vorauswahl .= qq|
462 <option value="$key">|
463 . $locale->text("$listeb{$key}")
466 $select_vorauswahl .= qq|</select>|;
468 $lxdebug->leave_sub();
470 return $select_vorauswahl;
474 # $lxdebug->enter_sub();
476 # $lxdebug->leave_sub();
480 $lxdebug->enter_sub();
482 $lxdebug->leave_sub();
486 $lxdebug->enter_sub();
488 # $form->{PD}{$form->{type}} = "selected";
489 # $form->{DF}{$form->{format}} = "selected";
490 # $form->{OP}{$form->{media}} = "selected";
491 # $form->{SM}{$form->{sendmode}} = "selected";
492 my $type = qq| <input type=hidden name="type" value="ustva">|;
493 my $media = qq| <input type=hidden name="media" value="screen">|;
495 qq| <option value=html selected>|
496 . $locale->text('Preview')
498 if ($latex_templates) {
500 qq| <option value=pdf>|
501 . $locale->text('UStVA (PDF-Dokument)')
505 #my $disabled= qq|disabled="disabled"|;
506 #$disabled='' if ($form->{elster} eq '1' );
507 if ($form->{elster} eq '1') {
509 qq|<option value=elsterwinston>|
510 . $locale->text('ELSTER Export (Winston)')
512 . qq|<option value=elstertaxbird>|
513 . $locale->text('ELSTER Export (Taxbird)')
517 #$format .= qq|<option value=elster>|.$locale->text('ELSTER Export nach Winston').qq|</option>|;
518 my $show_options = qq|
521 <select name=format title = "|
522 . $locale->text('Choose Outputformat') . qq|">$format</select>
524 $lxdebug->leave_sub();
526 return $show_options;
530 $lxdebug->enter_sub();
532 # Aufruf von get_config zum Einlesen der Finanzamtdaten aus finanzamt.ini
534 USTVA->get_config($userspath, 'finanzamt.ini');
536 # init some form vars
537 my @anmeldungszeitraum =
538 qw('0401' '0402' '0403'
542 '0441' '0442' '0443' '0444');
544 foreach my $item (@anmeldungszeitraum) {
548 #forgotten the year --> thisyear
549 if ($form->{year} !~ m/^\d\d\d\d$/) {
550 $form->{year} = substr(
552 $form->current_date(\%myconfig), \%myconfig
555 $lxdebug->message(LXDebug::DEBUG1,
556 qq|Actual year from Database: $form->{year}\n|);
560 # using dates in ISO-8601 format: yyyymmmdd for Postgres...
564 if ($form->{period} eq "13") {
565 $form->{fromdate} = "$form->{year}0101";
566 $form->{todate} = "$form->{year}1231";
570 if ($form->{period} eq "41") {
571 $form->{fromdate} = "$form->{year}0101";
572 $form->{todate} = "$form->{year}0331";
573 $form->{'0441'} = "X";
575 if ($form->{period} eq "42") {
576 $form->{fromdate} = "$form->{year}0401";
577 $form->{todate} = "$form->{year}0630";
578 $form->{'0442'} = "X";
580 if ($form->{period} eq "43") {
581 $form->{fromdate} = "$form->{year}0701";
582 $form->{todate} = "$form->{year}0930";
583 $form->{'0443'} = "X";
585 if ($form->{period} eq "44") {
586 $form->{fromdate} = "$form->{year}1001";
587 $form->{todate} = "$form->{year}1231";
588 $form->{'0444'} = "X";
593 $form->{period} eq "01" && do {
594 $form->{fromdate} = "$form->{year}0101";
595 $form->{todate} = "$form->{year}0131";
596 $form->{'0401'} = "X";
599 $form->{period} eq "02" && do {
600 $form->{fromdate} = "$form->{year}0201";
602 #this works from 1901 to 2099, 1900 and 2100 fail.
603 my $leap = ($form->{year} % 4 == 0) ? "29" : "28";
604 $form->{todate} = "$form->{year}02$leap";
605 $form->{"0402"} = "X";
608 $form->{period} eq "03" && do {
609 $form->{fromdate} = "$form->{year}0301";
610 $form->{todate} = "$form->{year}0331";
611 $form->{"0403"} = "X";
614 $form->{period} eq "04" && do {
615 $form->{fromdate} = "$form->{year}0401";
616 $form->{todate} = "$form->{year}0430";
617 $form->{"0404"} = "X";
620 $form->{period} eq "05" && do {
621 $form->{fromdate} = "$form->{year}0501";
622 $form->{todate} = "$form->{year}0531";
623 $form->{"0405"} = "X";
626 $form->{period} eq "06" && do {
627 $form->{fromdate} = "$form->{year}0601";
628 $form->{todate} = "$form->{year}0630";
629 $form->{"0406"} = "X";
632 $form->{period} eq "07" && do {
633 $form->{fromdate} = "$form->{year}0701";
634 $form->{todate} = "$form->{year}0731";
635 $form->{"0407"} = "X";
638 $form->{period} eq "08" && do {
639 $form->{fromdate} = "$form->{year}0801";
640 $form->{todate} = "$form->{year}0831";
641 $form->{"0408"} = "X";
644 $form->{period} eq "09" && do {
645 $form->{fromdate} = "$form->{year}0901";
646 $form->{todate} = "$form->{year}0930";
647 $form->{"0409"} = "X";
650 $form->{period} eq "10" && do {
651 $form->{fromdate} = "$form->{year}1001";
652 $form->{todate} = "$form->{year}1031";
653 $form->{"0410"} = "X";
656 $form->{period} eq "11" && do {
657 $form->{fromdate} = "$form->{year}1101";
658 $form->{todate} = "$form->{year}1130";
659 $form->{"0411"} = "X";
662 $form->{period} eq "12" && do {
663 $form->{fromdate} = "$form->{year}1201";
664 $form->{todate} = "$form->{year}1231";
665 $form->{"0412"} = "X";
670 # Kontrollvariable für die Templates
671 $form->{'year2007'} = ($form->{year} >= 2007 ) ? "1":"0";
675 USTVA->ustva(\%myconfig, \%$form);
677 # reformat Dates to dateformat
678 $form->{fromdate} = $locale->date(\%myconfig, $form->{fromdate}, 0, 0, 0);
680 $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
681 $form->{todate} = $locale->date(\%myconfig, $form->{todate}, 0, 0, 0);
683 $form->{longperiod} =
684 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1, 0, 0);
686 # if there are any dates construct a where
687 if ($form->{fromdate} || $form->{todate}) {
689 $form->{todate} = $form->current_date($myconfig) unless ($form->{todate});
691 my $longtodate = $locale->date($myconfig, $form->{todate}, 1, 0, 0);
692 my $shorttodate = $locale->date($myconfig, $form->{todate}, 0, 0, 0);
694 my $longfromdate = $locale->date($myconfig, $form->{fromdate}, 1, 0, 0);
695 my $shortfromdate = $locale->date($myconfig, $form->{fromdate}, 0, 0, 0);
697 $form->{this_period} = "$shortfromdate<br>\n$shorttodate";
698 $form->{longperiod} =
699 $locale->text('for Period')
700 . qq|<br>\n$longfromdate |
701 . $locale->text('to (date)')
705 if ($form->{comparefromdate} || $form->{comparetodate}) {
706 my $longcomparefromdate =
707 $locale->date(\%myconfig, $form->{comparefromdate}, 1, 0, 0);
708 my $shortcomparefromdate =
709 $locale->date(\%myconfig, $form->{comparefromdate}, 0, 0, 0);
711 my $longcomparetodate =
712 $locale->date(\%myconfig, $form->{comparetodate}, 1, 0, 0);
713 my $shortcomparetodate =
714 $locale->date(\%myconfig, $form->{comparetodate}, 0, 0, 0);
716 $form->{last_period} = "$shortcomparefromdate<br>\n$shortcomparetodate";
717 $form->{longperiod} .=
718 "<br>\n$longcomparefromdate "
719 . $locale->text('to (date)')
720 . qq| $longcomparetodate|;
723 $form->{Datum_heute} =
724 $locale->date(\%myconfig, $form->current_date(\%myconfig), 0, 0, 0);
726 # setup variables for the form
727 my @a = qw(company businessnumber tel fax email
728 co_chief co_department co_custom1 co_custom2 co_custom3 co_custom4 co_custom5
729 co_name1 co_name2 co_street co_street1 co_zip co_city co_city1 co_country co_tel co_tel1 co_tel2
730 co_fax co_fax1 co_email co_email1 co_url co_url1 ustid duns
731 co_bankname co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1
732 co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2 co_accountnr3);
734 map { $form->{$_} = $myconfig{$_} } @a;
736 if ($form->{address} ne '') {
737 my $temp = $form->{address};
738 $temp =~ s/\\n/<br \/>/;
739 ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp);
740 $form->{co_city} =~ s/\\n//g;
743 ################################
745 # Nation specific customisations
747 ################################
751 if ( $form->{coa} eq 'Germany-DATEV-SKR03EU' or $form->{coa} eq 'Germany-DATEV-SKR04EU') {
754 # Outputformat specific customisation's
757 my @category_cent = USTVA->report_variables({
758 myconfig => \%myconfig,
761 attribute => 'position',
765 push @category_cent, qw(83 Z43 Z45 Z53 Z62 Z65 Z67);
767 my @category_euro = USTVA->report_variables({
768 myconfig => \%myconfig,
771 attribute => 'position',
776 $form->{amount} = [];
778 if ( $form->{format} eq 'pdf' or $form->{format} eq 'postscript') {
780 $form->{IN} = "$form->{type}-$form->{year}.tex";
781 $form->{padding} = "~~";
782 $form->{bold} = "\textbf{";
783 $form->{endbold} = "}";
784 $form->{br} = '\\\\';
786 # Zahlenformatierung für Latex USTVA Formulare
788 foreach my $number (@category_euro) {
789 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '');
792 my ${decimal_comma} = ( $myconfig{numberformat} eq '1.000,00'
793 or $myconfig{numberformat} eq '1000,00' ) ? ',':'.';
795 foreach my $number (@category_cent) {
796 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '');
797 $form->{$number} =~ s/${decimal_comma}/~~/g;
800 } elsif ( $form->{format} eq 'html') { # Formatierungen für HTML Ausgabe
802 $form->{IN} = $form->{type} . '.html';
803 $form->{padding} = " ";
804 $form->{bold} = "<b>";
805 $form->{endbold} = "</b>";
806 $form->{br} = "<br>";
807 $form->{address} =~ s/\\n/\n/g;
809 foreach $number (@category_cent) {
810 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '0');
813 foreach $number (@category_euro) {
814 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '0');
817 } elsif ( $form->{format} eq 'elsterwinston' ) {
819 $form->{IN} = 'winston.xml';
822 # Build Winston filename
825 my $file = 'U'; # 1. char 'U' = USTVA
826 $file .= $form->{period};
827 #4. and 5. char = year modulo 100
828 $file .= sprintf("%02d", $form->{year} % 100);
829 #6. to 18. char = Elstersteuernummer
830 #Beispiel: Steuernummer in Bayern
831 #111/222/33334 ergibt für UStVA Jan 2004: U01049111022233334
832 $file .= $form->{elsterFFFF};
833 $file .= $form->{elstersteuernummer};
837 $form->{tmpfile} = "$userspath/$file";
839 $form->{attachment_filename} = $file;
841 # Zahlenformatierung für Winston
843 my $temp_numberformat = $myconfig{numberformat};
845 # Numberformat must be '1000.00' for Winston
847 $myconfig{numberformat} = '1000.00';
849 foreach my $number (@category_cent) {
850 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '2', '') : '';
853 foreach my $number (@category_euro) {
854 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '0', '') : '';
856 # Re-set Numberformat
857 $myconfig{numberformat} = $temp_numberformat;
859 # push Kennziffern to <%foreach Array fo easyer
860 # output in xml format. Thx to Moritz.
861 my %winston_id_for = (
865 foreach my $kennziffer (@category_cent, @category_euro) {
867 next if ( $kennziffer =~ m/Z\d\d/);
868 next if ( $form->{$kennziffer} == 0 );
870 if (defined $winston_id_for{$kennziffer} ) {
871 push(@{ $form->{id}}, $winston_id_for{$kennziffer});
873 push(@{ $form->{id}}, "Kz$kennziffer");
875 push(@{ $form->{amount}}, $form->{$kennziffer});
878 } elsif ( $form->{format} eq 'elstertaxbird' ) {
880 # Define serveral filenames
881 $form->{IN} = 'taxbird.txb';
883 $form->{attachment_filename} = "USTVA-" . $form->{period}
884 . sprintf("%02d", $form->{year} % 100) . ".txb";
886 $form->{attachment_filename} =~ s|.*/||;
887 $form->{tmpfile} = "$userspath/" . $form->{attachment_filename};
889 # TODO: set Output to UTF-8 or system Preference
890 #$form->{"iconv"} = Text::Iconv->new($myconfig{dbcharset}, "UTF-8");
891 #my $iconv = $self->{"iconv"};
892 #$iconv->convert($variable);
893 if ($form->{period} =~ /^[4]\d$/ ){
894 my %periods = ( # Lx => taxbird
901 foreach my $quarter ( keys %periods ) {
902 $form->{taxbird_period} = $periods{$quarter} if ( $form->{period} eq $quarter);
904 } elsif ($form->{period} =~ /^\d+$/ ) {
905 $form->{period} =~ s/^0//g;
906 my $period = $form->{period};
909 $form->{period} = $period;
912 USTVA::error( $locale->text('Wrong Period' ));
916 my %lands = ( # Lx => taxbird # TODO: besser als array...
917 'Baden Würtemberg' => '0',
920 'Brandenburg' => '3',
924 'Mecklenburg Vorpommern' => '7',
925 'Niedersachsen' => '8',
926 'Nordrhein Westfalen' => '9',
927 'Rheinland Pfalz' => '10',
930 'Sachsen Anhalt' => '13',
931 'Schleswig Holstein' => '14',
934 foreach my $land ( keys %lands ){
935 $form->{taxbird_land_nr} = $lands{$land} if ($form->{elsterland} eq $land );
938 $form->{co_zip} = $form->{co_city};
939 $form->{co_zip} =~ s/\D//g;
940 $form->{co_city} =~ s/\d//g;
941 $form->{co_city} =~ s/^\s//g;
943 ($form->{co_phone_prefix}, $form->{co_phone}) = split("-", $form->{tel});
944 $form->{co_phone_prefix} =~ s/\s//g;
945 $form->{co_phone} =~ s/\s//g;
947 $form->{taxbird_steuernummer} = $form->{steuernummer};
948 # $form->{taxbird_steuernummer} =~ s/\D//g;
949 $form->{taxbird_steuernummer} =~ s/\///; # ersten Querstrich ersetzen
951 # Numberformatting for Taxbird
952 my $temp_numberformat = $myconfig{numberformat};
953 # Numberformat must be '1000,00' for Taxbird ?!
954 $myconfig{numberformat} = '1000,00';
955 foreach my $number (@category_cent) {
956 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '2', '') : '';
959 foreach my $number (@category_euro) {
960 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '0', '') : '';
962 # Re-set Numberformat
963 $myconfig{numberformat} = $temp_numberformat;
965 # push Kennziffern to <%foreach Array fo easyer
966 # output in xml format. Thx to Moritz.
967 my %taxbird_id_for = (
969 '511' => 'Kz51-calc',
970 '861' => 'Kz86-calc',
971 '971' => 'Kz97-calc',
972 '931' => 'Kz93-calc',
973 '811' => 'Kz81-calc',
974 '891' => 'Kz89-calc',
975 'Z45' => 'uebertrag',
977 'Z62' => 'ust-minus-vost',
978 'Z65' => 'ust-sum+69',
983 for my $kennziffer (@category_cent, @category_euro) {
985 next if ($kennziffer eq 'Z43');
987 if ($form->{$kennziffer} != 0){
988 if (defined $taxbird_id_for{$kennziffer}) {
989 push(@{ $form->{id}}, $taxbird_id_for{$kennziffer});
991 push(@{ $form->{id}}, "Kz$kennziffer");
993 push(@{ $form->{amount}}, $form->{$kennziffer});
997 } elsif ( $form->{format} eq '' ){ # No format error.
999 USTVA::error( $locale->text('Application Error. No Format given' ) . "!");
1002 } else { # All other Formats are wrong
1004 USTVA::error( $locale->text('Application Error. Wrong Format') . ": " . $form->{format} );
1009 } elsif ($form->{coa} eq 'Austria') {
1012 # Outputformat specific customisation's
1015 my @category_euro = qw(
1016 511 861 36 80 971 931 98 96 53 74
1017 85 65 66 61 62 67 63 64 59 69
1018 39 83 811 891 Z43 Z45 Z53 Z62 Z65 Z67
1019 41 44 49 43 48 51 86 35 77 76 91 89
1020 97 93 95 94 42 60 45 52 73 84 81
1024 if ( $form->{format} eq 'html') { # Formatierungen für HTML Ausgabe
1026 $form->{IN} = $form->{type} . '.html';
1027 $form->{padding} = " ";
1028 $form->{bold} = "<b>";
1029 $form->{endbold} = "</b>";
1030 $form->{br} = "<br>";
1031 $form->{address} =~ s/\\n/\n/g;
1033 foreach $number (@category_euro) {
1034 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '0');
1040 # end nation specific customisations
1042 if ( $form->{period} eq '13' and $form->{format} ne 'html') {
1046 'Yearly taxreport not yet implemented')
1050 $form->{templates} = $myconfig{templates};
1051 $form->{templates} = "doc" if ( $form->{type} eq 'help' );
1053 $form->parse_template(\%myconfig, $userspath);
1055 $lxdebug->leave_sub();
1059 $lxdebug->enter_sub();
1061 # edit all taxauthority prefs
1064 USTVA->get_config($userspath, 'finanzamt.ini');
1066 my $land = $form->{elsterland};
1067 my $amt = $form->{elsterFFFF};
1070 if ($form->{cbscript} ne '' and $form->{cblogin} ne '') {
1071 $callback = qq|$form->{cbscript}|
1072 .qq|?action="config_step1"|
1073 .qq|&login="$form->{cblogin}"|
1074 .qq|&root="$form->{cbroot}"|
1075 .qq|&rpw="$form->{cbrpw}"|;
1078 $form->{title} = $locale->text('Tax Office Preferences');
1081 my $select_tax_office = USTVA->fa_auswahl($land, $amt, &elster_hash());
1082 my $checked_accrual = q|checked="checked"| if ($form->{method} eq 'accrual');
1083 my $checked_cash = q|checked="checked"| if ($form->{method} eq 'cash');
1084 my $checked_monthly = "checked" if ($form->{FA_voranmeld} eq 'month');
1085 my $checked_quarterly = "checked" if ($form->{FA_voranmeld} eq 'quarter');
1086 my $checked_dauerfristverlaengerung = "checked" if ($form->{FA_dauerfrist} eq '1');
1087 my $checked_kz_71 = "checked" if ($form->{FA_71} eq 'X');
1089 my $_hidden_variables_ref;
1091 my %_hidden_local_variables = (
1092 'saved' => $locale->text('Check Details'),
1093 'nextsub' => 'config_step2',
1097 foreach my $variable (keys %_hidden_local_variables) {
1098 push @{ $_hidden_variables_ref },
1099 { 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
1102 my @_hidden_form_variables = qw(
1103 FA_Name FA_Strasse FA_PLZ
1104 FA_Ort FA_Telefon FA_Fax
1105 FA_PLZ_Grosskunden FA_PLZ_Postfach FA_Postfach
1106 FA_BLZ_1 FA_Kontonummer_1 FA_Bankbezeichnung_1
1107 FA_BLZ_2 FA_Kontonummer_2 FA_Bankbezeichnung_oertlich
1108 FA_Oeffnungszeiten FA_Email FA_Internet
1109 steuernummer elsterland elstersteuernummer
1110 elsterFFFF login password
1113 foreach my $variable (@_hidden_form_variables) {
1114 push @{ $_hidden_variables_ref},
1115 { 'variable' => $variable, 'value' => $form->{$variable} };
1119 my $steuernummer_new = '';
1121 # Variablen für das Template zur Verfügung stellen
1122 my $template_ref = {
1123 select_tax_office => $select_tax_office,
1124 checked_accrual => $checked_accrual,
1125 checked_cash => $checked_cash,
1126 checked_monthly => $checked_monthly,
1127 checked_quarterly => $checked_quarterly,
1128 checked_dauerfristverlaengerung => $checked_dauerfristverlaengerung,
1129 hidden_variables => $_hidden_variables_ref,
1133 # Ausgabe des Templates
1134 print($form->parse_html_template('ustva/config_step1', $template_ref));
1136 $lxdebug->leave_sub();
1140 $lxdebug->enter_sub();
1147 my $elsterland = '';
1148 my $elster_amt = '';
1149 my $elsterFFFF = '';
1150 my $elstersteuernummer = '';
1151 USTVA->get_config($userspath, 'finanzamt.ini')
1152 if ($form->{saved} eq $locale->text('saved'));
1154 # Auf Übergabefehler checken
1155 USTVA::info( $locale->text('Missing Tax Authoritys Preferences') . "\n"
1156 . $locale->text('USTVA-Hint: Tax Authoritys'))
1157 if ( $form->{elsterFFFF_new} eq 'Auswahl'
1158 || $form->{elsterland_new} eq 'Auswahl');
1159 USTVA::info( $locale->text('Missing Method!') . "\n"
1160 . $locale->text('USTVA-Hint: Method'))
1161 if ($form->{method} eq '');
1163 # Klären, ob Variablen bereits befüllt sind UND ob veräderungen auf
1164 # der vorherigen Maske stattfanden: $change = 1(in der edit sub,
1165 # mittels get_config)
1167 my $change = $form->{elsterland} eq $form->{elsterland_new}
1168 && $form->{elsterFFFF} eq $form->{elsterFFFF_new} ? '0' : '1';
1169 $change = '0' if ($form->{saved} eq $locale->text('saved'));
1170 my $elster_init = &elster_hash();
1172 my %elster_init = %$elster_init;
1174 if ($change eq '1') {
1177 $elsterland = $form->{elsterland_new};
1178 $elsterFFFF = $form->{elsterFFFF_new};
1179 $form->{elsterland} = $elsterland;
1180 $form->{elsterFFFF} = $elsterFFFF;
1181 $form->{steuernummer} = '';
1183 create_steuernummer();
1185 # rebuild elster_amt
1187 foreach $amt (keys %{ $elster_init{ $form->{elsterland} } }) {
1189 if ($elster_init{ $form->{elsterland}{$amt} eq $form->{elsterFFFF} });
1192 # load the predefined hash data into the FA_* Vars
1193 my @variables = qw(FA_Name FA_Strasse FA_PLZ FA_Ort
1194 FA_Telefon FA_Fax FA_PLZ_Grosskunden FA_PLZ_Postfach
1196 FA_BLZ_1 FA_Kontonummer_1 FA_Bankbezeichnung_1
1197 FA_BLZ_2 FA_Kontonummer_2 FA_Bankbezeichnung_oertlich
1198 FA_Oeffnungszeiten FA_Email FA_Internet);
1200 for (my $i = 0; $i <= 20; $i++) {
1201 $form->{ $variables[$i] } =
1202 $elster_init->{$elsterland}->{$elsterFFFF}->[$i];
1207 $elsterland = $form->{elsterland};
1208 $elsterFFFF = $form->{elsterFFFF};
1211 my $stnr = $form->{steuernummer};
1213 my $patterncount = $form->{patterncount};
1214 my $elster_pattern = $form->{elster_pattern};
1215 my $delimiter = $form->{delimiter};
1216 my $steuernummer = $form->{steuernummer} if ($steuernummer eq '');
1218 $form->{FA_Oeffnungszeiten} =~ s/\\\\n/\n/g;
1222 my $input_steuernummer = USTVA->steuernummer_input(
1223 $form->{elsterland},
1224 $form->{elsterFFFF},
1225 $form->{steuernummer}
1228 $lxdebug->message(LXDebug::DEBUG1, qq|$input_steuernummer|);
1231 my $_hidden_variables_ref;
1233 my %_hidden_local_variables = (
1234 'elsterland' => $elsterland,
1235 'elsterFFFF' => $elsterFFFF,
1236 'warnung' => $warnung,
1237 'elstersteuernummer' => $elstersteuernummer,
1238 'steuernummer' => $stnr,
1239 'lastsub' => 'config_step1',
1240 'nextsub' => 'save',
1244 foreach my $variable (keys %_hidden_local_variables) {
1245 push @{ $_hidden_variables_ref },
1246 { 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
1249 my @_hidden_form_variables = qw(
1250 FA_steuerberater_name FA_steuerberater_street
1251 FA_steuerberater_city FA_steuerberater_tel
1262 foreach my $variable (@_hidden_form_variables) {
1263 push @{ $_hidden_variables_ref},
1264 { 'variable' => $variable, 'value' => $form->{$variable} };
1267 my $template_ref = {
1268 tax_office_data => $tax_office_data,
1269 input_steuernummer => $input_steuernummer,
1270 readonly => '', #q|disabled="disabled"|,
1271 callback => $callback,
1272 hidden_variables => $_hidden_variables_ref,
1275 # Ausgabe des Templates
1276 print($form->parse_html_template('ustva/config_step2', $template_ref));
1279 $lxdebug->leave_sub();
1282 sub create_steuernummer {
1283 $lxdebug->enter_sub();
1284 my $part = $form->{part};
1285 my $patterncount = $form->{patterncount};
1286 my $delimiter = $form->{delimiter};
1287 my $elster_pattern = $form->{elster_pattern};
1289 # rebuild steuernummer and elstersteuernummer
1290 # es gibt eine gespeicherte steuernummer $form->{steuernummer}
1291 # und die parts und delimiter
1296 my $steuernummer_new = $part;
1297 my $elstersteuernummer_new = $form->{elster_FFFF};
1298 $elstersteuernummer_new .= '0';
1300 for ($h = 1; $h < $patterncount; $h++) {
1301 $steuernummer_new .= qq|$delimiter|;
1302 for (my $i = 1; $i <= length($elster_pattern); $i++) {
1303 $steuernummer_new .= $form->{"part_$h\_$i"};
1304 $elstersteuernummer_new .= $form->{"part_$h\_$i"};
1307 if ($form->{steuernummer} ne $steuernummer_new) {
1308 $form->{steuernummer} = $steuernummer_new;
1309 $form->{elstersteuernummer} = $elstersteuernummer_new;
1310 $form->{steuernummer_new} = $steuernummer_new;
1312 $form->{steuernummer_new} = '';
1313 $form->{elstersteuernummer_new} = '';
1315 $lxdebug->leave_sub();
1319 $lxdebug->enter_sub();
1321 my $filename = "$form->{login}_$form->{filename}";
1322 $filename =~ s|.*/||;
1324 #zuerst die steuernummer aus den part, parts_X_Y und delimiter herstellen
1325 create_steuernummer();
1327 # Textboxen formatieren: Linebreaks entfernen
1329 $form->{FA_Oeffnungszeiten} =~ s/\r\n/\\n/g;
1331 #URL mit http:// davor?
1332 $form->{FA_Internet} =~ s/^http:\/\///;
1333 $form->{FA_Internet} = 'http://' . $form->{FA_Internet};
1336 elster elsterland elstersteuernummer steuernummer
1337 elsteramt elsterFFFF FA_Name FA_Strasse
1338 FA_PLZ FA_Ort FA_Telefon FA_Fax
1339 FA_PLZ_Grosskunden FA_PLZ_Postfach FA_Postfach FA_BLZ_1
1340 FA_Kontonummer_1 FA_Bankbezeichnung_1 FA_BLZ_2 FA_Kontonummer_2
1341 FA_Bankbezeichnung_oertlich FA_Oeffnungszeiten
1342 FA_Email FA_Internet FA_voranmeld method FA_steuerberater_name
1343 FA_steuerberater_street FA_steuerberater_city FA_steuerberater_tel
1344 FA_71 FA_dauerfrist);
1346 # Hier kommt dann die Plausibilitätsprüfung der ELSTERSteuernummer
1347 if ($form->{elstersteuernummer} ne '000000000') {
1349 $form->{elster} = '1';
1351 open my $ustvaconfig, ">", "$userspath/$filename" or $form->error("$filename : $!");
1353 # create the config file
1354 print {$ustvaconfig} qq|# Configuration file for USTVA\n\n|;
1356 foreach $key (sort @config) {
1357 $form->{$key} =~ s/\\/\\\\/g;
1359 $form->{$key} =~ s/\r\n/\n/g;
1361 print {$ustvaconfig} qq|$key=|;
1362 if ($form->{$key} ne 'Y') {
1363 print {$ustvaconfig} qq|$form->{$key}\n|;
1365 if ($form->{$key} eq 'Y') {
1366 print {$ustvaconfig} qq|checked \n|;
1369 print {$ustvaconfig} qq|\n\n|;
1371 $form->{saved} = $locale->text('saved');
1375 $form->{saved} = $locale->text('Choose a Tax Number');
1379 $lxdebug->leave_sub();
1384 $lxdebug->enter_sub();
1386 # allow Symbolic references just here:
1388 call_sub($form->{"nextsub"});
1390 $lxdebug->leave_sub();
1394 $lxdebug->enter_sub();
1395 call_sub($form->{"lastsub"});
1396 $lxdebug->leave_sub();
1400 $lxdebug->enter_sub();
1401 my $finanzamt = USTVA->query_finanzamt(\%myconfig, \%$form);
1402 $lxdebug->leave_sub();