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}
200 # Which COA is in use?
202 USTVA->get_coa($form, $myconfig);
205 openings => $openings,
206 company_given => $company_given,
207 address_given => $address_given,
208 taxnumber_given => $taxnumber_given,
209 taxnumber => $myconfig->{taxnumber},
210 select_year => $select_year,
211 period_local => $period_local,
212 method_local => $method_local,
213 ustva_vorauswahl => $ustva_vorauswahl,
214 checkbox_kz_10 => $checkbox_kz_10,
215 tax_office_banks => $tax_office_banks_ref,
216 select_options => &show_options,
220 print($form->parse_html_template('ustva/report', $template_ref));
224 $lxdebug->leave_sub();
230 $lxdebug->enter_sub();
232 # parse help documents under doc
233 my $tmp = $form->{templates};
234 $form->{templates} = 'doc';
235 $form->{help} = 'ustva';
236 $form->{type} = 'help';
237 $form->{format} = 'html';
240 #$form->{templates} = $tmp;
241 $lxdebug->leave_sub();
245 $lxdebug->enter_sub();
249 $lxdebug->leave_sub();
250 call_sub($form->{"nextsub"});
254 sub ustva_vorauswahl {
255 $lxdebug->enter_sub();
257 my $select_vorauswahl;
259 #Aktuelles Datum zerlegen:
260 my $date = $form->datetonum($form->current_date(\%myconfig), \%myconfig);
262 #$locale->date($myconfig, $form->current_date($myconfig), 0)=~ /(\d\d).(\d\d).(\d\d\d\d)/;
263 $form->{day} = substr($date, 6, 2);
264 $form->{month} = substr($date, 4, 2);
265 $form->{year} = substr($date, 0, 4);
266 $lxdebug->message(LXDebug::DEBUG1, qq|
267 Actual date from Database: $date\n
268 Actual year from Database: $form->{year}\n
269 Actual day from Database: $form->{day}\n
270 Actual month from Database: $form->{month}\n|);
275 # Testdaten erzeugen:
277 #$form->{month}= '01';
278 #$form->{year}= 2004;
279 $select_vorauswahl = qq|
280 <input type=hidden name=day value=$form->{day}>
281 <input type=hidden name=month value=$form->{month}>
282 <input type=hidden name=yymmdd value=$yymmdd>
283 <input type=hidden name=sel value=$sel>
286 if ($form->{FA_voranmeld} eq 'month') {
288 # Vorauswahl bei monatlichem Voranmeldungszeitraum
290 my %liste = ('01' => $locale->text('January'),
291 '02' => $locale->text('February'),
292 '03' => $locale->text('March'),
293 '04' => $locale->text('April'),
294 '05' => $locale->text('May'),
295 '06' => $locale->text('June'),
296 '07' => $locale->text('July'),
297 '08' => $locale->text('August'),
298 '09' => $locale->text('September'),
299 '10' => $locale->text('October'),
300 '11' => $locale->text('November'),
301 '12' => $locale->text('December'),
302 '13' => $locale->text('Yearly'),
305 my $yy = $form->{year} * 10000;
306 $yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
310 # Offset für Dauerfristverlängerung
311 $dfv = '100' if ($form->{FA_dauerfrist} eq '1');
314 $yymmdd <= ($yy + 110 + $dfv) && do {
315 $form->{year} = $form->{year} - 1;
319 $yymmdd <= ($yy + 210 + $dfv) && do {
323 $yymmdd <= ($yy + 310 + $dfv) && do {
327 $yymmdd <= ($yy + 410 + $dfv) && do {
331 $yymmdd <= ($yy + 510 + $dfv) && do {
335 $yymmdd <= ($yy + 610 + $dfv) && do {
339 $yymmdd <= ($yy + 710 + $dfv) && do {
343 $yymmdd <= ($yy + 810 + $dfv) && do {
347 $yymmdd <= ($yy + 910 + $dfv) && do {
351 $yymmdd <= ($yy + 1010 + $dfv) && do {
355 $yymmdd <= ($yy + 1110 + $dfv) && do {
359 $yymmdd <= ($yy + 1210) && do {
363 $yymmdd <= ($yy + 1231) && do {
369 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
370 . $locale->text('Select a period') . qq|" >|;
373 foreach $key (sort keys %liste) {
375 $selected = 'selected' if ($sel eq $key);
376 $select_vorauswahl .= qq|
377 <option value="$key" $selected> $liste{$key}</option>
380 $select_vorauswahl .= qq|</select>|;
382 } elsif ($form->{FA_voranmeld} eq 'quarter') {
384 # Vorauswahl bei quartalsweisem Voranmeldungszeitraum
385 my %liste = ('41' => $locale->text('1. Quarter'),
386 '42' => $locale->text('2. Quarter'),
387 '43' => $locale->text('3. Quarter'),
388 '44' => $locale->text('4. Quarter'),
389 '13' => $locale->text('Yearly'),);
391 my $yy = $form->{year} * 10000;
392 $yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
394 my $dfv = ''; # Offset für Dauerfristverlängerung
395 $dfv = '100' if ($form->{FA_dauerfrist} eq '1');
398 $yymmdd <= ($yy + 110 + $dfv) && do {
399 $form->{year} = $form->{year} - 1;
403 $yymmdd <= ($yy + 410 + $dfv) && do {
407 $yymmdd <= ($yy + 710 + $dfv) && do {
411 $yymmdd <= ($yy + 1010 + $dfv) && do {
415 $yymmdd <= ($yy + 1231) && do {
420 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
421 . $locale->text('Select a period') . qq|" >|;
423 foreach $key (sort keys %liste) {
425 $selected = 'selected' if ($sel eq $key);
426 $select_vorauswahl .= qq|
427 <option value="$key" $selected>$liste{$key}</option>
430 $select_vorauswahl .= qq|\n</select>
435 # keine Vorauswahl bei Voranmeldungszeitraum
436 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
437 . $locale->text('Select a period') . qq|" >|;
439 my %listea = ('41' => '1. Quarter',
440 '42' => '2. Quarter',
441 '43' => '3. Quarter',
442 '44' => '4. Quarter',);
444 my %listeb = ('01' => 'January',
458 foreach $key (sort keys %listea) {
459 $select_vorauswahl .= qq|
460 <option value="$key">|
461 . $locale->text("$listea{$key}")
465 foreach $key (sort keys %listeb) {
466 $select_vorauswahl .= qq|
467 <option value="$key">|
468 . $locale->text("$listeb{$key}")
471 $select_vorauswahl .= qq|</select>|;
473 $lxdebug->leave_sub();
475 return $select_vorauswahl;
479 # $lxdebug->enter_sub();
481 # $lxdebug->leave_sub();
485 $lxdebug->enter_sub();
487 $lxdebug->leave_sub();
491 $lxdebug->enter_sub();
493 # $form->{PD}{$form->{type}} = "selected";
494 # $form->{DF}{$form->{format}} = "selected";
495 # $form->{OP}{$form->{media}} = "selected";
496 # $form->{SM}{$form->{sendmode}} = "selected";
497 my $type = qq| <input type=hidden name="type" value="ustva">|;
498 my $media = qq| <input type=hidden name="media" value="screen">|;
500 qq| <option value=html selected>|
501 . $locale->text('Preview')
503 if ($latex_templates) {
505 qq| <option value=pdf>|
506 . $locale->text('UStVA (PDF-Dokument)')
510 #my $disabled= qq|disabled="disabled"|;
511 #$disabled='' if ($form->{elster} eq '1' );
512 if ($form->{elster} eq '1') {
514 qq|<option value=elsterwinston>|
515 . $locale->text('ELSTER Export (Winston)')
517 . qq|<option value=elstertaxbird>|
518 . $locale->text('ELSTER Export (Taxbird)')
522 #$format .= qq|<option value=elster>|.$locale->text('ELSTER Export nach Winston').qq|</option>|;
523 my $show_options = qq|
526 <select name=format title = "|
527 . $locale->text('Choose Outputformat') . qq|">$format</select>
529 $lxdebug->leave_sub();
531 return $show_options;
535 $lxdebug->enter_sub();
537 # Aufruf von get_config zum Einlesen der Finanzamtdaten aus finanzamt.ini
539 USTVA->get_config($userspath, 'finanzamt.ini');
541 # init some form vars
542 my @anmeldungszeitraum =
543 qw('0401' '0402' '0403'
547 '0441' '0442' '0443' '0444');
549 foreach my $item (@anmeldungszeitraum) {
553 #forgotten the year --> thisyear
554 if ($form->{year} !~ m/^\d\d\d\d$/) {
555 $form->{year} = substr(
557 $form->current_date(\%myconfig), \%myconfig
560 $lxdebug->message(LXDebug::DEBUG1,
561 qq|Actual year from Database: $form->{year}\n|);
565 # using dates in ISO-8601 format: yyyymmmdd for Postgres...
569 if ($form->{period} eq "13") {
570 $form->{fromdate} = "$form->{year}0101";
571 $form->{todate} = "$form->{year}1231";
575 if ($form->{period} eq "41") {
576 $form->{fromdate} = "$form->{year}0101";
577 $form->{todate} = "$form->{year}0331";
578 $form->{'0441'} = "X";
580 if ($form->{period} eq "42") {
581 $form->{fromdate} = "$form->{year}0401";
582 $form->{todate} = "$form->{year}0630";
583 $form->{'0442'} = "X";
585 if ($form->{period} eq "43") {
586 $form->{fromdate} = "$form->{year}0701";
587 $form->{todate} = "$form->{year}0930";
588 $form->{'0443'} = "X";
590 if ($form->{period} eq "44") {
591 $form->{fromdate} = "$form->{year}1001";
592 $form->{todate} = "$form->{year}1231";
593 $form->{'0444'} = "X";
598 $form->{period} eq "01" && do {
599 $form->{fromdate} = "$form->{year}0101";
600 $form->{todate} = "$form->{year}0131";
601 $form->{'0401'} = "X";
604 $form->{period} eq "02" && do {
605 $form->{fromdate} = "$form->{year}0201";
607 #this works from 1901 to 2099, 1900 and 2100 fail.
608 my $leap = ($form->{year} % 4 == 0) ? "29" : "28";
609 $form->{todate} = "$form->{year}02$leap";
610 $form->{"0402"} = "X";
613 $form->{period} eq "03" && do {
614 $form->{fromdate} = "$form->{year}0301";
615 $form->{todate} = "$form->{year}0331";
616 $form->{"0403"} = "X";
619 $form->{period} eq "04" && do {
620 $form->{fromdate} = "$form->{year}0401";
621 $form->{todate} = "$form->{year}0430";
622 $form->{"0404"} = "X";
625 $form->{period} eq "05" && do {
626 $form->{fromdate} = "$form->{year}0501";
627 $form->{todate} = "$form->{year}0531";
628 $form->{"0405"} = "X";
631 $form->{period} eq "06" && do {
632 $form->{fromdate} = "$form->{year}0601";
633 $form->{todate} = "$form->{year}0630";
634 $form->{"0406"} = "X";
637 $form->{period} eq "07" && do {
638 $form->{fromdate} = "$form->{year}0701";
639 $form->{todate} = "$form->{year}0731";
640 $form->{"0407"} = "X";
643 $form->{period} eq "08" && do {
644 $form->{fromdate} = "$form->{year}0801";
645 $form->{todate} = "$form->{year}0831";
646 $form->{"0408"} = "X";
649 $form->{period} eq "09" && do {
650 $form->{fromdate} = "$form->{year}0901";
651 $form->{todate} = "$form->{year}0930";
652 $form->{"0409"} = "X";
655 $form->{period} eq "10" && do {
656 $form->{fromdate} = "$form->{year}1001";
657 $form->{todate} = "$form->{year}1031";
658 $form->{"0410"} = "X";
661 $form->{period} eq "11" && do {
662 $form->{fromdate} = "$form->{year}1101";
663 $form->{todate} = "$form->{year}1130";
664 $form->{"0411"} = "X";
667 $form->{period} eq "12" && do {
668 $form->{fromdate} = "$form->{year}1201";
669 $form->{todate} = "$form->{year}1231";
670 $form->{"0412"} = "X";
675 # Kontrollvariable für die Templates
676 $form->{'year2007'} = ($form->{year} >= 2007 ) ? "1":"0";
680 USTVA->ustva(\%myconfig, \%$form);
682 # reformat Dates to dateformat
683 $form->{fromdate} = $locale->date(\%myconfig, $form->{fromdate}, 0, 0, 0);
685 $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
686 $form->{todate} = $locale->date(\%myconfig, $form->{todate}, 0, 0, 0);
688 $form->{longperiod} =
689 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1, 0, 0);
691 # if there are any dates construct a where
692 if ($form->{fromdate} || $form->{todate}) {
694 $form->{todate} = $form->current_date($myconfig) unless ($form->{todate});
696 my $longtodate = $locale->date($myconfig, $form->{todate}, 1, 0, 0);
697 my $shorttodate = $locale->date($myconfig, $form->{todate}, 0, 0, 0);
699 my $longfromdate = $locale->date($myconfig, $form->{fromdate}, 1, 0, 0);
700 my $shortfromdate = $locale->date($myconfig, $form->{fromdate}, 0, 0, 0);
702 $form->{this_period} = "$shortfromdate<br>\n$shorttodate";
703 $form->{longperiod} =
704 $locale->text('for Period')
705 . qq|<br>\n$longfromdate |
706 . $locale->text('to (date)')
710 if ($form->{comparefromdate} || $form->{comparetodate}) {
711 my $longcomparefromdate =
712 $locale->date(\%myconfig, $form->{comparefromdate}, 1, 0, 0);
713 my $shortcomparefromdate =
714 $locale->date(\%myconfig, $form->{comparefromdate}, 0, 0, 0);
716 my $longcomparetodate =
717 $locale->date(\%myconfig, $form->{comparetodate}, 1, 0, 0);
718 my $shortcomparetodate =
719 $locale->date(\%myconfig, $form->{comparetodate}, 0, 0, 0);
721 $form->{last_period} = "$shortcomparefromdate<br>\n$shortcomparetodate";
722 $form->{longperiod} .=
723 "<br>\n$longcomparefromdate "
724 . $locale->text('to (date)')
725 . qq| $longcomparetodate|;
728 $form->{Datum_heute} =
729 $locale->date(\%myconfig, $form->current_date(\%myconfig), 0, 0, 0);
731 # setup variables for the form
732 my @a = qw(company businessnumber tel fax email
733 co_chief co_department co_custom1 co_custom2 co_custom3 co_custom4 co_custom5
734 co_name1 co_name2 co_street co_street1 co_zip co_city co_city1 co_country co_tel co_tel1 co_tel2
735 co_fax co_fax1 co_email co_email1 co_url co_url1 ustid duns
736 co_bankname co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1
737 co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2 co_accountnr3);
739 map { $form->{$_} = $myconfig{$_} } @a;
741 if ($form->{address} ne '') {
742 my $temp = $form->{address};
743 $temp =~ s/\\n/<br \/>/;
744 ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp);
745 $form->{co_city} =~ s/\\n//g;
748 ################################
750 # Nation specific customisations
752 ################################
756 if ( $form->{coa} eq 'Germany-DATEV-SKR03EU' or $form->{coa} eq 'Germany-DATEV-SKR04EU') {
759 # Outputformat specific customisation's
762 my @category_cent = USTVA->report_variables({
763 myconfig => \%myconfig,
766 attribute => 'position',
770 push @category_cent, qw(83 Z43 Z45 Z53 Z62 Z65 Z67);
772 my @category_euro = USTVA->report_variables({
773 myconfig => \%myconfig,
776 attribute => 'position',
781 $form->{amount} = [];
783 if ( $form->{format} eq 'pdf' or $form->{format} eq 'postscript') {
785 $form->{IN} = "$form->{type}-$form->{year}.tex";
786 $form->{padding} = "~~";
787 $form->{bold} = "\textbf{";
788 $form->{endbold} = "}";
789 $form->{br} = '\\\\';
791 # Zahlenformatierung für Latex USTVA Formulare
793 foreach my $number (@category_euro) {
794 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '');
797 my ${decimal_comma} = ( $myconfig{numberformat} eq '1.000,00'
798 or $myconfig{numberformat} eq '1000,00' ) ? ',':'.';
800 foreach my $number (@category_cent) {
801 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '');
802 $form->{$number} =~ s/${decimal_comma}/~~/g;
805 } elsif ( $form->{format} eq 'html') { # Formatierungen für HTML Ausgabe
807 $form->{IN} = $form->{type} . '.html';
808 $form->{padding} = " ";
809 $form->{bold} = "<b>";
810 $form->{endbold} = "</b>";
811 $form->{br} = "<br>";
812 $form->{address} =~ s/\\n/\n/g;
814 foreach $number (@category_cent) {
815 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '0');
818 foreach $number (@category_euro) {
819 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '0');
822 } elsif ( $form->{format} eq 'elsterwinston' ) {
824 $form->{IN} = 'winston.xml';
827 # Build Winston filename
830 my $file = 'U'; # 1. char 'U' = USTVA
831 $file .= $form->{period};
832 #4. and 5. char = year modulo 100
833 $file .= sprintf("%02d", $form->{year} % 100);
834 #6. to 18. char = Elstersteuernummer
835 #Beispiel: Steuernummer in Bayern
836 #111/222/33334 ergibt für UStVA Jan 2004: U01049111022233334
837 $file .= $form->{elsterFFFF};
838 $file .= $form->{elstersteuernummer};
842 $form->{tmpfile} = "$userspath/$file";
844 $form->{attachment_filename} = $file;
846 # Zahlenformatierung für Winston
848 my $temp_numberformat = $myconfig{numberformat};
850 # Numberformat must be '1000.00' for Winston
852 $myconfig{numberformat} = '1000.00';
854 foreach my $number (@category_cent) {
855 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '2', '') : '';
858 foreach my $number (@category_euro) {
859 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '0', '') : '';
861 # Re-set Numberformat
862 $myconfig{numberformat} = $temp_numberformat;
864 # push Kennziffern to <%foreach Array fo easyer
865 # output in xml format. Thx to Moritz.
866 my %winston_id_for = (
870 foreach my $kennziffer (@category_cent, @category_euro) {
872 next if ( $kennziffer =~ m/Z\d\d/);
873 next if ( $form->{$kennziffer} == 0 );
875 if (defined $winston_id_for{$kennziffer} ) {
876 push(@{ $form->{id}}, $winston_id_for{$kennziffer});
878 push(@{ $form->{id}}, "Kz$kennziffer");
880 push(@{ $form->{amount}}, $form->{$kennziffer});
883 } elsif ( $form->{format} eq 'elstertaxbird' ) {
885 # Define serveral filenames
886 $form->{IN} = 'taxbird.txb';
888 $form->{attachment_filename} = "USTVA-" . $form->{period}
889 . sprintf("%02d", $form->{year} % 100) . ".txb";
891 $form->{attachment_filename} =~ s|.*/||;
892 $form->{tmpfile} = "$userspath/" . $form->{attachment_filename};
894 # TODO: set Output to UTF-8 or system Preference
895 #$form->{"iconv"} = Text::Iconv->new($myconfig{dbcharset}, "UTF-8");
896 #my $iconv = $self->{"iconv"};
897 #$iconv->convert($variable);
898 if ($form->{period} =~ /^[4]\d$/ ){
899 my %periods = ( # Lx => taxbird
906 foreach my $quarter ( keys %periods ) {
907 $form->{taxbird_period} = $periods{$quarter} if ( $form->{period} eq $quarter);
909 } elsif ($form->{period} =~ /^\d+$/ ) {
910 $form->{period} =~ s/^0//g;
911 my $period = $form->{period};
914 $form->{period} = $period;
917 USTVA::error( $locale->text('Wrong Period' ));
921 my %lands = ( # Lx => taxbird # TODO: besser als array...
922 'Baden Würtemberg' => '0',
925 'Brandenburg' => '3',
929 'Mecklenburg Vorpommern' => '7',
930 'Niedersachsen' => '8',
931 'Nordrhein Westfalen' => '9',
932 'Rheinland Pfalz' => '10',
935 'Sachsen Anhalt' => '13',
936 'Schleswig Holstein' => '14',
939 foreach my $land ( keys %lands ){
940 $form->{taxbird_land_nr} = $lands{$land} if ($form->{elsterland} eq $land );
943 $form->{co_zip} = $form->{co_city};
944 $form->{co_zip} =~ s/\D//g;
945 $form->{co_city} =~ s/\d//g;
946 $form->{co_city} =~ s/^\s//g;
948 ($form->{co_phone_prefix}, $form->{co_phone}) = split("-", $form->{tel});
949 $form->{co_phone_prefix} =~ s/\s//g;
950 $form->{co_phone} =~ s/\s//g;
952 $form->{taxbird_steuernummer} = $form->{steuernummer};
953 # $form->{taxbird_steuernummer} =~ s/\D//g;
954 $form->{taxbird_steuernummer} =~ s/\///; # ersten Querstrich ersetzen
956 # Numberformatting for Taxbird
957 my $temp_numberformat = $myconfig{numberformat};
958 # Numberformat must be '1000,00' for Taxbird ?!
959 $myconfig{numberformat} = '1000,00';
960 foreach my $number (@category_cent) {
961 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '2', '') : '';
964 foreach my $number (@category_euro) {
965 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '0', '') : '';
967 # Re-set Numberformat
968 $myconfig{numberformat} = $temp_numberformat;
970 # push Kennziffern to <%foreach Array fo easyer
971 # output in xml format. Thx to Moritz.
972 my %taxbird_id_for = (
974 '511' => 'Kz51-calc',
975 '861' => 'Kz86-calc',
976 '971' => 'Kz97-calc',
977 '931' => 'Kz93-calc',
978 '811' => 'Kz81-calc',
979 '891' => 'Kz89-calc',
980 'Z45' => 'uebertrag',
982 'Z62' => 'ust-minus-vost',
983 'Z65' => 'ust-sum+69',
988 for my $kennziffer (@category_cent, @category_euro) {
990 next if ($kennziffer eq 'Z43');
992 if ($form->{$kennziffer} != 0){
993 if (defined $taxbird_id_for{$kennziffer}) {
994 push(@{ $form->{id}}, $taxbird_id_for{$kennziffer});
996 push(@{ $form->{id}}, "Kz$kennziffer");
998 push(@{ $form->{amount}}, $form->{$kennziffer});
1002 } elsif ( $form->{format} eq '' ){ # No format error.
1004 USTVA::error( $locale->text('Application Error. No Format given' ) . "!");
1007 } else { # All other Formats are wrong
1009 USTVA::error( $locale->text('Application Error. Wrong Format') . ": " . $form->{format} );
1014 } else # Outputformat for generic output
1017 my @category_cent = USTVA->report_variables({
1018 myconfig => \%myconfig,
1021 attribute => 'position',
1025 my @category_euro = USTVA->report_variables({
1026 myconfig => \%myconfig,
1029 attribute => 'position',
1033 $form->{"Watchdog::USTVA"} = 1;
1034 $form->{USTVA} = [];
1036 if ( $form->{format} eq 'generic') { # Formatierungen für HTML Ausgabe
1039 for my $kennziffer (@category_cent, @category_euro) {
1041 $rec_ref->{id} = $kennziffer;
1042 $rec_ref->{amount} = $form->format_amount(\%myconfig, $form->{$kennziffer}, 2, '0');
1044 $lxdebug->message($LXDebug::DEBUG, "Kennziffer $kennziffer: '$form->{$kennziffer}'" );
1045 $lxdebug->dump($LXDebug::DEBUG, $rec_ref );
1046 push @ { $form->{USTVA} }, $rec_ref;
1053 if ( $form->{period} eq '13' and $form->{format} ne 'html') {
1057 'Yearly taxreport not yet implemented')
1061 $form->{templates} = $myconfig{templates};
1062 $form->{templates} = "doc" if ( $form->{type} eq 'help' );
1064 if ($form->{format} eq 'generic'){
1069 taxnumber => $myconfig{taxnumber},
1072 print($form->parse_html_template2('ustva/generic_taxreport', $template_ref));
1077 $form->parse_template(\%myconfig, $userspath);
1081 $lxdebug->leave_sub();
1085 $lxdebug->enter_sub();
1087 # edit all taxauthority prefs
1090 USTVA->get_config($userspath, 'finanzamt.ini');
1092 my $land = $form->{elsterland};
1093 my $amt = $form->{elsterFFFF};
1096 if ($form->{cbscript} ne '' and $form->{cblogin} ne '') {
1097 $callback = qq|$form->{cbscript}|
1098 .qq|?action="config_step1"|
1099 .qq|&login="$form->{cblogin}"|
1100 .qq|&root="$form->{cbroot}"|
1101 .qq|&rpw="$form->{cbrpw}"|;
1104 $form->{title} = $locale->text('Tax Office Preferences');
1107 my $select_tax_office = USTVA->fa_auswahl($land, $amt, &elster_hash());
1108 my $checked_accrual = q|checked="checked"| if ($form->{method} eq 'accrual');
1109 my $checked_cash = q|checked="checked"| if ($form->{method} eq 'cash');
1110 my $checked_monthly = "checked" if ($form->{FA_voranmeld} eq 'month');
1111 my $checked_quarterly = "checked" if ($form->{FA_voranmeld} eq 'quarter');
1112 my $checked_dauerfristverlaengerung = "checked" if ($form->{FA_dauerfrist} eq '1');
1113 my $checked_kz_71 = "checked" if ($form->{FA_71} eq 'X');
1115 my $_hidden_variables_ref;
1117 my %_hidden_local_variables = (
1118 'saved' => $locale->text('Check Details'),
1119 'nextsub' => 'config_step2',
1123 foreach my $variable (keys %_hidden_local_variables) {
1124 push @{ $_hidden_variables_ref },
1125 { 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
1128 my @_hidden_form_variables = qw(
1129 FA_Name FA_Strasse FA_PLZ
1130 FA_Ort FA_Telefon FA_Fax
1131 FA_PLZ_Grosskunden FA_PLZ_Postfach FA_Postfach
1132 FA_BLZ_1 FA_Kontonummer_1 FA_Bankbezeichnung_1
1133 FA_BLZ_2 FA_Kontonummer_2 FA_Bankbezeichnung_oertlich
1134 FA_Oeffnungszeiten FA_Email FA_Internet
1135 steuernummer elsterland elstersteuernummer
1136 elsterFFFF login password
1139 foreach my $variable (@_hidden_form_variables) {
1140 push @{ $_hidden_variables_ref},
1141 { 'variable' => $variable, 'value' => $form->{$variable} };
1144 # Which COA is in use?
1146 USTVA->get_coa($form, \%myconfig);
1149 my $steuernummer_new = '';
1151 # Variablen für das Template zur Verfügung stellen
1152 my $template_ref = {
1153 select_tax_office => $select_tax_office,
1154 checked_accrual => $checked_accrual,
1155 checked_cash => $checked_cash,
1156 checked_monthly => $checked_monthly,
1157 checked_quarterly => $checked_quarterly,
1158 checked_dauerfristverlaengerung => $checked_dauerfristverlaengerung,
1159 hidden_variables => $_hidden_variables_ref,
1163 # Ausgabe des Templates
1164 print($form->parse_html_template('ustva/config_step1', $template_ref));
1166 $lxdebug->leave_sub();
1170 $lxdebug->enter_sub();
1177 my $elsterland = '';
1178 my $elster_amt = '';
1179 my $elsterFFFF = '';
1180 my $elstersteuernummer = '';
1181 USTVA->get_config($userspath, 'finanzamt.ini')
1182 if ($form->{saved} eq $locale->text('saved'));
1184 # Auf Übergabefehler checken
1185 USTVA::info( $locale->text('Missing Tax Authoritys Preferences') . "\n"
1186 . $locale->text('USTVA-Hint: Tax Authoritys'))
1187 if ( $form->{elsterFFFF_new} eq 'Auswahl'
1188 || $form->{elsterland_new} eq 'Auswahl');
1189 USTVA::info( $locale->text('Missing Method!') . "\n"
1190 . $locale->text('USTVA-Hint: Method'))
1191 if ($form->{method} eq '');
1193 # Klären, ob Variablen bereits befüllt sind UND ob veräderungen auf
1194 # der vorherigen Maske stattfanden: $change = 1(in der edit sub,
1195 # mittels get_config)
1197 my $change = $form->{elsterland} eq $form->{elsterland_new}
1198 && $form->{elsterFFFF} eq $form->{elsterFFFF_new} ? '0' : '1';
1199 $change = '0' if ($form->{saved} eq $locale->text('saved'));
1200 my $elster_init = &elster_hash();
1202 my %elster_init = %$elster_init;
1204 if ($change eq '1') {
1207 $elsterland = $form->{elsterland_new};
1208 $elsterFFFF = $form->{elsterFFFF_new};
1209 $form->{elsterland} = $elsterland;
1210 $form->{elsterFFFF} = $elsterFFFF;
1211 $form->{steuernummer} = '';
1213 create_steuernummer();
1215 # rebuild elster_amt
1217 foreach $amt (keys %{ $elster_init{ $form->{elsterland} } }) {
1219 if ($elster_init{ $form->{elsterland}{$amt} eq $form->{elsterFFFF} });
1222 # load the predefined hash data into the FA_* Vars
1223 my @variables = qw(FA_Name FA_Strasse FA_PLZ FA_Ort
1224 FA_Telefon FA_Fax FA_PLZ_Grosskunden FA_PLZ_Postfach
1226 FA_BLZ_1 FA_Kontonummer_1 FA_Bankbezeichnung_1
1227 FA_BLZ_2 FA_Kontonummer_2 FA_Bankbezeichnung_oertlich
1228 FA_Oeffnungszeiten FA_Email FA_Internet);
1230 for (my $i = 0; $i <= 20; $i++) {
1231 $form->{ $variables[$i] } =
1232 $elster_init->{$elsterland}->{$elsterFFFF}->[$i];
1237 $elsterland = $form->{elsterland};
1238 $elsterFFFF = $form->{elsterFFFF};
1241 my $stnr = $form->{steuernummer};
1243 my $patterncount = $form->{patterncount};
1244 my $elster_pattern = $form->{elster_pattern};
1245 my $delimiter = $form->{delimiter};
1246 my $steuernummer = $form->{steuernummer} if ($steuernummer eq '');
1248 $form->{FA_Oeffnungszeiten} =~ s/\\\\n/\n/g;
1252 my $input_steuernummer = USTVA->steuernummer_input(
1253 $form->{elsterland},
1254 $form->{elsterFFFF},
1255 $form->{steuernummer}
1258 $lxdebug->message(LXDebug::DEBUG1, qq|$input_steuernummer|);
1261 my $_hidden_variables_ref;
1263 my %_hidden_local_variables = (
1264 'elsterland' => $elsterland,
1265 'elsterFFFF' => $elsterFFFF,
1266 'warnung' => $warnung,
1267 'elstersteuernummer' => $elstersteuernummer,
1268 'steuernummer' => $stnr,
1269 'lastsub' => 'config_step1',
1270 'nextsub' => 'save',
1274 foreach my $variable (keys %_hidden_local_variables) {
1275 push @{ $_hidden_variables_ref },
1276 { 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
1279 my @_hidden_form_variables = qw(
1280 FA_steuerberater_name FA_steuerberater_street
1281 FA_steuerberater_city FA_steuerberater_tel
1290 foreach my $variable (@_hidden_form_variables) {
1291 push @{ $_hidden_variables_ref},
1292 { 'variable' => $variable, 'value' => $form->{$variable} };
1295 my $template_ref = {
1296 tax_office_data => $tax_office_data,
1297 input_steuernummer => $input_steuernummer,
1298 readonly => '', #q|disabled="disabled"|,
1299 callback => $callback,
1300 hidden_variables => $_hidden_variables_ref,
1303 # Ausgabe des Templates
1304 print($form->parse_html_template('ustva/config_step2', $template_ref));
1307 $lxdebug->leave_sub();
1310 sub create_steuernummer {
1311 $lxdebug->enter_sub();
1312 my $part = $form->{part};
1313 my $patterncount = $form->{patterncount};
1314 my $delimiter = $form->{delimiter};
1315 my $elster_pattern = $form->{elster_pattern};
1317 # rebuild steuernummer and elstersteuernummer
1318 # es gibt eine gespeicherte steuernummer $form->{steuernummer}
1319 # und die parts und delimiter
1324 my $steuernummer_new = $part;
1325 my $elstersteuernummer_new = $form->{elster_FFFF};
1326 $elstersteuernummer_new .= '0';
1328 for ($h = 1; $h < $patterncount; $h++) {
1329 $steuernummer_new .= qq|$delimiter|;
1330 for (my $i = 1; $i <= length($elster_pattern); $i++) {
1331 $steuernummer_new .= $form->{"part_$h\_$i"};
1332 $elstersteuernummer_new .= $form->{"part_$h\_$i"};
1335 if ($form->{steuernummer} ne $steuernummer_new) {
1336 $form->{steuernummer} = $steuernummer_new;
1337 $form->{elstersteuernummer} = $elstersteuernummer_new;
1338 $form->{steuernummer_new} = $steuernummer_new;
1340 $form->{steuernummer_new} = '';
1341 $form->{elstersteuernummer_new} = '';
1343 $lxdebug->leave_sub();
1347 $lxdebug->enter_sub();
1349 my $filename = "$form->{login}_$form->{filename}";
1350 $filename =~ s|.*/||;
1352 #zuerst die steuernummer aus den part, parts_X_Y und delimiter herstellen
1353 create_steuernummer();
1355 # Textboxen formatieren: Linebreaks entfernen
1357 $form->{FA_Oeffnungszeiten} =~ s/\r\n/\\n/g;
1359 #URL mit http:// davor?
1360 $form->{FA_Internet} =~ s/^http:\/\///;
1361 $form->{FA_Internet} = 'http://' . $form->{FA_Internet};
1364 elster elsterland elstersteuernummer steuernummer
1365 elsteramt elsterFFFF FA_Name FA_Strasse
1366 FA_PLZ FA_Ort FA_Telefon FA_Fax
1367 FA_PLZ_Grosskunden FA_PLZ_Postfach FA_Postfach FA_BLZ_1
1368 FA_Kontonummer_1 FA_Bankbezeichnung_1 FA_BLZ_2 FA_Kontonummer_2
1369 FA_Bankbezeichnung_oertlich FA_Oeffnungszeiten
1370 FA_Email FA_Internet FA_voranmeld method FA_steuerberater_name
1371 FA_steuerberater_street FA_steuerberater_city FA_steuerberater_tel
1372 FA_71 FA_dauerfrist);
1374 # Hier kommt dann die Plausibilitätsprüfung der ELSTERSteuernummer
1375 if ($form->{elstersteuernummer} ne '000000000') {
1377 $form->{elster} = '1';
1379 open my $ustvaconfig, ">", "$userspath/$filename" or $form->error("$filename : $!");
1381 # create the config file
1382 print {$ustvaconfig} qq|# Configuration file for USTVA\n\n|;
1384 foreach $key (sort @config) {
1385 $form->{$key} =~ s/\\/\\\\/g;
1387 $form->{$key} =~ s/\r\n/\n/g;
1389 print {$ustvaconfig} qq|$key=|;
1390 if ($form->{$key} ne 'Y') {
1391 print {$ustvaconfig} qq|$form->{$key}\n|;
1393 if ($form->{$key} eq 'Y') {
1394 print {$ustvaconfig} qq|checked \n|;
1397 print {$ustvaconfig} qq|\n\n|;
1399 $form->{saved} = $locale->text('saved');
1403 $form->{saved} = $locale->text('Choose a Tax Number');
1407 $lxdebug->leave_sub();
1412 $lxdebug->enter_sub();
1414 # allow Symbolic references just here:
1416 call_sub($form->{"nextsub"});
1418 $lxdebug->leave_sub();
1422 $lxdebug->enter_sub();
1423 call_sub($form->{"lastsub"});
1424 $lxdebug->leave_sub();
1428 $lxdebug->enter_sub();
1429 my $finanzamt = USTVA->query_finanzamt(\%myconfig, \%$form);
1430 $lxdebug->leave_sub();