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/common.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 #############################
74 $lxdebug->enter_sub();
76 $auth->assert('advance_turnover_tax_return');
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 USTVA->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?action=config|
116 . qq|&level=Programm--Preferences">|
117 . $locale->text('No Company Name given') . qq|!</a><br>|;
120 # Anpassungen der Variablennamen auf pre 2.1.1 Namen
121 # klären, ob $form->{company_street|_address} gesetzt sind
122 if ($form->{address} ne '') {
123 my $temp = $form->{address};
124 $temp =~ s/\\n/<br \/>/;
125 ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp);
126 $form->{co_city} =~ s/\\n//g;
131 ($form->{co_street} ne ''
133 $form->{co_zip} ne ''
134 or $form->{co_city} ne ''
137 ? qq|$form->{co_street}<br>|
138 . qq|$form->{co_street1}<br>|
139 . qq|$form->{co_zip} $form->{co_city}|
140 : qq|<a href="am.pl?action=config|
141 . qq|&level=Programm--Preferences">|
142 . $locale->text('No Company Address given')
145 $form->{co_email} = $form->{email} unless $form->{co_email};
146 $form->{co_tel} = $form->{tel} unless $form->{co_tel};
147 $form->{co_fax} = $form->{fax} unless $form->{co_fax};
148 $form->{co_url} = $form->{urlx} unless $form->{co_url};
150 my $taxnumber_given = ($form->{steuernummer} ne '')
151 ? qq|$form->{steuernummer}|
152 : qq|<a href="ustva.pl?action="config_step1"|
153 . qq|&level=Programm--Finanzamteinstellungen">Keine Steuernummer hinterlegt!|
156 my $ustva_vorauswahl = &ustva_vorauswahl();
158 my @all_years = $form->all_years(\%myconfig);
160 my $select_year = qq|<select name=year title="|
161 . $locale->text('Year') . qq|">|;
162 foreach my $key (@all_years) {
163 $select_year .= qq|<option |;
164 $select_year .= qq|selected| if ($key eq $form->{year});
165 $select_year .= qq| >$key</option>|;
167 $select_year .= qq|</select>|;
170 $_checked = "checked" if ($form->{kz10} eq '1');
171 my $checkbox_kz_10 = qq|<input name="FA_10" id=FA_10 class=checkbox|
172 . qq| type=checkbox value="1" $_checked title = "|
173 . $locale->text('Amended Advance Turnover Tax Return (Nr. 10)')
175 . $locale->text('Amended Advance Turnover Tax Return');
177 my $method_local = ($form->{method} eq 'accrual') ? $locale->text('accrual')
178 : ($form->{method} eq 'cash') ? $locale->text('cash')
181 my $period_local = ( $form->{FA_voranmeld} eq 'month') ? $locale->text('month')
182 : ( $form->{FA_voranmeld} eq 'quarter') ? $locale->text('quarter')
185 my $tax_office_banks_ref = [
186 { BLZ => $form->{FA_BLZ_1},
187 Kontonummer => $form->{FA_Kontonummer_1},
188 Bankbezeichnung => $form->{FA_Bankbezeichnung_1}
190 { BLZ => $form->{FA_BLZ_2},
191 Kontonummer => $form->{FA_Kontonummer_2},
192 Bankbezeichnung => $form->{FA_Bankbezeichnung_oertlich}
196 # Which COA is in use?
198 USTVA->get_coa($form, $myconfig);
201 openings => $openings,
202 company_given => $company_given,
203 address_given => $address_given,
204 taxnumber_given => $taxnumber_given,
205 taxnumber => $myconfig->{taxnumber},
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,
216 print($form->parse_html_template('ustva/report', $template_ref));
220 $lxdebug->leave_sub();
226 $lxdebug->enter_sub();
228 $auth->assert('advance_turnover_tax_return');
230 # parse help documents under doc
231 my $tmp = $form->{templates};
232 $form->{templates} = 'doc';
233 $form->{help} = 'ustva';
234 $form->{type} = 'help';
235 $form->{format} = 'html';
238 #$form->{templates} = $tmp;
239 $lxdebug->leave_sub();
243 $lxdebug->enter_sub();
245 $auth->assert('advance_turnover_tax_return');
249 $lxdebug->leave_sub();
250 call_sub($form->{"nextsub"});
254 sub ustva_vorauswahl {
255 $lxdebug->enter_sub();
257 $auth->assert('advance_turnover_tax_return');
259 my $select_vorauswahl;
261 #Aktuelles Datum zerlegen:
262 my $date = $form->datetonum($form->current_date(\%myconfig), \%myconfig);
264 #$locale->date($myconfig, $form->current_date($myconfig), 0)=~ /(\d\d).(\d\d).(\d\d\d\d)/;
265 $form->{day} = substr($date, 6, 2);
266 $form->{month} = substr($date, 4, 2);
267 $form->{year} = substr($date, 0, 4);
268 $lxdebug->message(LXDebug::DEBUG1, qq|
269 Actual date from Database: $date\n
270 Actual year from Database: $form->{year}\n
271 Actual day from Database: $form->{day}\n
272 Actual month from Database: $form->{month}\n|);
277 # Testdaten erzeugen:
279 #$form->{month}= '01';
280 #$form->{year}= 2004;
281 $select_vorauswahl = qq|
282 <input type=hidden name=day value=$form->{day}>
283 <input type=hidden name=month value=$form->{month}>
284 <input type=hidden name=yymmdd value=$yymmdd>
285 <input type=hidden name=sel value=$sel>
288 if ($form->{FA_voranmeld} eq 'month') {
290 # Vorauswahl bei monatlichem Voranmeldungszeitraum
292 my %liste = ('01' => $locale->text('January'),
293 '02' => $locale->text('February'),
294 '03' => $locale->text('March'),
295 '04' => $locale->text('April'),
296 '05' => $locale->text('May'),
297 '06' => $locale->text('June'),
298 '07' => $locale->text('July'),
299 '08' => $locale->text('August'),
300 '09' => $locale->text('September'),
301 '10' => $locale->text('October'),
302 '11' => $locale->text('November'),
303 '12' => $locale->text('December'),
304 '13' => $locale->text('Yearly'),
307 my $yy = $form->{year} * 10000;
308 $yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
312 # Offset für Dauerfristverlängerung
313 $dfv = '100' if ($form->{FA_dauerfrist} eq '1');
316 $yymmdd <= ($yy + 110 + $dfv) && do {
317 $form->{year} = $form->{year} - 1;
321 $yymmdd <= ($yy + 210 + $dfv) && do {
325 $yymmdd <= ($yy + 310 + $dfv) && do {
329 $yymmdd <= ($yy + 410 + $dfv) && do {
333 $yymmdd <= ($yy + 510 + $dfv) && do {
337 $yymmdd <= ($yy + 610 + $dfv) && do {
341 $yymmdd <= ($yy + 710 + $dfv) && do {
345 $yymmdd <= ($yy + 810 + $dfv) && do {
349 $yymmdd <= ($yy + 910 + $dfv) && do {
353 $yymmdd <= ($yy + 1010 + $dfv) && do {
357 $yymmdd <= ($yy + 1110 + $dfv) && do {
361 $yymmdd <= ($yy + 1210) && do {
365 $yymmdd <= ($yy + 1231) && do {
371 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
372 . $locale->text('Select a period') . qq|" >|;
375 foreach $key (sort keys %liste) {
377 $selected = 'selected' if ($sel eq $key);
378 $select_vorauswahl .= qq|
379 <option value="$key" $selected> $liste{$key}</option>
382 $select_vorauswahl .= qq|</select>|;
384 } elsif ($form->{FA_voranmeld} eq 'quarter') {
386 # Vorauswahl bei quartalsweisem Voranmeldungszeitraum
387 my %liste = ('41' => $locale->text('1. Quarter'),
388 '42' => $locale->text('2. Quarter'),
389 '43' => $locale->text('3. Quarter'),
390 '44' => $locale->text('4. Quarter'),
391 '13' => $locale->text('Yearly'),);
393 my $yy = $form->{year} * 10000;
394 $yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
396 my $dfv = ''; # Offset für Dauerfristverlängerung
397 $dfv = '100' if ($form->{FA_dauerfrist} eq '1');
400 $yymmdd <= ($yy + 110 + $dfv) && do {
401 $form->{year} = $form->{year} - 1;
405 $yymmdd <= ($yy + 410 + $dfv) && do {
409 $yymmdd <= ($yy + 710 + $dfv) && do {
413 $yymmdd <= ($yy + 1010 + $dfv) && do {
417 $yymmdd <= ($yy + 1231) && do {
422 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
423 . $locale->text('Select a period') . qq|" >|;
425 foreach $key (sort keys %liste) {
427 $selected = 'selected' if ($sel eq $key);
428 $select_vorauswahl .= qq|
429 <option value="$key" $selected>$liste{$key}</option>
432 $select_vorauswahl .= qq|\n</select>
437 # keine Vorauswahl bei Voranmeldungszeitraum
438 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
439 . $locale->text('Select a period') . qq|" >|;
441 my %listea = ('41' => '1. Quarter',
442 '42' => '2. Quarter',
443 '43' => '3. Quarter',
444 '44' => '4. Quarter',);
446 my %listeb = ('01' => 'January',
460 foreach $key (sort keys %listea) {
461 $select_vorauswahl .= qq|
462 <option value="$key">|
463 . $locale->text("$listea{$key}")
467 foreach $key (sort keys %listeb) {
468 $select_vorauswahl .= qq|
469 <option value="$key">|
470 . $locale->text("$listeb{$key}")
473 $select_vorauswahl .= qq|</select>|;
475 $lxdebug->leave_sub();
477 return $select_vorauswahl;
481 # $lxdebug->enter_sub();
483 # $lxdebug->leave_sub();
487 $lxdebug->enter_sub();
489 $lxdebug->leave_sub();
493 $lxdebug->enter_sub();
495 $auth->assert('advance_turnover_tax_return');
497 # $form->{PD}{$form->{type}} = "selected";
498 # $form->{DF}{$form->{format}} = "selected";
499 # $form->{OP}{$form->{media}} = "selected";
500 # $form->{SM}{$form->{sendmode}} = "selected";
501 my $type = qq| <input type=hidden name="type" value="ustva">|;
502 my $media = qq| <input type=hidden name="media" value="screen">|;
504 qq| <option value=html selected>|
505 . $locale->text('Preview')
507 if ($latex_templates) {
509 qq| <option value=pdf>|
510 . $locale->text('UStVA (PDF-Dokument)')
514 #my $disabled= qq|disabled="disabled"|;
515 #$disabled='' if ($form->{elster} eq '1' );
516 if ($form->{elster} eq '1') {
518 qq|<option value=elsterwinston>|
519 . $locale->text('ELSTER Export (Winston)')
521 . qq|<option value=elstertaxbird>|
522 . $locale->text('ELSTER Export (Taxbird)')
526 #$format .= qq|<option value=elster>|.$locale->text('ELSTER Export nach Winston').qq|</option>|;
527 my $show_options = qq|
530 <select name=format title = "|
531 . $locale->text('Choose Outputformat') . qq|">$format</select>
533 $lxdebug->leave_sub();
535 return $show_options;
539 $lxdebug->enter_sub();
541 $auth->assert('advance_turnover_tax_return');
543 # Aufruf von get_config zum Einlesen der Finanzamtdaten aus finanzamt.ini
545 USTVA->get_config($userspath, 'finanzamt.ini');
547 # init some form vars
548 my @anmeldungszeitraum =
549 qw('0401' '0402' '0403'
553 '0441' '0442' '0443' '0444');
555 foreach my $item (@anmeldungszeitraum) {
559 #forgotten the year --> thisyear
560 if ($form->{year} !~ m/^\d\d\d\d$/) {
561 $form->{year} = substr(
563 $form->current_date(\%myconfig), \%myconfig
566 $lxdebug->message(LXDebug::DEBUG1,
567 qq|Actual year from Database: $form->{year}\n|);
571 # using dates in ISO-8601 format: yyyymmmdd for Postgres...
575 if ($form->{period} eq "13") {
576 $form->{fromdate} = "$form->{year}0101";
577 $form->{todate} = "$form->{year}1231";
581 if ($form->{period} eq "41") {
582 $form->{fromdate} = "$form->{year}0101";
583 $form->{todate} = "$form->{year}0331";
584 $form->{'0441'} = "X";
586 if ($form->{period} eq "42") {
587 $form->{fromdate} = "$form->{year}0401";
588 $form->{todate} = "$form->{year}0630";
589 $form->{'0442'} = "X";
591 if ($form->{period} eq "43") {
592 $form->{fromdate} = "$form->{year}0701";
593 $form->{todate} = "$form->{year}0930";
594 $form->{'0443'} = "X";
596 if ($form->{period} eq "44") {
597 $form->{fromdate} = "$form->{year}1001";
598 $form->{todate} = "$form->{year}1231";
599 $form->{'0444'} = "X";
604 $form->{period} eq "01" && do {
605 $form->{fromdate} = "$form->{year}0101";
606 $form->{todate} = "$form->{year}0131";
607 $form->{'0401'} = "X";
610 $form->{period} eq "02" && do {
611 $form->{fromdate} = "$form->{year}0201";
613 #this works from 1901 to 2099, 1900 and 2100 fail.
614 my $leap = ($form->{year} % 4 == 0) ? "29" : "28";
615 $form->{todate} = "$form->{year}02$leap";
616 $form->{"0402"} = "X";
619 $form->{period} eq "03" && do {
620 $form->{fromdate} = "$form->{year}0301";
621 $form->{todate} = "$form->{year}0331";
622 $form->{"0403"} = "X";
625 $form->{period} eq "04" && do {
626 $form->{fromdate} = "$form->{year}0401";
627 $form->{todate} = "$form->{year}0430";
628 $form->{"0404"} = "X";
631 $form->{period} eq "05" && do {
632 $form->{fromdate} = "$form->{year}0501";
633 $form->{todate} = "$form->{year}0531";
634 $form->{"0405"} = "X";
637 $form->{period} eq "06" && do {
638 $form->{fromdate} = "$form->{year}0601";
639 $form->{todate} = "$form->{year}0630";
640 $form->{"0406"} = "X";
643 $form->{period} eq "07" && do {
644 $form->{fromdate} = "$form->{year}0701";
645 $form->{todate} = "$form->{year}0731";
646 $form->{"0407"} = "X";
649 $form->{period} eq "08" && do {
650 $form->{fromdate} = "$form->{year}0801";
651 $form->{todate} = "$form->{year}0831";
652 $form->{"0408"} = "X";
655 $form->{period} eq "09" && do {
656 $form->{fromdate} = "$form->{year}0901";
657 $form->{todate} = "$form->{year}0930";
658 $form->{"0409"} = "X";
661 $form->{period} eq "10" && do {
662 $form->{fromdate} = "$form->{year}1001";
663 $form->{todate} = "$form->{year}1031";
664 $form->{"0410"} = "X";
667 $form->{period} eq "11" && do {
668 $form->{fromdate} = "$form->{year}1101";
669 $form->{todate} = "$form->{year}1130";
670 $form->{"0411"} = "X";
673 $form->{period} eq "12" && do {
674 $form->{fromdate} = "$form->{year}1201";
675 $form->{todate} = "$form->{year}1231";
676 $form->{"0412"} = "X";
681 # Kontrollvariable für die Templates
682 $form->{'year2007'} = ($form->{year} >= 2007 ) ? "1":"0";
686 USTVA->ustva(\%myconfig, \%$form);
688 # reformat Dates to dateformat
689 $form->{fromdate} = $locale->date(\%myconfig, $form->{fromdate}, 0, 0, 0);
691 $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
692 $form->{todate} = $locale->date(\%myconfig, $form->{todate}, 0, 0, 0);
694 $form->{longperiod} =
695 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1, 0, 0);
697 # if there are any dates construct a where
698 if ($form->{fromdate} || $form->{todate}) {
700 $form->{todate} = $form->current_date($myconfig) unless ($form->{todate});
702 my $longtodate = $locale->date($myconfig, $form->{todate}, 1, 0, 0);
703 my $shorttodate = $locale->date($myconfig, $form->{todate}, 0, 0, 0);
705 my $longfromdate = $locale->date($myconfig, $form->{fromdate}, 1, 0, 0);
706 my $shortfromdate = $locale->date($myconfig, $form->{fromdate}, 0, 0, 0);
708 $form->{this_period} = "$shortfromdate<br>\n$shorttodate";
709 $form->{longperiod} =
710 $locale->text('for Period')
711 . qq|<br>\n$longfromdate |
712 . $locale->text('to (date)')
716 if ($form->{comparefromdate} || $form->{comparetodate}) {
717 my $longcomparefromdate =
718 $locale->date(\%myconfig, $form->{comparefromdate}, 1, 0, 0);
719 my $shortcomparefromdate =
720 $locale->date(\%myconfig, $form->{comparefromdate}, 0, 0, 0);
722 my $longcomparetodate =
723 $locale->date(\%myconfig, $form->{comparetodate}, 1, 0, 0);
724 my $shortcomparetodate =
725 $locale->date(\%myconfig, $form->{comparetodate}, 0, 0, 0);
727 $form->{last_period} = "$shortcomparefromdate<br>\n$shortcomparetodate";
728 $form->{longperiod} .=
729 "<br>\n$longcomparefromdate "
730 . $locale->text('to (date)')
731 . qq| $longcomparetodate|;
734 $form->{Datum_heute} =
735 $locale->date(\%myconfig, $form->current_date(\%myconfig), 0, 0, 0);
737 # setup variables for the form
738 my @a = qw(company businessnumber tel fax email
739 co_chief co_department co_custom1 co_custom2 co_custom3 co_custom4 co_custom5
740 co_name1 co_name2 co_street co_street1 co_zip co_city co_city1 co_country co_tel co_tel1 co_tel2
741 co_fax co_fax1 co_email co_email1 co_url co_url1 ustid duns
742 co_bankname co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1
743 co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2 co_accountnr3);
745 map { $form->{$_} = $myconfig{$_} } @a;
747 if ($form->{address} ne '') {
748 my $temp = $form->{address};
749 $temp =~ s/\\n/<br \/>/;
750 ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp);
751 $form->{co_city} =~ s/\\n//g;
754 ################################
756 # Nation specific customisations
758 ################################
762 if ( $form->{coa} eq 'Germany-DATEV-SKR03EU' or $form->{coa} eq 'Germany-DATEV-SKR04EU') {
765 # Outputformat specific customisation's
768 my @category_cent = USTVA->report_variables({
769 myconfig => \%myconfig,
772 attribute => 'position',
776 push @category_cent, qw(83 Z43 Z45 Z53 Z62 Z65 Z67);
778 my @category_euro = USTVA->report_variables({
779 myconfig => \%myconfig,
782 attribute => 'position',
787 $form->{amount} = [];
789 if ( $form->{format} eq 'pdf' or $form->{format} eq 'postscript') {
791 $form->{IN} = "$form->{type}-$form->{year}.tex";
792 $form->{padding} = "~~";
793 $form->{bold} = "\textbf{";
794 $form->{endbold} = "}";
795 $form->{br} = '\\\\';
797 # Zahlenformatierung für Latex USTVA Formulare
799 foreach my $number (@category_euro) {
800 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '');
803 my ${decimal_comma} = ( $myconfig{numberformat} eq '1.000,00'
804 or $myconfig{numberformat} eq '1000,00' ) ? ',':'.';
806 foreach my $number (@category_cent) {
807 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '');
808 $form->{$number} =~ s/${decimal_comma}/~~/g;
811 } elsif ( $form->{format} eq 'html') { # Formatierungen für HTML Ausgabe
813 $form->{IN} = $form->{type} . '.html';
814 $form->{padding} = " ";
815 $form->{bold} = "<b>";
816 $form->{endbold} = "</b>";
817 $form->{br} = "<br>";
818 $form->{address} =~ s/\\n/\n/g;
820 foreach $number (@category_cent) {
821 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '0');
824 foreach $number (@category_euro) {
825 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '0');
828 } elsif ( $form->{format} eq 'elsterwinston' ) {
830 $form->{IN} = 'winston.xml';
833 # Build Winston filename
836 my $file = 'U'; # 1. char 'U' = USTVA
837 $file .= $form->{period};
838 #4. and 5. char = year modulo 100
839 $file .= sprintf("%02d", $form->{year} % 100);
840 #6. to 18. char = Elstersteuernummer
841 #Beispiel: Steuernummer in Bayern
842 #111/222/33334 ergibt für UStVA Jan 2004: U01049111022233334
843 $file .= $form->{elsterFFFF};
844 $file .= $form->{elstersteuernummer};
848 $form->{tmpfile} = "$userspath/$file";
850 $form->{attachment_filename} = $file;
852 # Zahlenformatierung für Winston
854 my $temp_numberformat = $myconfig{numberformat};
856 # Numberformat must be '1000.00' for Winston
858 $myconfig{numberformat} = '1000.00';
860 foreach my $number (@category_cent) {
861 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '2', '') : '';
864 foreach my $number (@category_euro) {
865 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '0', '') : '';
867 # Re-set Numberformat
868 $myconfig{numberformat} = $temp_numberformat;
870 # push Kennziffern to <%foreach Array fo easyer
871 # output in xml format. Thx to Moritz.
872 my %winston_id_for = (
876 foreach my $kennziffer (@category_cent, @category_euro) {
878 next if ( $kennziffer =~ m/Z\d\d/);
879 next if ( $form->{$kennziffer} == 0 );
881 if (defined $winston_id_for{$kennziffer} ) {
882 push(@{ $form->{id}}, $winston_id_for{$kennziffer});
884 push(@{ $form->{id}}, "Kz$kennziffer");
886 push(@{ $form->{amount}}, $form->{$kennziffer});
889 } elsif ( $form->{format} eq 'elstertaxbird' ) {
891 # Define serveral filenames
892 $form->{IN} = 'taxbird.txb';
894 $form->{attachment_filename} = "USTVA-" . $form->{period}
895 . sprintf("%02d", $form->{year} % 100) . ".txb";
897 $form->{attachment_filename} =~ s|.*/||;
898 $form->{tmpfile} = "$userspath/" . $form->{attachment_filename};
900 # TODO: set Output to UTF-8 or system Preference
901 #$form->{"iconv"} = Text::Iconv->new($myconfig{dbcharset}, "UTF-8");
902 #my $iconv = $self->{"iconv"};
903 #$iconv->convert($variable);
904 if ($form->{period} =~ /^[4]\d$/ ){
905 my %periods = ( # Lx => taxbird
912 foreach my $quarter ( keys %periods ) {
913 $form->{taxbird_period} = $periods{$quarter} if ( $form->{period} eq $quarter);
915 } elsif ($form->{period} =~ /^\d+$/ ) {
916 $form->{period} =~ s/^0//g;
917 my $period = $form->{period};
920 $form->{period} = $period;
923 USTVA::error( $locale->text('Wrong Period' ));
927 my %lands = ( # Lx => taxbird # TODO: besser als array...
928 'Baden Würtemberg' => '0',
931 'Brandenburg' => '3',
935 'Mecklenburg Vorpommern' => '7',
936 'Niedersachsen' => '8',
937 'Nordrhein Westfalen' => '9',
938 'Rheinland Pfalz' => '10',
941 'Sachsen Anhalt' => '13',
942 'Schleswig Holstein' => '14',
945 foreach my $land ( keys %lands ){
946 $form->{taxbird_land_nr} = $lands{$land} if ($form->{elsterland} eq $land );
949 $form->{co_zip} = $form->{co_city};
950 $form->{co_zip} =~ s/\D//g;
951 $form->{co_city} =~ s/\d//g;
952 $form->{co_city} =~ s/^\s//g;
954 ($form->{co_phone_prefix}, $form->{co_phone}) = split("-", $form->{tel});
955 $form->{co_phone_prefix} =~ s/\s//g;
956 $form->{co_phone} =~ s/\s//g;
958 $form->{taxbird_steuernummer} = $form->{steuernummer};
959 # $form->{taxbird_steuernummer} =~ s/\D//g;
960 $form->{taxbird_steuernummer} =~ s/\///; # ersten Querstrich ersetzen
962 # Numberformatting for Taxbird
963 my $temp_numberformat = $myconfig{numberformat};
964 # Numberformat must be '1000,00' for Taxbird ?!
965 $myconfig{numberformat} = '1000,00';
966 foreach my $number (@category_cent) {
967 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '2', '') : '';
970 foreach my $number (@category_euro) {
971 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '0', '') : '';
973 # Re-set Numberformat
974 $myconfig{numberformat} = $temp_numberformat;
976 # push Kennziffern to <%foreach Array fo easyer
977 # output in xml format. Thx to Moritz.
978 my %taxbird_id_for = (
980 '511' => 'Kz51-calc',
981 '861' => 'Kz86-calc',
982 '971' => 'Kz97-calc',
983 '931' => 'Kz93-calc',
984 '811' => 'Kz81-calc',
985 '891' => 'Kz89-calc',
986 'Z45' => 'uebertrag',
988 'Z62' => 'ust-minus-vost',
989 'Z65' => 'ust-sum+69',
994 for my $kennziffer (@category_cent, @category_euro) {
996 next if ($kennziffer eq 'Z43');
998 if ($form->{$kennziffer} != 0){
999 if (defined $taxbird_id_for{$kennziffer}) {
1000 push(@{ $form->{id}}, $taxbird_id_for{$kennziffer});
1002 push(@{ $form->{id}}, "Kz$kennziffer");
1004 push(@{ $form->{amount}}, $form->{$kennziffer});
1008 } elsif ( $form->{format} eq '' ){ # No format error.
1010 USTVA::error( $locale->text('Application Error. No Format given' ) . "!");
1013 } else { # All other Formats are wrong
1015 USTVA::error( $locale->text('Application Error. Wrong Format') . ": " . $form->{format} );
1020 } else # Outputformat for generic output
1023 my @category_cent = USTVA->report_variables({
1024 myconfig => \%myconfig,
1027 attribute => 'position',
1031 my @category_euro = USTVA->report_variables({
1032 myconfig => \%myconfig,
1035 attribute => 'position',
1039 $form->{USTVA} = [];
1041 if ( $form->{format} eq 'generic') { # Formatierungen für HTML Ausgabe
1044 for my $kennziffer (@category_cent, @category_euro) {
1046 $rec_ref->{id} = $kennziffer;
1047 $rec_ref->{amount} = $form->format_amount(\%myconfig, $form->{$kennziffer}, 2, '0');
1049 $lxdebug->message($LXDebug::DEBUG, "Kennziffer $kennziffer: '$form->{$kennziffer}'" );
1050 $lxdebug->dump($LXDebug::DEBUG, $rec_ref );
1051 push @ { $form->{USTVA} }, $rec_ref;
1058 if ( $form->{period} eq '13' and $form->{format} ne 'html') {
1062 'Yearly taxreport not yet implemented')
1066 $form->{templates} = $myconfig{templates};
1067 $form->{templates} = "doc" if ( $form->{type} eq 'help' );
1069 if ($form->{format} eq 'generic'){
1074 taxnumber => $myconfig{taxnumber},
1077 print($form->parse_html_template('ustva/generic_taxreport', $template_ref));
1082 $form->parse_template(\%myconfig, $userspath);
1086 $lxdebug->leave_sub();
1090 $lxdebug->enter_sub();
1092 $auth->assert('advance_turnover_tax_return');
1094 # edit all taxauthority prefs
1097 USTVA->get_config($userspath, 'finanzamt.ini');
1099 my $land = $form->{elsterland};
1100 my $amt = $form->{elsterFFFF};
1103 $form->{title} = $locale->text('Tax Office Preferences');
1106 my $select_tax_office = USTVA->fa_auswahl($land, $amt, &elster_hash());
1107 my $checked_accrual = q|checked="checked"| if ($form->{method} eq 'accrual');
1108 my $checked_cash = q|checked="checked"| if ($form->{method} eq 'cash');
1109 my $checked_monthly = "checked" if ($form->{FA_voranmeld} eq 'month');
1110 my $checked_quarterly = "checked" if ($form->{FA_voranmeld} eq 'quarter');
1111 my $checked_dauerfristverlaengerung = "checked" if ($form->{FA_dauerfrist} eq '1');
1112 my $checked_kz_71 = "checked" if ($form->{FA_71} eq 'X');
1114 my $_hidden_variables_ref;
1116 my %_hidden_local_variables = (
1117 'saved' => $locale->text('Check Details'),
1118 'nextsub' => 'config_step2',
1122 foreach my $variable (keys %_hidden_local_variables) {
1123 push @{ $_hidden_variables_ref },
1124 { 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
1127 my @_hidden_form_variables = qw(
1128 FA_Name FA_Strasse FA_PLZ
1129 FA_Ort FA_Telefon FA_Fax
1130 FA_PLZ_Grosskunden FA_PLZ_Postfach FA_Postfach
1131 FA_BLZ_1 FA_Kontonummer_1 FA_Bankbezeichnung_1
1132 FA_BLZ_2 FA_Kontonummer_2 FA_Bankbezeichnung_oertlich
1133 FA_Oeffnungszeiten FA_Email FA_Internet
1134 steuernummer elsterland elstersteuernummer
1138 foreach my $variable (@_hidden_form_variables) {
1139 push @{ $_hidden_variables_ref},
1140 { 'variable' => $variable, 'value' => $form->{$variable} };
1143 # Which COA is in use?
1145 USTVA->get_coa($form, \%myconfig);
1148 my $steuernummer_new = '';
1150 # Variablen für das Template zur Verfügung stellen
1151 my $template_ref = {
1152 select_tax_office => $select_tax_office,
1153 checked_accrual => $checked_accrual,
1154 checked_cash => $checked_cash,
1155 checked_monthly => $checked_monthly,
1156 checked_quarterly => $checked_quarterly,
1157 checked_dauerfristverlaengerung => $checked_dauerfristverlaengerung,
1158 hidden_variables => $_hidden_variables_ref,
1162 # Ausgabe des Templates
1163 print($form->parse_html_template('ustva/config_step1', $template_ref));
1165 $lxdebug->leave_sub();
1169 $lxdebug->enter_sub();
1171 $auth->assert('advance_turnover_tax_return');
1179 my $elsterland = '';
1180 my $elster_amt = '';
1181 my $elsterFFFF = '';
1182 my $elstersteuernummer = '';
1183 USTVA->get_config($userspath, 'finanzamt.ini')
1184 if ($form->{saved} eq $locale->text('saved'));
1186 # Auf Übergabefehler checken
1187 USTVA::info( $locale->text('Missing Tax Authoritys Preferences') . "\n"
1188 . $locale->text('USTVA-Hint: Tax Authoritys'))
1189 if ( $form->{elsterFFFF_new} eq 'Auswahl'
1190 || $form->{elsterland_new} eq 'Auswahl');
1191 USTVA::info( $locale->text('Missing Method!') . "\n"
1192 . $locale->text('USTVA-Hint: Method'))
1193 if ($form->{method} eq '');
1195 # Klären, ob Variablen bereits befüllt sind UND ob veräderungen auf
1196 # der vorherigen Maske stattfanden: $change = 1(in der edit sub,
1197 # mittels get_config)
1199 my $change = $form->{elsterland} eq $form->{elsterland_new}
1200 && $form->{elsterFFFF} eq $form->{elsterFFFF_new} ? '0' : '1';
1201 $change = '0' if ($form->{saved} eq $locale->text('saved'));
1202 my $elster_init = &elster_hash();
1204 my %elster_init = %$elster_init;
1206 if ($change eq '1') {
1209 $elsterland = $form->{elsterland_new};
1210 $elsterFFFF = $form->{elsterFFFF_new};
1211 $form->{elsterland} = $elsterland;
1212 $form->{elsterFFFF} = $elsterFFFF;
1213 $form->{steuernummer} = '';
1215 create_steuernummer();
1217 # rebuild elster_amt
1219 foreach $amt (keys %{ $elster_init{ $form->{elsterland} } }) {
1221 if ($elster_init{ $form->{elsterland}{$amt} eq $form->{elsterFFFF} });
1224 # load the predefined hash data into the FA_* Vars
1225 my @variables = qw(FA_Name FA_Strasse FA_PLZ FA_Ort
1226 FA_Telefon FA_Fax FA_PLZ_Grosskunden FA_PLZ_Postfach
1228 FA_BLZ_1 FA_Kontonummer_1 FA_Bankbezeichnung_1
1229 FA_BLZ_2 FA_Kontonummer_2 FA_Bankbezeichnung_oertlich
1230 FA_Oeffnungszeiten FA_Email FA_Internet);
1232 for (my $i = 0; $i <= 20; $i++) {
1233 $form->{ $variables[$i] } =
1234 $elster_init->{$elsterland}->{$elsterFFFF}->[$i];
1239 $elsterland = $form->{elsterland};
1240 $elsterFFFF = $form->{elsterFFFF};
1243 my $stnr = $form->{steuernummer};
1245 my $patterncount = $form->{patterncount};
1246 my $elster_pattern = $form->{elster_pattern};
1247 my $delimiter = $form->{delimiter};
1248 my $steuernummer = $form->{steuernummer} if ($steuernummer eq '');
1250 $form->{FA_Oeffnungszeiten} =~ s/\\\\n/\n/g;
1254 my $input_steuernummer = USTVA->steuernummer_input(
1255 $form->{elsterland},
1256 $form->{elsterFFFF},
1257 $form->{steuernummer}
1260 $lxdebug->message(LXDebug::DEBUG1, qq|$input_steuernummer|);
1263 my $_hidden_variables_ref;
1265 my %_hidden_local_variables = (
1266 'elsterland' => $elsterland,
1267 'elsterFFFF' => $elsterFFFF,
1268 'warnung' => $warnung,
1269 'elstersteuernummer' => $elstersteuernummer,
1270 'steuernummer' => $stnr,
1271 'lastsub' => 'config_step1',
1272 'nextsub' => 'save',
1276 foreach my $variable (keys %_hidden_local_variables) {
1277 push @{ $_hidden_variables_ref },
1278 { 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
1281 my @_hidden_form_variables = qw(
1282 FA_steuerberater_name FA_steuerberater_street
1283 FA_steuerberater_city FA_steuerberater_tel
1291 foreach my $variable (@_hidden_form_variables) {
1292 push @{ $_hidden_variables_ref},
1293 { 'variable' => $variable, 'value' => $form->{$variable} };
1296 my $template_ref = {
1297 tax_office_data => $tax_office_data,
1298 input_steuernummer => $input_steuernummer,
1299 readonly => '', #q|disabled="disabled"|,
1300 callback => $callback,
1301 hidden_variables => $_hidden_variables_ref,
1304 # Ausgabe des Templates
1305 print($form->parse_html_template('ustva/config_step2', $template_ref));
1308 $lxdebug->leave_sub();
1311 sub create_steuernummer {
1312 $lxdebug->enter_sub();
1314 $auth->assert('advance_turnover_tax_return');
1316 my $part = $form->{part};
1317 my $patterncount = $form->{patterncount};
1318 my $delimiter = $form->{delimiter};
1319 my $elster_pattern = $form->{elster_pattern};
1321 # rebuild steuernummer and elstersteuernummer
1322 # es gibt eine gespeicherte steuernummer $form->{steuernummer}
1323 # und die parts und delimiter
1328 my $steuernummer_new = $part;
1329 my $elstersteuernummer_new = $form->{elster_FFFF};
1330 $elstersteuernummer_new .= '0';
1332 for ($h = 1; $h < $patterncount; $h++) {
1333 $steuernummer_new .= qq|$delimiter|;
1334 for (my $i = 1; $i <= length($elster_pattern); $i++) {
1335 $steuernummer_new .= $form->{"part_$h\_$i"};
1336 $elstersteuernummer_new .= $form->{"part_$h\_$i"};
1339 if ($form->{steuernummer} ne $steuernummer_new) {
1340 $form->{steuernummer} = $steuernummer_new;
1341 $form->{elstersteuernummer} = $elstersteuernummer_new;
1342 $form->{steuernummer_new} = $steuernummer_new;
1344 $form->{steuernummer_new} = '';
1345 $form->{elstersteuernummer_new} = '';
1347 $lxdebug->leave_sub();
1351 $lxdebug->enter_sub();
1353 $auth->assert('advance_turnover_tax_return');
1355 my $filename = "$form->{login}_$form->{filename}";
1356 $filename =~ s|.*/||;
1358 #zuerst die steuernummer aus den part, parts_X_Y und delimiter herstellen
1359 create_steuernummer();
1361 # Textboxen formatieren: Linebreaks entfernen
1363 $form->{FA_Oeffnungszeiten} =~ s/\r\n/\\n/g;
1365 #URL mit http:// davor?
1366 $form->{FA_Internet} =~ s/^http:\/\///;
1367 $form->{FA_Internet} = 'http://' . $form->{FA_Internet};
1370 elster elsterland elstersteuernummer steuernummer
1371 elsteramt elsterFFFF FA_Name FA_Strasse
1372 FA_PLZ FA_Ort FA_Telefon FA_Fax
1373 FA_PLZ_Grosskunden FA_PLZ_Postfach FA_Postfach FA_BLZ_1
1374 FA_Kontonummer_1 FA_Bankbezeichnung_1 FA_BLZ_2 FA_Kontonummer_2
1375 FA_Bankbezeichnung_oertlich FA_Oeffnungszeiten
1376 FA_Email FA_Internet FA_voranmeld method FA_steuerberater_name
1377 FA_steuerberater_street FA_steuerberater_city FA_steuerberater_tel
1378 FA_71 FA_dauerfrist);
1380 # Hier kommt dann die Plausibilitätsprüfung der ELSTERSteuernummer
1381 if ($form->{elstersteuernummer} ne '000000000') {
1383 $form->{elster} = '1';
1385 open my $ustvaconfig, ">", "$userspath/$filename" or $form->error("$filename : $!");
1387 # create the config file
1388 print {$ustvaconfig} qq|# Configuration file for USTVA\n\n|;
1390 foreach $key (sort @config) {
1391 $form->{$key} =~ s/\\/\\\\/g;
1393 $form->{$key} =~ s/\r\n/\n/g;
1395 print {$ustvaconfig} qq|$key=|;
1396 if ($form->{$key} ne 'Y') {
1397 print {$ustvaconfig} qq|$form->{$key}\n|;
1399 if ($form->{$key} eq 'Y') {
1400 print {$ustvaconfig} qq|checked \n|;
1403 print {$ustvaconfig} qq|\n\n|;
1405 $form->{saved} = $locale->text('saved');
1409 $form->{saved} = $locale->text('Choose a Tax Number');
1413 $lxdebug->leave_sub();
1418 $lxdebug->enter_sub();
1420 # allow Symbolic references just here:
1422 call_sub($form->{"nextsub"});
1424 $lxdebug->leave_sub();
1428 $lxdebug->enter_sub();
1429 call_sub($form->{"lastsub"});
1430 $lxdebug->leave_sub();
1434 $lxdebug->enter_sub();
1436 $auth->assert('advance_turnover_tax_return');
1438 my $finanzamt = USTVA->query_finanzamt(\%myconfig, \%$form);
1439 $lxdebug->leave_sub();