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";
37 use List::Util qw(first);
45 # this is for our long dates
46 # $locale->text('January')
47 # $locale->text('February')
48 # $locale->text('March')
49 # $locale->text('April')
50 # $locale->text('May ')
51 # $locale->text('June')
52 # $locale->text('July')
53 # $locale->text('August')
54 # $locale->text('September')
55 # $locale->text('October')
56 # $locale->text('November')
57 # $locale->text('December')
59 # this is for our short month
60 # $locale->text('Jan')
61 # $locale->text('Feb')
62 # $locale->text('Mar')
63 # $locale->text('Apr')
64 # $locale->text('May')
65 # $locale->text('Jun')
66 # $locale->text('Jul')
67 # $locale->text('Aug')
68 # $locale->text('Sep')
69 # $locale->text('Oct')
70 # $locale->text('Nov')
71 # $locale->text('Dec')
73 #############################
76 $lxdebug->enter_sub();
78 $auth->assert('advance_turnover_tax_return');
80 my $myconfig = \%myconfig;
82 $form->{title} = $locale->text('UStVA');
83 $form->{kz10} = ''; #Berichtigte Anmeldung? Ja =1 Nein=0
85 my $year = substr($form->datetonum($form->current_date(\%myconfig), \%myconfig ),
92 # Einlesen der Finanzamtdaten
93 my $ustva = USTVA->new();
94 $ustva->get_config($userspath, 'finanzamt.ini');
96 # Hier Einlesen der user-config
97 # steuernummer entfernt für prerelease
99 signature name company address businessnumber
100 tel fax email co_chief co_department
101 co_custom1 co_custom2 co_custom3 co_custom4 co_custom5
102 co_name1 co_name2 co_street co_street1 co_zip
103 co_city co_city1 co_country co_tel co_tel1
104 co_tel2 co_fax co_fax1 co_email co_email1
105 co_url co_url1 ustid duns co_bankname
106 co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1
107 co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2
111 map { $form->{$_} = $myconfig->{$_} } @a;
113 my $openings = $form->{FA_Oeffnungszeiten};
114 $openings =~ s/\\\\n/<br>/g;
116 my $company_given = ($form->{company} ne '')
117 ? qq|<h3>$form->{company}</h3>\n|
118 : qq|<a href="am.pl?action=config|
119 . qq|&level=Programm--Preferences">|
120 . $locale->text('No Company Name given') . qq|!</a><br>|;
123 # Anpassungen der Variablennamen auf pre 2.1.1 Namen
124 # klären, ob $form->{company_street|_address} gesetzt sind
125 if ($form->{address} ne '') {
126 my $temp = $form->{address};
127 $temp =~ s/\n/<br \/>/;
128 ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp);
129 $form->{co_city} =~ s/\n//g;
134 ($form->{co_street} && ($form->{co_zip} || $form->{co_city}))
135 ? qq|$form->{co_street}<br>|
136 . qq|$form->{co_street1}<br>|
137 . qq|$form->{co_zip} $form->{co_city}|
138 : qq|<a href="am.pl?action=config|
139 . qq|&level=Programm--Preferences">|
140 . $locale->text('No Company Address given')
143 $form->{co_email} = $form->{email} unless $form->{co_email};
144 $form->{co_tel} = $form->{tel} unless $form->{co_tel};
145 $form->{co_fax} = $form->{fax} unless $form->{co_fax};
146 $form->{co_url} = $form->{urlx} unless $form->{co_url};
148 my $taxnumber_given = ($form->{steuernummer} ne '') ? $form->{steuernummer} : qq|<a href="ustva.pl?action=config_step1">Keine Steuernummer hinterlegt!</a><br>|;
150 my $ustva_vorauswahl = &ustva_vorauswahl();
152 my @all_years = $form->all_years(\%myconfig);
154 my $select_year = qq|<select name=year title="|
155 . $locale->text('Year') . qq|">|;
156 foreach my $key (@all_years) {
157 $select_year .= qq|<option |;
158 $select_year .= qq|selected| if ($key eq $form->{year});
159 $select_year .= qq| >$key</option>|;
161 $select_year .= qq|</select>|;
164 $_checked = "checked" if ($form->{kz10} eq '1');
165 my $checkbox_kz_10 = qq|<input name="FA_10" id=FA_10 class=checkbox|
166 . qq| type=checkbox value="1" $_checked title = "|
167 . $locale->text('Amended Advance Turnover Tax Return (Nr. 10)')
169 . $locale->text('Amended Advance Turnover Tax Return');
171 my $method_local = ($form->{method} eq 'accrual') ? $locale->text('accrual')
172 : ($form->{method} eq 'cash') ? $locale->text('cash')
175 my $period_local = ( $form->{FA_voranmeld} eq 'month') ? $locale->text('month')
176 : ( $form->{FA_voranmeld} eq 'quarter') ? $locale->text('quarter')
179 my $tax_office_banks_ref = [
180 { BLZ => $form->{FA_BLZ_1},
181 Kontonummer => $form->{FA_Kontonummer_1},
182 Bankbezeichnung => $form->{FA_Bankbezeichnung_1}
184 { BLZ => $form->{FA_BLZ_2},
185 Kontonummer => $form->{FA_Kontonummer_2},
186 Bankbezeichnung => $form->{FA_Bankbezeichnung_oertlich}
190 # Which COA is in use?
192 $ustva->get_coa($form, $myconfig);
195 openings => $openings,
196 company_given => $company_given,
197 address_given => $address_given,
198 taxnumber_given => $taxnumber_given,
199 taxnumber => $myconfig->{taxnumber},
200 select_year => $select_year,
201 period_local => $period_local,
202 method_local => $method_local,
203 ustva_vorauswahl => $ustva_vorauswahl,
204 checkbox_kz_10 => $checkbox_kz_10,
205 tax_office_banks => $tax_office_banks_ref,
206 select_options => &show_options,
210 print($form->parse_html_template('ustva/report', $template_ref));
214 $lxdebug->leave_sub();
220 $lxdebug->enter_sub();
222 $auth->assert('advance_turnover_tax_return');
224 # parse help documents under doc
225 my $tmp = $form->{templates};
226 $form->{templates} = 'doc';
227 $form->{help} = 'ustva';
228 $form->{type} = 'help';
229 $form->{format} = 'html';
232 #$form->{templates} = $tmp;
233 $lxdebug->leave_sub();
237 $lxdebug->enter_sub();
239 $auth->assert('advance_turnover_tax_return');
243 $lxdebug->leave_sub();
244 call_sub($form->{"nextsub"});
248 sub ustva_vorauswahl {
249 $lxdebug->enter_sub();
251 $auth->assert('advance_turnover_tax_return');
253 my $select_vorauswahl;
255 #Aktuelles Datum zerlegen:
256 my $date = $form->datetonum($form->current_date(\%myconfig), \%myconfig);
258 #$locale->date($myconfig, $form->current_date($myconfig), 0)=~ /(\d\d).(\d\d).(\d\d\d\d)/;
259 $form->{day} = substr($date, 6, 2);
260 $form->{month} = substr($date, 4, 2);
261 $form->{year} = substr($date, 0, 4);
262 $lxdebug->message(LXDebug::DEBUG1, qq|
263 Actual date from Database: $date\n
264 Actual year from Database: $form->{year}\n
265 Actual day from Database: $form->{day}\n
266 Actual month from Database: $form->{month}\n|);
271 # Testdaten erzeugen:
273 #$form->{month}= '01';
274 #$form->{year}= 2004;
275 $select_vorauswahl = qq|
276 <input type=hidden name=day value=$form->{day}>
277 <input type=hidden name=month value=$form->{month}>
278 <input type=hidden name=yymmdd value=$yymmdd>
279 <input type=hidden name=sel value=$sel>
282 if ($form->{FA_voranmeld} eq 'month') {
284 # Vorauswahl bei monatlichem Voranmeldungszeitraum
286 my %liste = ('01' => $locale->text('January'),
287 '02' => $locale->text('February'),
288 '03' => $locale->text('March'),
289 '04' => $locale->text('April'),
290 '05' => $locale->text('May'),
291 '06' => $locale->text('June'),
292 '07' => $locale->text('July'),
293 '08' => $locale->text('August'),
294 '09' => $locale->text('September'),
295 '10' => $locale->text('October'),
296 '11' => $locale->text('November'),
297 '12' => $locale->text('December'),
298 '13' => $locale->text('Yearly'),
301 my $yy = $form->{year} * 10000;
302 $yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
306 # Offset für Dauerfristverlängerung
307 $dfv = '100' if ($form->{FA_dauerfrist} eq '1');
310 $yymmdd <= ($yy + 110 + $dfv) && do {
311 $form->{year} = $form->{year} - 1;
315 $yymmdd <= ($yy + 210 + $dfv) && do {
319 $yymmdd <= ($yy + 310 + $dfv) && do {
323 $yymmdd <= ($yy + 410 + $dfv) && do {
327 $yymmdd <= ($yy + 510 + $dfv) && do {
331 $yymmdd <= ($yy + 610 + $dfv) && do {
335 $yymmdd <= ($yy + 710 + $dfv) && do {
339 $yymmdd <= ($yy + 810 + $dfv) && do {
343 $yymmdd <= ($yy + 910 + $dfv) && do {
347 $yymmdd <= ($yy + 1010 + $dfv) && do {
351 $yymmdd <= ($yy + 1110 + $dfv) && do {
355 $yymmdd <= ($yy + 1210) && do {
359 $yymmdd <= ($yy + 1231) && do {
365 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
366 . $locale->text('Select a period') . qq|" >|;
369 foreach $key (sort keys %liste) {
371 $selected = 'selected' if ($sel eq $key);
372 $select_vorauswahl .= qq|
373 <option value="$key" $selected> $liste{$key}</option>
376 $select_vorauswahl .= qq|</select>|;
378 } elsif ($form->{FA_voranmeld} eq 'quarter') {
380 # Vorauswahl bei quartalsweisem Voranmeldungszeitraum
381 my %liste = ('41' => $locale->text('1. Quarter'),
382 '42' => $locale->text('2. Quarter'),
383 '43' => $locale->text('3. Quarter'),
384 '44' => $locale->text('4. Quarter'),
385 '13' => $locale->text('Yearly'),);
387 my $yy = $form->{year} * 10000;
388 $yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
390 my $dfv = ''; # Offset für Dauerfristverlängerung
391 $dfv = '100' if ($form->{FA_dauerfrist} eq '1');
394 $yymmdd <= ($yy + 110 + $dfv) && do {
395 $form->{year} = $form->{year} - 1;
399 $yymmdd <= ($yy + 410 + $dfv) && do {
403 $yymmdd <= ($yy + 710 + $dfv) && do {
407 $yymmdd <= ($yy + 1010 + $dfv) && do {
411 $yymmdd <= ($yy + 1231) && do {
416 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
417 . $locale->text('Select a period') . qq|" >|;
419 foreach $key (sort keys %liste) {
421 $selected = 'selected' if ($sel eq $key);
422 $select_vorauswahl .= qq|
423 <option value="$key" $selected>$liste{$key}</option>
426 $select_vorauswahl .= qq|\n</select>
431 # keine Vorauswahl bei Voranmeldungszeitraum
432 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
433 . $locale->text('Select a period') . qq|" >|;
435 my %listea = ('41' => '1. Quarter',
436 '42' => '2. Quarter',
437 '43' => '3. Quarter',
438 '44' => '4. Quarter',);
440 my %listeb = ('01' => 'January',
454 foreach $key (sort keys %listea) {
455 $select_vorauswahl .= qq|
456 <option value="$key">|
457 . $locale->text("$listea{$key}")
461 foreach $key (sort keys %listeb) {
462 $select_vorauswahl .= qq|
463 <option value="$key">|
464 . $locale->text("$listeb{$key}")
467 $select_vorauswahl .= qq|</select>|;
469 $lxdebug->leave_sub();
471 return $select_vorauswahl;
475 # $lxdebug->enter_sub();
477 # $lxdebug->leave_sub();
481 $lxdebug->enter_sub();
483 $lxdebug->leave_sub();
487 $lxdebug->enter_sub();
489 $auth->assert('advance_turnover_tax_return');
491 # $form->{PD}{$form->{type}} = "selected";
492 # $form->{DF}{$form->{format}} = "selected";
493 # $form->{OP}{$form->{media}} = "selected";
494 # $form->{SM}{$form->{sendmode}} = "selected";
495 my $type = qq| <input type=hidden name="type" value="ustva">|;
496 my $media = qq| <input type=hidden name="media" value="screen">|;
498 qq| <option value=html selected>|
499 . $locale->text('Preview')
501 if ($latex_templates) {
503 qq| <option value=pdf>|
504 . $locale->text('UStVA (PDF-Dokument)')
508 #my $disabled= qq|disabled="disabled"|;
509 #$disabled='' if ($form->{elster} eq '1' );
510 if ($form->{elster} eq '1') {
512 qq|<option value=elsterwinston>|
513 . $locale->text('ELSTER Export (Winston)')
515 . qq|<option value=elstertaxbird>|
516 . $locale->text('ELSTER Export (Taxbird)')
520 #$format .= qq|<option value=elster>|.$locale->text('ELSTER Export nach Winston').qq|</option>|;
521 my $show_options = qq|
524 <select name=format title = "|
525 . $locale->text('Choose Outputformat') . qq|">$format</select>
527 $lxdebug->leave_sub();
529 return $show_options;
533 $lxdebug->enter_sub();
535 $auth->assert('advance_turnover_tax_return');
537 # Aufruf von get_config zum Einlesen der Finanzamtdaten aus finanzamt.ini
539 my $ustva = USTVA->new();
540 $ustva->get_config($userspath, 'finanzamt.ini');
542 # init some form vars
543 my @anmeldungszeitraum =
544 qw('0401' '0402' '0403'
548 '0441' '0442' '0443' '0444');
550 foreach my $item (@anmeldungszeitraum) {
554 #forgotten the year --> thisyear
555 if ($form->{year} !~ m/^\d\d\d\d$/) {
556 $form->{year} = substr(
558 $form->current_date(\%myconfig), \%myconfig
561 $lxdebug->message(LXDebug::DEBUG1,
562 qq|Actual year from Database: $form->{year}\n|);
566 # using dates in ISO-8601 format: yyyymmmdd for Postgres...
570 if ($form->{period} eq "13") {
571 $form->{fromdate} = "$form->{year}0101";
572 $form->{todate} = "$form->{year}1231";
576 if ($form->{period} eq "41") {
577 $form->{fromdate} = "$form->{year}0101";
578 $form->{todate} = "$form->{year}0331";
579 $form->{'0441'} = "X";
581 if ($form->{period} eq "42") {
582 $form->{fromdate} = "$form->{year}0401";
583 $form->{todate} = "$form->{year}0630";
584 $form->{'0442'} = "X";
586 if ($form->{period} eq "43") {
587 $form->{fromdate} = "$form->{year}0701";
588 $form->{todate} = "$form->{year}0930";
589 $form->{'0443'} = "X";
591 if ($form->{period} eq "44") {
592 $form->{fromdate} = "$form->{year}1001";
593 $form->{todate} = "$form->{year}1231";
594 $form->{'0444'} = "X";
599 $form->{period} eq "01" && do {
600 $form->{fromdate} = "$form->{year}0101";
601 $form->{todate} = "$form->{year}0131";
602 $form->{'0401'} = "X";
605 $form->{period} eq "02" && do {
606 $form->{fromdate} = "$form->{year}0201";
608 #this works from 1901 to 2099, 1900 and 2100 fail.
609 my $leap = ($form->{year} % 4 == 0) ? "29" : "28";
610 $form->{todate} = "$form->{year}02$leap";
611 $form->{"0402"} = "X";
614 $form->{period} eq "03" && do {
615 $form->{fromdate} = "$form->{year}0301";
616 $form->{todate} = "$form->{year}0331";
617 $form->{"0403"} = "X";
620 $form->{period} eq "04" && do {
621 $form->{fromdate} = "$form->{year}0401";
622 $form->{todate} = "$form->{year}0430";
623 $form->{"0404"} = "X";
626 $form->{period} eq "05" && do {
627 $form->{fromdate} = "$form->{year}0501";
628 $form->{todate} = "$form->{year}0531";
629 $form->{"0405"} = "X";
632 $form->{period} eq "06" && do {
633 $form->{fromdate} = "$form->{year}0601";
634 $form->{todate} = "$form->{year}0630";
635 $form->{"0406"} = "X";
638 $form->{period} eq "07" && do {
639 $form->{fromdate} = "$form->{year}0701";
640 $form->{todate} = "$form->{year}0731";
641 $form->{"0407"} = "X";
644 $form->{period} eq "08" && do {
645 $form->{fromdate} = "$form->{year}0801";
646 $form->{todate} = "$form->{year}0831";
647 $form->{"0408"} = "X";
650 $form->{period} eq "09" && do {
651 $form->{fromdate} = "$form->{year}0901";
652 $form->{todate} = "$form->{year}0930";
653 $form->{"0409"} = "X";
656 $form->{period} eq "10" && do {
657 $form->{fromdate} = "$form->{year}1001";
658 $form->{todate} = "$form->{year}1031";
659 $form->{"0410"} = "X";
662 $form->{period} eq "11" && do {
663 $form->{fromdate} = "$form->{year}1101";
664 $form->{todate} = "$form->{year}1130";
665 $form->{"0411"} = "X";
668 $form->{period} eq "12" && do {
669 $form->{fromdate} = "$form->{year}1201";
670 $form->{todate} = "$form->{year}1231";
671 $form->{"0412"} = "X";
676 # Kontrollvariable für die Templates
677 $form->{'year2007'} = ($form->{year} >= 2007 ) ? "1":"0";
681 $ustva->ustva(\%myconfig, \%$form);
683 # reformat Dates to dateformat
684 $form->{fromdate} = $locale->date(\%myconfig, $form->{fromdate}, 0, 0, 0);
686 $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
687 $form->{todate} = $locale->date(\%myconfig, $form->{todate}, 0, 0, 0);
689 $form->{longperiod} =
690 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1, 0, 0);
692 # if there are any dates construct a where
693 if ($form->{fromdate} || $form->{todate}) {
695 $form->{todate} = $form->current_date($myconfig) unless ($form->{todate});
697 my $longtodate = $locale->date($myconfig, $form->{todate}, 1, 0, 0);
698 my $shorttodate = $locale->date($myconfig, $form->{todate}, 0, 0, 0);
700 my $longfromdate = $locale->date($myconfig, $form->{fromdate}, 1, 0, 0);
701 my $shortfromdate = $locale->date($myconfig, $form->{fromdate}, 0, 0, 0);
703 $form->{this_period} = "$shortfromdate<br>\n$shorttodate";
704 $form->{longperiod} =
705 $locale->text('for Period')
706 . qq|<br>\n$longfromdate |
707 . $locale->text('to (date)')
711 if ($form->{comparefromdate} || $form->{comparetodate}) {
712 my $longcomparefromdate =
713 $locale->date(\%myconfig, $form->{comparefromdate}, 1, 0, 0);
714 my $shortcomparefromdate =
715 $locale->date(\%myconfig, $form->{comparefromdate}, 0, 0, 0);
717 my $longcomparetodate =
718 $locale->date(\%myconfig, $form->{comparetodate}, 1, 0, 0);
719 my $shortcomparetodate =
720 $locale->date(\%myconfig, $form->{comparetodate}, 0, 0, 0);
722 $form->{last_period} = "$shortcomparefromdate<br>\n$shortcomparetodate";
723 $form->{longperiod} .=
724 "<br>\n$longcomparefromdate "
725 . $locale->text('to (date)')
726 . qq| $longcomparetodate|;
729 $form->{Datum_heute} =
730 $locale->date(\%myconfig, $form->current_date(\%myconfig), 0, 0, 0);
732 # setup variables for the form
733 my @a = qw(company businessnumber tel fax email
734 co_chief co_department co_custom1 co_custom2 co_custom3 co_custom4 co_custom5
735 co_name1 co_name2 co_street co_street1 co_zip co_city co_city1 co_country co_tel co_tel1 co_tel2
736 co_fax co_fax1 co_email co_email1 co_url co_url1 ustid duns
737 co_bankname co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1
738 co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2 co_accountnr3);
740 map { $form->{$_} = $myconfig{$_} } @a;
742 if ($form->{address} ne '') {
743 my $temp = $form->{address};
744 $temp =~ s/\\n/<br \/>/;
745 ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp);
746 $form->{co_city} =~ s/\\n//g;
749 ################################
751 # Nation specific customisations
753 ################################
757 if ( $form->{coa} eq 'Germany-DATEV-SKR03EU' or $form->{coa} eq 'Germany-DATEV-SKR04EU') {
760 # Outputformat specific customisation's
763 my @category_cent = $ustva->report_variables({
764 myconfig => \%myconfig,
767 attribute => 'position',
771 push @category_cent, qw(83 Z43 Z45 Z53 Z62 Z65 Z67);
773 my @category_euro = $ustva->report_variables({
774 myconfig => \%myconfig,
777 attribute => 'position',
782 $form->{amount} = [];
784 if ( $form->{format} eq 'pdf' or $form->{format} eq 'postscript') {
786 $form->{IN} = "$form->{type}-$form->{year}.tex";
787 $form->{padding} = "~~";
788 $form->{bold} = "\textbf{";
789 $form->{endbold} = "}";
790 $form->{br} = '\\\\';
792 # Zahlenformatierung für Latex USTVA Formulare
794 foreach my $number (@category_euro) {
795 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '');
798 my ${decimal_comma} = ( $myconfig{numberformat} eq '1.000,00'
799 or $myconfig{numberformat} eq '1000,00' ) ? ',':'.';
801 foreach my $number (@category_cent) {
802 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '');
803 $form->{$number} =~ s/${decimal_comma}/~~/g;
806 } elsif ( $form->{format} eq 'html') { # Formatierungen für HTML Ausgabe
808 $form->{IN} = $form->{type} . '.html';
809 $form->{padding} = " ";
810 $form->{bold} = "<b>";
811 $form->{endbold} = "</b>";
812 $form->{br} = "<br>";
813 $form->{address} =~ s/\\n/\n/g;
815 foreach $number (@category_cent) {
816 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '0');
819 foreach $number (@category_euro) {
820 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '0');
823 } elsif ( $form->{format} eq 'elsterwinston' ) {
825 $form->{IN} = 'winston.xml';
828 # Build Winston filename
831 my $file = 'U'; # 1. char 'U' = USTVA
832 $file .= $form->{period};
833 #4. and 5. char = year modulo 100
834 $file .= sprintf("%02d", $form->{year} % 100);
835 #6. to 18. char = Elstersteuernummer
836 #Beispiel: Steuernummer in Bayern
837 #111/222/33334 ergibt für UStVA Jan 2004: U01049111022233334
838 $file .= $form->{elsterFFFF};
839 $file .= $form->{elstersteuernummer};
843 $form->{tmpfile} = "$userspath/$file";
845 $form->{attachment_filename} = $file;
847 # Zahlenformatierung für Winston
849 my $temp_numberformat = $myconfig{numberformat};
851 # Numberformat must be '1000.00' for Winston
853 $myconfig{numberformat} = '1000.00';
855 foreach my $number (@category_cent) {
856 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '2', '') : '';
859 foreach my $number (@category_euro) {
860 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '0', '') : '';
862 # Re-set Numberformat
863 $myconfig{numberformat} = $temp_numberformat;
865 # push Kennziffern to <%foreach Array fo easyer
866 # output in xml format. Thx to Moritz.
867 my %winston_id_for = (
871 foreach my $kennziffer (@category_cent, @category_euro) {
873 next if ( $kennziffer =~ m/Z\d\d/);
874 next if ( $form->{$kennziffer} == 0 );
876 if (defined $winston_id_for{$kennziffer} ) {
877 push(@{ $form->{id}}, $winston_id_for{$kennziffer});
879 push(@{ $form->{id}}, "Kz$kennziffer");
881 push(@{ $form->{amount}}, $form->{$kennziffer});
884 } elsif ( $form->{format} eq 'elstertaxbird' ) {
886 # Define serveral filenames
887 $form->{IN} = 'taxbird.txb';
889 $form->{attachment_filename} = "USTVA-" . $form->{period}
890 . sprintf("%02d", $form->{year} % 100) . ".txb";
892 $form->{attachment_filename} =~ s|.*/||;
893 $form->{tmpfile} = "$userspath/" . $form->{attachment_filename};
895 # TODO: set Output to UTF-8 or system Preference
896 #$form->{"iconv"} = Text::Iconv->new($myconfig{dbcharset}, "UTF-8");
897 #my $iconv = $self->{"iconv"};
898 #$iconv->convert($variable);
899 if ($form->{period} =~ /^[4]\d$/ ){
900 my %periods = ( # Lx => taxbird
907 foreach my $quarter ( keys %periods ) {
908 $form->{taxbird_period} = $periods{$quarter} if ( $form->{period} eq $quarter);
910 } elsif ($form->{period} =~ /^\d+$/ ) {
911 $form->{period} =~ s/^0//g;
912 my $period = $form->{period};
915 $form->{period} = $period;
918 USTVA::error( $locale->text('Wrong Period' ));
922 my $tax_office = first { $_->{name} eq $form->{elsterland} } @{ $ustva->{tax_office_information} };
923 $form->{taxbird_land_nr} = $tax_office->{taxbird_nr} if $tax_office;
925 $form->{co_zip} = $form->{co_city};
926 $form->{co_zip} =~ s/\D//g;
927 $form->{co_city} =~ s/\d//g;
928 $form->{co_city} =~ s/^\s//g;
930 ($form->{co_phone_prefix}, $form->{co_phone}) = split("-", $form->{tel});
931 $form->{co_phone_prefix} =~ s/\s//g;
932 $form->{co_phone} =~ s/\s//g;
934 $form->{taxbird_steuernummer} = $form->{steuernummer};
935 # $form->{taxbird_steuernummer} =~ s/\D//g;
936 $form->{taxbird_steuernummer} =~ s/\///; # ersten Querstrich ersetzen
938 # Numberformatting for Taxbird
939 my $temp_numberformat = $myconfig{numberformat};
940 # Numberformat must be '1000,00' for Taxbird ?!
941 $myconfig{numberformat} = '1000,00';
942 foreach my $number (@category_cent) {
943 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '2', '') : '';
946 foreach my $number (@category_euro) {
947 $form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '0', '') : '';
949 # Re-set Numberformat
950 $myconfig{numberformat} = $temp_numberformat;
952 # push Kennziffern to <%foreach Array fo easyer
953 # output in xml format. Thx to Moritz.
954 my %taxbird_id_for = (
956 '511' => 'Kz51-calc',
957 '861' => 'Kz86-calc',
958 '971' => 'Kz97-calc',
959 '931' => 'Kz93-calc',
960 '811' => 'Kz81-calc',
961 '891' => 'Kz89-calc',
962 'Z45' => 'uebertrag',
964 'Z62' => 'ust-minus-vost',
965 'Z65' => 'ust-sum+69',
970 for my $kennziffer (@category_cent, @category_euro) {
972 next if ($kennziffer eq 'Z43');
974 if ($form->{$kennziffer} != 0){
975 if (defined $taxbird_id_for{$kennziffer}) {
976 push(@{ $form->{id}}, $taxbird_id_for{$kennziffer});
978 push(@{ $form->{id}}, "Kz$kennziffer");
980 push(@{ $form->{amount}}, $form->{$kennziffer});
984 } elsif ( $form->{format} eq '' ){ # No format error.
986 USTVA::error( $locale->text('Application Error. No Format given' ) . "!");
989 } else { # All other Formats are wrong
991 USTVA::error( $locale->text('Application Error. Wrong Format') . ": " . $form->{format} );
996 } else # Outputformat for generic output
999 my @category_cent = $ustva->report_variables({
1000 myconfig => \%myconfig,
1003 attribute => 'position',
1007 my @category_euro = $ustva->report_variables({
1008 myconfig => \%myconfig,
1011 attribute => 'position',
1015 $form->{USTVA} = [];
1017 if ( $form->{format} eq 'generic') { # Formatierungen für HTML Ausgabe
1020 for my $kennziffer (@category_cent, @category_euro) {
1022 $rec_ref->{id} = $kennziffer;
1023 $rec_ref->{amount} = $form->format_amount(\%myconfig, $form->{$kennziffer}, 2, '0');
1025 $lxdebug->message($LXDebug::DEBUG, "Kennziffer $kennziffer: '$form->{$kennziffer}'" );
1026 $lxdebug->dump($LXDebug::DEBUG, $rec_ref );
1027 push @ { $form->{USTVA} }, $rec_ref;
1034 if ( $form->{period} eq '13' and $form->{format} ne 'html') {
1038 'Yearly taxreport not yet implemented')
1042 $form->{templates} = $myconfig{templates};
1043 $form->{templates} = "doc" if ( $form->{type} eq 'help' );
1045 if ($form->{format} eq 'generic'){
1050 taxnumber => $myconfig{taxnumber},
1053 print($form->parse_html_template('ustva/generic_taxreport', $template_ref));
1058 $form->parse_template(\%myconfig, $userspath);
1062 $lxdebug->leave_sub();
1066 $lxdebug->enter_sub();
1068 $auth->assert('advance_turnover_tax_return');
1070 # edit all taxauthority prefs
1074 my $ustva = USTVA->new();
1075 $ustva->get_config($userspath, 'finanzamt.ini');
1077 my $land = $form->{elsterland};
1078 my $amt = $form->{elsterFFFF};
1081 $form->{title} = $locale->text('Tax Office Preferences');
1084 my $select_tax_office = $ustva->fa_auswahl($land, $amt, $ustva->query_finanzamt(\%myconfig, $form));
1085 my $checked_accrual = q|checked="checked"| if ($form->{method} eq 'accrual');
1086 my $checked_cash = q|checked="checked"| if ($form->{method} eq 'cash');
1087 my $checked_monthly = "checked" if ($form->{FA_voranmeld} eq 'month');
1088 my $checked_quarterly = "checked" if ($form->{FA_voranmeld} eq 'quarter');
1089 my $checked_dauerfristverlaengerung = "checked" if ($form->{FA_dauerfrist} eq '1');
1090 my $checked_kz_71 = "checked" if ($form->{FA_71} eq 'X');
1092 my $_hidden_variables_ref;
1094 my %_hidden_local_variables = (
1095 'saved' => $locale->text('Check Details'),
1096 'nextsub' => 'config_step2',
1100 foreach my $variable (keys %_hidden_local_variables) {
1101 push @{ $_hidden_variables_ref },
1102 { 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
1105 my @_hidden_form_variables = qw(
1106 FA_Name FA_Strasse FA_PLZ
1107 FA_Ort FA_Telefon FA_Fax
1108 FA_PLZ_Grosskunden FA_PLZ_Postfach FA_Postfach
1109 FA_BLZ_1 FA_Kontonummer_1 FA_Bankbezeichnung_1
1110 FA_BLZ_2 FA_Kontonummer_2 FA_Bankbezeichnung_oertlich
1111 FA_Oeffnungszeiten FA_Email FA_Internet
1112 steuernummer elsterland elstersteuernummer
1116 foreach my $variable (@_hidden_form_variables) {
1117 push @{ $_hidden_variables_ref},
1118 { 'variable' => $variable, 'value' => $form->{$variable} };
1121 # Which COA is in use?
1123 $ustva->get_coa($form, \%myconfig);
1126 my $steuernummer_new = '';
1128 # Variablen für das Template zur Verfügung stellen
1129 my $template_ref = {
1130 select_tax_office => $select_tax_office,
1131 checked_accrual => $checked_accrual,
1132 checked_cash => $checked_cash,
1133 checked_monthly => $checked_monthly,
1134 checked_quarterly => $checked_quarterly,
1135 checked_dauerfristverlaengerung => $checked_dauerfristverlaengerung,
1136 hidden_variables => $_hidden_variables_ref,
1140 # Ausgabe des Templates
1141 print($form->parse_html_template('ustva/config_step1', $template_ref));
1143 $lxdebug->leave_sub();
1147 $lxdebug->enter_sub();
1149 $auth->assert('advance_turnover_tax_return');
1157 my $elsterland = '';
1158 my $elster_amt = '';
1159 my $elsterFFFF = '';
1160 my $elstersteuernummer = '';
1162 my $ustva = USTVA->new();
1163 $ustva->get_config($userspath, 'finanzamt.ini')
1164 if ($form->{saved} eq $locale->text('saved'));
1166 # Auf Übergabefehler checken
1167 USTVA::info( $locale->text('Missing Tax Authoritys Preferences') . "\n"
1168 . $locale->text('USTVA-Hint: Tax Authoritys'))
1169 if ( $form->{elsterFFFF_new} eq 'Auswahl'
1170 || $form->{elsterland_new} eq 'Auswahl');
1171 USTVA::info( $locale->text('Missing Method!') . "\n"
1172 . $locale->text('USTVA-Hint: Method'))
1173 if ($form->{method} eq '');
1175 # Klären, ob Variablen bereits befüllt sind UND ob veräderungen auf
1176 # der vorherigen Maske stattfanden: $change = 1(in der edit sub,
1177 # mittels get_config)
1179 my $change = $form->{elsterland} eq $form->{elsterland_new}
1180 && $form->{elsterFFFF} eq $form->{elsterFFFF_new} ? '0' : '1';
1181 $change = '0' if ($form->{saved} eq $locale->text('saved'));
1182 my $elster_init = $ustva->query_finanzamt(\%myconfig, $form);
1184 my %elster_init = %$elster_init;
1186 if ($change eq '1') {
1189 $elsterland = $form->{elsterland_new};
1190 $elsterFFFF = $form->{elsterFFFF_new};
1191 $form->{elsterland} = $elsterland;
1192 $form->{elsterFFFF} = $elsterFFFF;
1193 $form->{steuernummer} = '';
1195 create_steuernummer();
1197 # rebuild elster_amt
1199 foreach $amt (keys %{ $elster_init{ $form->{elsterland} } }) {
1201 if ($elster_init{ $form->{elsterland}{$amt} eq $form->{elsterFFFF} });
1204 # load the predefined hash data into the FA_* Vars
1205 my @variables = qw(FA_Name FA_Strasse FA_PLZ FA_Ort
1206 FA_Telefon FA_Fax FA_PLZ_Grosskunden FA_PLZ_Postfach
1208 FA_BLZ_1 FA_Kontonummer_1 FA_Bankbezeichnung_1
1209 FA_BLZ_2 FA_Kontonummer_2 FA_Bankbezeichnung_oertlich
1210 FA_Oeffnungszeiten FA_Email FA_Internet);
1212 for (my $i = 0; $i <= 20; $i++) {
1213 $form->{ $variables[$i] } =
1214 $elster_init->{$elsterland}->{$elsterFFFF}->[$i];
1219 $elsterland = $form->{elsterland};
1220 $elsterFFFF = $form->{elsterFFFF};
1223 my $stnr = $form->{steuernummer};
1225 my $patterncount = $form->{patterncount};
1226 my $elster_pattern = $form->{elster_pattern};
1227 my $delimiter = $form->{delimiter};
1228 my $steuernummer = $form->{steuernummer} if ($steuernummer eq '');
1230 $form->{FA_Oeffnungszeiten} =~ s/\\\\n/\n/g;
1233 $ustva->get_coa($form, \%myconfig);
1235 my $input_steuernummer = $ustva->steuernummer_input(
1236 $form->{elsterland},
1237 $form->{elsterFFFF},
1238 $form->{steuernummer}
1241 $lxdebug->message(LXDebug::DEBUG1, qq|$input_steuernummer|);
1244 my $_hidden_variables_ref;
1246 my %_hidden_local_variables = (
1247 'elsterland' => $elsterland,
1248 'elsterFFFF' => $elsterFFFF,
1249 'warnung' => $warnung,
1250 'elstersteuernummer' => $elstersteuernummer,
1251 'steuernummer' => $stnr,
1252 'lastsub' => 'config_step1',
1253 'nextsub' => 'save',
1257 foreach my $variable (keys %_hidden_local_variables) {
1258 push @{ $_hidden_variables_ref },
1259 { 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
1262 my @_hidden_form_variables = qw(
1263 FA_steuerberater_name FA_steuerberater_street
1264 FA_steuerberater_city FA_steuerberater_tel
1272 foreach my $variable (@_hidden_form_variables) {
1273 push @{ $_hidden_variables_ref},
1274 { 'variable' => $variable, 'value' => $form->{$variable} };
1277 my $template_ref = {
1278 tax_office_data => $tax_office_data,
1279 input_steuernummer => $input_steuernummer,
1280 readonly => '', #q|disabled="disabled"|,
1281 callback => $callback,
1282 hidden_variables => $_hidden_variables_ref,
1285 # Ausgabe des Templates
1286 print($form->parse_html_template('ustva/config_step2', $template_ref));
1289 $lxdebug->leave_sub();
1292 sub create_steuernummer {
1293 $lxdebug->enter_sub();
1295 $auth->assert('advance_turnover_tax_return');
1297 my $part = $form->{part};
1298 my $patterncount = $form->{patterncount};
1299 my $delimiter = $form->{delimiter};
1300 my $elster_pattern = $form->{elster_pattern};
1302 # rebuild steuernummer and elstersteuernummer
1303 # es gibt eine gespeicherte steuernummer $form->{steuernummer}
1304 # und die parts und delimiter
1309 my $steuernummer_new = $part;
1310 my $elstersteuernummer_new = $form->{elster_FFFF};
1311 $elstersteuernummer_new .= '0';
1313 for ($h = 1; $h < $patterncount; $h++) {
1314 $steuernummer_new .= qq|$delimiter|;
1315 for (my $i = 1; $i <= length($elster_pattern); $i++) {
1316 $steuernummer_new .= $form->{"part_$h\_$i"};
1317 $elstersteuernummer_new .= $form->{"part_$h\_$i"};
1320 if ($form->{steuernummer} ne $steuernummer_new) {
1321 $form->{steuernummer} = $steuernummer_new;
1322 $form->{elstersteuernummer} = $elstersteuernummer_new;
1323 $form->{steuernummer_new} = $steuernummer_new;
1325 $form->{steuernummer_new} = '';
1326 $form->{elstersteuernummer_new} = '';
1328 $lxdebug->leave_sub();
1332 $lxdebug->enter_sub();
1334 $auth->assert('advance_turnover_tax_return');
1336 my $filename = "$form->{login}_$form->{filename}";
1337 $filename =~ s|.*/||;
1339 #zuerst die steuernummer aus den part, parts_X_Y und delimiter herstellen
1340 create_steuernummer();
1342 # Textboxen formatieren: Linebreaks entfernen
1344 $form->{FA_Oeffnungszeiten} =~ s/\r\n/\\n/g;
1346 #URL mit http:// davor?
1347 $form->{FA_Internet} =~ s/^http:\/\///;
1348 $form->{FA_Internet} = 'http://' . $form->{FA_Internet};
1351 elster elsterland elstersteuernummer steuernummer
1352 elsteramt elsterFFFF FA_Name FA_Strasse
1353 FA_PLZ FA_Ort FA_Telefon FA_Fax
1354 FA_PLZ_Grosskunden FA_PLZ_Postfach FA_Postfach FA_BLZ_1
1355 FA_Kontonummer_1 FA_Bankbezeichnung_1 FA_BLZ_2 FA_Kontonummer_2
1356 FA_Bankbezeichnung_oertlich FA_Oeffnungszeiten
1357 FA_Email FA_Internet FA_voranmeld method FA_steuerberater_name
1358 FA_steuerberater_street FA_steuerberater_city FA_steuerberater_tel
1359 FA_71 FA_dauerfrist);
1361 # Hier kommt dann die Plausibilitätsprüfung der ELSTERSteuernummer
1362 if ($form->{elstersteuernummer} ne '000000000') {
1364 $form->{elster} = '1';
1366 open my $ustvaconfig, ">", "$userspath/$filename" or $form->error("$filename : $!");
1368 # create the config file
1369 print {$ustvaconfig} qq|# Configuration file for USTVA\n\n|;
1371 foreach $key (sort @config) {
1372 $form->{$key} =~ s/\\/\\\\/g;
1374 $form->{$key} =~ s/\r\n/\n/g;
1376 print {$ustvaconfig} qq|$key=|;
1377 if ($form->{$key} ne 'Y') {
1378 print {$ustvaconfig} qq|$form->{$key}\n|;
1380 if ($form->{$key} eq 'Y') {
1381 print {$ustvaconfig} qq|checked \n|;
1384 print {$ustvaconfig} qq|\n\n|;
1386 $form->{saved} = $locale->text('saved');
1390 $form->{saved} = $locale->text('Choose a Tax Number');
1394 $lxdebug->leave_sub();
1399 $lxdebug->enter_sub();
1401 # allow Symbolic references just here:
1403 call_sub($form->{"nextsub"});
1405 $lxdebug->leave_sub();
1409 $lxdebug->enter_sub();
1410 call_sub($form->{"lastsub"});
1411 $lxdebug->leave_sub();