1 #=====================================================================
3 # Copyright (c) 2004 by Udo Spallek, Aachen
7 # Web: http://www.lx-office.org
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23 #======================================================================
24 # German Tax authority Module and later ELSTER Interface
25 # 08.01.14 ELSTER Interface software (taxbird/winston) removed
26 #======================================================================
31 require "bin/mozilla/common.pl";
36 #use warnings; # FATAL=> 'all';
37 #use vars qw($locale $form %myconfig);
39 #use CGI::Carp "fatalsToBrowser";
41 use List::Util qw(first);
50 # this is for our long dates
51 # $locale->text('January')
52 # $locale->text('February')
53 # $locale->text('March')
54 # $locale->text('April')
55 # $locale->text('May ')
56 # $locale->text('June')
57 # $locale->text('July')
58 # $locale->text('August')
59 # $locale->text('September')
60 # $locale->text('October')
61 # $locale->text('November')
62 # $locale->text('December')
64 # this is for our short month
65 # $locale->text('Jan')
66 # $locale->text('Feb')
67 # $locale->text('Mar')
68 # $locale->text('Apr')
69 # $locale->text('May')
70 # $locale->text('Jun')
71 # $locale->text('Jul')
72 # $locale->text('Aug')
73 # $locale->text('Sep')
74 # $locale->text('Oct')
75 # $locale->text('Nov')
76 # $locale->text('Dec')
78 #############################
81 $::lxdebug->enter_sub();
84 my $locale = $::locale;
85 my %myconfig = %::myconfig;
87 $::auth->assert('advance_turnover_tax_return');
89 my $defaults = SL::DB::Default->get;
90 $form->{title} = $locale->text('UStVA');
91 $form->{kz10} = ''; #Berichtigte Anmeldung? Ja =1 Nein=0
93 my $year = substr($form->datetonum($form->current_date(\%myconfig), \%myconfig ),
100 # Einlesen der Finanzamtdaten
101 my $ustva = USTVA->new();
102 $ustva->get_config();
103 $ustva->get_finanzamt();
105 my $geierlein_enabled = 0;
106 my $geierlein_path = $::lx_office_conf{paths}{geierlein_path};
108 if ( $geierlein_path && length($geierlein_path) > 0 ) {$geierlein_enabled=1;}
110 # $::lxdebug->message(LXDebug->DEBUG2,"geierlein_enabled=".$geierlein_enabled." path=".$geierlein_path);
111 # Hier Einlesen der user-config
112 # steuernummer entfernt für prerelease
115 tel fax email co_chief co_department
116 co_custom1 co_custom2 co_custom3 co_custom4 co_custom5
117 co_name1 co_name2 co_street co_street1 co_zip
118 co_city co_city1 co_country co_tel co_tel1
119 co_tel2 co_fax co_fax1 co_email co_email1
120 co_url co_url1 co_bankname
121 co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1
122 co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2
126 $form->{$_} = $myconfig{$_} for @a;
128 my $openings = $form->{fa_oeffnungszeiten};
129 $openings =~ s/\\\\n/<br>/g;
131 my $company_given = ($form->{company} ne '')
132 ? qq|<h3>$form->{company}</h3>\n|
133 : qq|<a href="controller.pl?action=ClientConfig/edit">|
134 . $locale->text('No Company Name given') . qq|!</a><br>|;
137 # Anpassungen der Variablennamen auf pre 2.1.1 Namen
138 # klären, ob $form->{company_street|_address} gesetzt sind
139 if ($form->{address} ne '') {
140 my $temp = $form->{address};
141 $temp =~ s/\n/<br \/>/;
142 ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp);
143 $form->{co_city} =~ s/\n//g;
148 ($form->{co_street} && ($form->{co_zip} || $form->{co_city}))
149 ? qq|$form->{co_street}<br>|
150 . qq|$form->{co_street1}<br>|
151 . qq|$form->{co_zip} $form->{co_city}|
152 : qq|<a href="controller.pl?action=ClientConfig/edit">|
153 . $locale->text('No Company Address given')
156 $form->{co_email} = $form->{email} unless $form->{co_email};
157 $form->{co_tel} = $form->{tel} unless $form->{co_tel};
158 $form->{co_fax} = $form->{fax} unless $form->{co_fax};
159 $form->{co_url} = $form->{urlx} unless $form->{co_url};
161 my $taxnumber_given = ($form->{taxnumber} ne '') ? $form->{taxnumber} : qq|<a href="ustva.pl?action=config_step1">Keine Steuernummer hinterlegt!</a><br>|;
162 my $fa_name_given = ($form->{fa_name} ne '') ? $form->{fa_name} : qq|<a href="ustva.pl?action=config_step1">Kein Finanzamt hinterlegt!</a><br>|;
163 my $ustva_vorauswahl = &ustva_vorauswahl();
165 my @all_years = $form->all_years(\%myconfig);
167 my $select_year = qq|<select name=year title="|
168 . $locale->text('Year') . qq|">|;
169 foreach my $key (@all_years) {
170 $select_year .= qq|<option |;
171 $select_year .= qq|selected| if ($key eq $form->{year});
172 $select_year .= qq| >$key</option>|;
174 $select_year .= qq|</select>|;
177 $_checked = "checked" if ($form->{kz10} eq '1');
178 my $checkbox_kz_10 = qq|<input name="FA_10" id=FA_10 class=checkbox|
179 . qq| type=checkbox value="1" $_checked title = "|
180 . $locale->text('Amended Advance Turnover Tax Return').'(Nr. 10)'
182 . $locale->text('Amended Advance Turnover Tax Return');
184 $_checked = "checked" if ($form->{kz22} eq '1');
185 my $checkbox_kz_22 = qq|<input name="FA_22" id=FA_22 class=checkbox|
186 . qq| type=checkbox value="1" $_checked title = "|
187 . $locale->text('Receipts attached/extra').'(Nr. 22)'
189 . $locale->text('Receipts attached/extra');
191 $_checked = "checked" if ($form->{kz29} eq '1');
192 my $checkbox_kz_29 = qq|<input name="FA_29" id=FA_29 class=checkbox|
193 . qq| type=checkbox value="1" $_checked title = "|
194 . $locale->text('Accounting desired').'(Nr. 29)'
196 . $locale->text('Accounting desired');
198 $_checked = "checked" if ($form->{kz26} eq '1');
199 my $checkbox_kz_26 = qq|<input name="FA_26" id=FA_26 class=checkbox|
200 . qq| type=checkbox value="1" $_checked title = "|
201 . $locale->text('Direct debit revoked').'(Nr. 26)'
203 . $locale->text('Direct debit revoked');
205 my $method_local = ($form->{accounting_method} eq 'accrual') ? $locale->text('accrual')
206 : ($form->{accounting_method} eq 'cash') ? $locale->text('cash')
209 my $period_local = ( $form->{fa_voranmeld} eq 'month') ? $locale->text('month')
210 : ( $form->{fa_voranmeld} eq 'quarter') ? $locale->text('quarter')
213 my @tax_office_banks_ref = (
214 { BLZ => $form->{fa_blz_1},
215 Kontonummer => $form->{fa_kontonummer_1},
216 Bankbezeichnung => $form->{fa_bankbezeichnung_1}
218 { BLZ => $form->{fa_blz_2},
219 Kontonummer => $form->{fa_kontonummer_2},
220 Bankbezeichnung => $form->{fa_bankbezeichnung_2}
224 $ustva->get_coa($form); # fetches coa and modifies some form variables
227 openings => $openings,
228 company_given => $company_given,
229 address_given => $address_given,
230 taxnumber_given => $taxnumber_given,
231 fa_name_given => $fa_name_given,
232 taxnumber => $defaults->taxnumber,
233 select_year => $select_year,
234 period_local => $period_local,
235 method_local => $method_local,
236 ustva_vorauswahl => $ustva_vorauswahl,
237 checkbox_kz_10 => $checkbox_kz_10,
238 checkbox_kz_22 => $checkbox_kz_22,
239 checkbox_kz_29 => $checkbox_kz_29,
240 checkbox_kz_26 => $checkbox_kz_26,
241 tax_office_banks => \@tax_office_banks_ref,
242 geierlein_enabled => $geierlein_enabled,
243 geierlein_path => $geierlein_path,
244 select_options => &show_options,
248 print($form->parse_html_template('ustva/report', $template_ref));
252 $::lxdebug->leave_sub();
258 $::lxdebug->enter_sub();
260 $::auth->assert('advance_turnover_tax_return');
262 # parse help documents under doc
263 $::form->{templates} = 'doc';
264 $::form->{help} = 'ustva';
265 $::form->{type} = 'help';
266 $::form->{format} = 'html';
269 $::lxdebug->leave_sub();
273 $::lxdebug->enter_sub();
275 $::auth->assert('advance_turnover_tax_return');
278 $::lxdebug->leave_sub();
279 call_sub($::form->{"nextsub"});
282 sub ustva_vorauswahl {
283 $::lxdebug->enter_sub();
286 my $locale = $::locale;
287 my %myconfig = %::myconfig;
289 $::auth->assert('advance_turnover_tax_return');
291 my $select_vorauswahl;
293 #Aktuelles Datum zerlegen:
294 my $date = $form->datetonum($form->current_date(\%myconfig), \%myconfig);
296 #$locale->date($myconfig, $form->current_date($myconfig), 0)=~ /(\d\d).(\d\d).(\d\d\d\d)/;
297 $form->{day} = substr($date, 6, 2);
298 $form->{month} = substr($date, 4, 2);
299 $form->{year} = substr($date, 0, 4);
300 $::lxdebug->message(LXDebug->DEBUG1, qq|
301 Actual date from Database: $date\n
302 Actual year from Database: $form->{year}\n
303 Actual day from Database: $form->{day}\n
304 Actual month from Database: $form->{month}\n|);
309 # Testdaten erzeugen:
311 #$form->{month}= '01';
312 #$form->{year}= 2004;
313 $select_vorauswahl = qq|
314 <input type="hidden" name="day" value="$form->{day}">
315 <input type="hidden" name="month" value="$form->{month}">
316 <input type="hidden" name="yymmdd" value="$yymmdd">
317 <input type="hidden" name="sel" value="$sel">
320 if ($form->{fa_voranmeld} eq 'month') {
322 # Vorauswahl bei monatlichem Voranmeldungszeitraum
324 my %liste = ('01' => $locale->text('January'),
325 '02' => $locale->text('February'),
326 '03' => $locale->text('March'),
327 '04' => $locale->text('April'),
328 '05' => $locale->text('May'),
329 '06' => $locale->text('June'),
330 '07' => $locale->text('July'),
331 '08' => $locale->text('August'),
332 '09' => $locale->text('September'),
333 '10' => $locale->text('October'),
334 '11' => $locale->text('November'),
335 '12' => $locale->text('December'),
336 '13' => $locale->text('Yearly'),
339 my $yy = $form->{year} * 10000;
340 $yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
344 # Offset für Dauerfristverlängerung
345 $dfv = '100' if ($form->{fa_dauerfrist} eq '1');
348 $yymmdd <= ($yy + 110 + $dfv) && do {
349 $form->{year} = $form->{year} - 1;
353 $yymmdd <= ($yy + 210 + $dfv) && do {
357 $yymmdd <= ($yy + 310 + $dfv) && do {
361 $yymmdd <= ($yy + 410 + $dfv) && do {
365 $yymmdd <= ($yy + 510 + $dfv) && do {
369 $yymmdd <= ($yy + 610 + $dfv) && do {
373 $yymmdd <= ($yy + 710 + $dfv) && do {
377 $yymmdd <= ($yy + 810 + $dfv) && do {
381 $yymmdd <= ($yy + 910 + $dfv) && do {
385 $yymmdd <= ($yy + 1010 + $dfv) && do {
389 $yymmdd <= ($yy + 1110 + $dfv) && do {
393 $yymmdd <= ($yy + 1210) && do {
397 $yymmdd <= ($yy + 1231) && do {
403 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
404 . $locale->text('Select a period') . qq|" >|;
407 foreach $key (sort keys %liste) {
409 $selected = 'selected' if ($sel eq $key);
410 $select_vorauswahl .= qq|
411 <option value="$key" $selected> $liste{$key}</option>
414 $select_vorauswahl .= qq|</select>|;
416 } elsif ($form->{fa_voranmeld} eq 'quarter') {
418 # Vorauswahl bei quartalsweisem Voranmeldungszeitraum
419 my %liste = ('41' => $locale->text('1. Quarter'),
420 '42' => $locale->text('2. Quarter'),
421 '43' => $locale->text('3. Quarter'),
422 '44' => $locale->text('4. Quarter'),
423 '13' => $locale->text('Yearly'),);
425 my $yy = $form->{year} * 10000;
426 $yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
428 my $dfv = ''; # Offset für Dauerfristverlängerung
429 $dfv = '100' if ($form->{fa_dauerfrist} eq '1');
432 $yymmdd <= ($yy + 110 + $dfv) && do {
433 $form->{year} = $form->{year} - 1;
437 $yymmdd <= ($yy + 410 + $dfv) && do {
441 $yymmdd <= ($yy + 710 + $dfv) && do {
445 $yymmdd <= ($yy + 1010 + $dfv) && do {
449 $yymmdd <= ($yy + 1231) && do {
454 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
455 . $locale->text('Select a period') . qq|" >|;
457 foreach $key (sort keys %liste) {
459 $selected = 'selected' if ($sel eq $key);
460 $select_vorauswahl .= qq|
461 <option value="$key" $selected>$liste{$key}</option>
464 $select_vorauswahl .= qq|\n</select>
469 # keine Vorauswahl bei Voranmeldungszeitraum
470 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
471 . $locale->text('Select a period') . qq|" >|;
473 my %listea = ('41' => '1. Quarter',
474 '42' => '2. Quarter',
475 '43' => '3. Quarter',
476 '44' => '4. Quarter',);
478 my %listeb = ('01' => 'January',
492 foreach $key (sort keys %listea) {
493 $select_vorauswahl .= qq|
494 <option value="$key">|
495 . $locale->text("$listea{$key}")
499 foreach $key (sort keys %listeb) {
500 $select_vorauswahl .= qq|
501 <option value="$key">|
502 . $locale->text("$listeb{$key}")
505 $select_vorauswahl .= qq|</select>|;
507 $::lxdebug->leave_sub();
509 return $select_vorauswahl;
513 # $::lxdebug->enter_sub();
515 # $::lxdebug->leave_sub();
519 $::lxdebug->enter_sub();
521 $::lxdebug->leave_sub();
525 $::lxdebug->enter_sub();
527 $::auth->assert('advance_turnover_tax_return');
529 # $form->{PD}{$form->{type}} = "selected";
530 # $form->{DF}{$form->{format}} = "selected";
531 # $form->{OP}{$form->{media}} = "selected";
532 # $form->{SM}{$form->{sendmode}} = "selected";
533 my $type = qq| <input type=hidden name="type" value="ustva">|;
534 my $media = qq| <input type=hidden name="media" value="screen">|;
536 qq| <option value=html selected>|
537 . $::locale->text('HTML')
540 #my $disabled= qq|disabled="disabled"|;
541 #$disabled='' if ($form->{elster} eq '1' );
542 #if ($::form->{elster} eq '1') {
545 qq|<option value=elstertaxbird>|
546 . $::locale->text('ELSTER Export (via Geierlein)')
550 my $show_options = qq|
553 <select name=format title = "|
554 . $::locale->text('Choose Outputformat') . qq|">$format</select>
556 $::lxdebug->leave_sub();
558 return $show_options;
562 $::lxdebug->enter_sub();
565 my $locale = $::locale;
566 my %myconfig = %::myconfig;
568 $::auth->assert('advance_turnover_tax_return');
570 my $defaults = SL::DB::Default->get;
571 $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates;
572 $form->{templates} = $defaults->templates;
575 my $ustva = USTVA->new();
576 $ustva->get_config();
577 $ustva->get_finanzamt();
579 # Setze Anmeldungszeitraum
581 $ustva->set_FromTo(\%$form);
584 $ustva->ustva(\%myconfig, \%$form);
586 # reformat Dates to dateformat
587 $form->{fromdate} = $locale->date(\%myconfig, $form->{fromdate}, 0, 0, 0);
589 $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
590 $form->{todate} = $locale->date(\%myconfig, $form->{todate}, 0, 0, 0);
592 $form->{longperiod} =
593 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1, 0, 0);
595 # if there are any dates construct a where
596 if ($form->{fromdate} || $form->{todate}) {
598 $form->{todate} = $form->current_date(\%myconfig) unless ($form->{todate});
600 my $longtodate = $locale->date(\%myconfig, $form->{todate}, 1, 0, 0);
601 my $shorttodate = $locale->date(\%myconfig, $form->{todate}, 0, 0, 0);
603 my $longfromdate = $locale->date(\%myconfig, $form->{fromdate}, 1, 0, 0);
604 my $shortfromdate = $locale->date(\%myconfig, $form->{fromdate}, 0, 0, 0);
606 $form->{this_period} = "$shortfromdate<br>\n$shorttodate";
607 $form->{longperiod} =
608 $locale->text('for Period')
609 . qq|<br>\n$longfromdate |
610 . $locale->text('to (date)')
614 if ($form->{comparefromdate} || $form->{comparetodate}) {
615 my $longcomparefromdate =
616 $locale->date(\%myconfig, $form->{comparefromdate}, 1, 0, 0);
617 my $shortcomparefromdate =
618 $locale->date(\%myconfig, $form->{comparefromdate}, 0, 0, 0);
620 my $longcomparetodate =
621 $locale->date(\%myconfig, $form->{comparetodate}, 1, 0, 0);
622 my $shortcomparetodate =
623 $locale->date(\%myconfig, $form->{comparetodate}, 0, 0, 0);
625 $form->{last_period} = "$shortcomparefromdate<br>\n$shortcomparetodate";
626 $form->{longperiod} .=
627 "<br>\n$longcomparefromdate "
628 . $locale->text('to (date)')
629 . qq| $longcomparetodate|;
632 $form->{Datum_heute} =
633 $locale->date(\%myconfig, $form->current_date(\%myconfig), 0, 0, 0);
635 # setup variables for the form
636 my @a = qw(tel fax email
637 co_chief co_department co_custom1 co_custom2 co_custom3 co_custom4 co_custom5
638 co_name1 co_name2 co_street co_street1 co_zip co_city co_city1 co_country co_tel co_tel1 co_tel2
639 co_fax co_fax1 co_email co_email1 co_url co_url1
640 co_bankname co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1
641 co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2 co_accountnr3);
643 $form->{$_} = $myconfig{$_} for @a;
644 $form->{$_} = $defaults->$_ for qw(company address co_ustid duns);
646 if ($form->{address} ne '') {
647 my $temp = $form->{address};
648 $temp =~ s/\n/<br \/>/;
649 ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp,2);
650 $form->{co_city} =~ s/\\n//g;
653 ################################
655 # Nation specific customisations
657 ################################
661 if ( $form->{coa} eq 'Germany-DATEV-SKR03EU' or $form->{coa} eq 'Germany-DATEV-SKR04EU') {
664 $form->{amount} = [];
666 if ( $form->{format} eq 'pdf' or $form->{format} eq 'postscript') {
668 $form->{IN} = "$form->{type}-$form->{year}.tex";
669 $form->{padding} = "~~";
670 $form->{bold} = "\textbf{";
671 $form->{endbold} = "}";
672 $form->{br} = '\\\\';
674 # Zahlenformatierung für Latex USTVA Formulare
676 foreach my $number (@{$::form->{category_euro}}) {
677 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '');
680 my ${decimal_comma} = ( $myconfig{numberformat} eq '1.000,00'
681 or $myconfig{numberformat} eq '1000,00' ) ? ',':'.';
683 foreach my $number (@{$::form->{category_cent}}) {
684 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '');
685 $form->{$number} =~ s/${decimal_comma}/~~/g;
688 } elsif ( $form->{format} eq 'html') { # Formatierungen für HTML Ausgabe
690 $form->{IN} = $form->{type} . '.html';
691 $form->{padding} = " ";
692 $form->{bold} = "<b>";
693 $form->{endbold} = "</b>";
694 $form->{br} = "<br>";
695 $form->{address} =~ s/\\n/\n/g;
697 foreach my $number (@{$::form->{category_cent}}) {
698 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '0');
701 foreach my $number (@{$::form->{category_euro}}) {
702 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '0');
704 } elsif ( $form->{format} eq '' ){ # No format error.
707 USTVA::error( $locale->text('Application Error. No Format given' ) . "!");
708 $::dispatcher->end_request;
710 } else { # All other Formats are wrong
712 USTVA::error( $locale->text('Application Error. Wrong Format') . ": " . $form->{format} );
713 $::dispatcher->end_request;
717 } else # Outputformat for generic output
722 if ( $form->{format} eq 'generic') { # Formatierungen für HTML Ausgabe
725 for my $kennziffer (@{$::form->{category_cent}}, @{$::form->{category_euro}}) {
727 $rec_ref->{id} = $kennziffer;
728 $rec_ref->{amount} = $form->format_amount(\%myconfig, $form->{$kennziffer}, 2, '0');
730 $::lxdebug->message($LXDebug::DEBUG, "Kennziffer $kennziffer: '$form->{$kennziffer}'" );
731 $::lxdebug->dump($LXDebug::DEBUG, $rec_ref );
732 push @ { $form->{USTVA} }, $rec_ref;
739 if ( $form->{period} eq '13' and $form->{format} ne 'html') {
743 'Yearly taxreport not yet implemented')
747 $form->{templates} = "doc" if ( $form->{type} eq 'help' );
749 if ($form->{format} eq 'generic'){
754 taxnumber => $defaults->taxnumber,
757 print($form->parse_html_template('ustva/generic_taxreport', $template_ref));
759 } elsif ( $form->{format} eq 'elstertaxbird' ) {
760 $form->parse_template(\%myconfig);
763 # add a prefix for ustva pos numbers, i.e.: 81 -> post_ustva_81
764 $form->{"pos_ustva_$_"} = $form->{$_} for grep { m{^\d+} } keys %{ $form };
765 $form->{title} = $locale->text('Advance turnover tax return');
768 print $form->parse_html_template('ustva/ustva');
773 $::lxdebug->leave_sub();
777 $::lxdebug->enter_sub();
779 $::auth->assert('advance_turnover_tax_return');
781 $::form->{title} = $::locale->text('Tax Office Preferences');
783 # edit all taxauthority prefs
787 my $ustva = USTVA->new();
788 $ustva->get_config();
789 $ustva->get_finanzamt();
791 my $land = $::form->{fa_land_nr};
792 my $amt = $::form->{fa_bufa_nr};
795 $::form->{title} = $::locale->text('Tax Office Preferences');
798 my $select_tax_office = $ustva->fa_auswahl($land, $amt, $ustva->query_finanzamt(\%::myconfig, $::form));
799 my $method_local = ($::form->{accounting_method} eq 'accrual') ? $::locale->text('accrual')
800 : ($::form->{accounting_method} eq 'cash') ? $::locale->text('cash')
803 my $checked_monthly = $::form->{fa_voranmeld} eq 'month' ? "checked" : '';
804 my $checked_quarterly = $::form->{fa_voranmeld} eq 'quarter' ? "checked" : '';
805 my $checked_dauerfristverlaengerung = $::form->{da_dauerfrist} eq '1' ? "checked" : '';
807 my $_hidden_variables_ref;
809 my %_hidden_local_variables = (
810 'saved' => $::locale->text('Check Details'),
811 'nextsub' => 'config_step2',
815 foreach my $variable (keys %_hidden_local_variables) {
816 push @{ $_hidden_variables_ref },
817 { 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
820 my @_hidden_form_variables = $ustva->get_fiamt_vars();
821 push @_hidden_form_variables ,qw(fa_bufa_nr taxnumber accounting_method coa);
823 foreach my $variable (@_hidden_form_variables) {
824 push @{ $_hidden_variables_ref},
825 { 'variable' => $variable, 'value' => $::form->{$variable} };
828 $ustva->get_coa($::form); # fetches coa and modifies some form variables
830 # Variablen für das Template zur Verfügung stellen
832 select_tax_office => $select_tax_office,
833 method_local => $method_local,
834 checked_monthly => $checked_monthly,
835 checked_quarterly => $checked_quarterly,
836 checked_dauerfristverlaengerung => $checked_dauerfristverlaengerung,
837 hidden_variables => $_hidden_variables_ref,
841 # Ausgabe des Templates
842 print($::form->parse_html_template('ustva/config_step1', $template_ref));
844 $::lxdebug->leave_sub();
848 $::lxdebug->enter_sub();
851 my $locale = $::locale;
852 my %myconfig = %::myconfig;
854 $::auth->assert('advance_turnover_tax_return');
861 my $ustva = USTVA->new();
862 $ustva->get_config() if ($form->{saved} eq $locale->text('saved'));
863 my $coa = $::form->{coa};
864 $form->{"COA_$coa"} = '1';
865 $form->{COA_Germany} = '1' if ($coa =~ m/^germany/i);
866 $ustva->get_finanzamt();
869 # Auf Übergabefehler checken
870 USTVA::info( $locale->text('Missing Tax Authoritys Preferences') . "\n"
871 . $locale->text('USTVA-Hint: Tax Authoritys'))
872 if ( $form->{fa_bufa_nr_new} eq 'Auswahl'
873 || $form->{fa_land_nr_new} eq 'Auswahl');
874 USTVA::info( $locale->text('Missing Method!') . "\n"
875 . $locale->text('USTVA-Hint: Method'))
876 if ($form->{accounting_method} eq '');
878 # Klären, ob Variablen bereits befüllt sind UND ob veränderungen auf
879 # der vorherigen Maske stattfanden: $change = 1(in der edit sub,
880 # mittels get_config)
882 # $::lxdebug->message(LXDebug->DEBUG2,"land old=".$form->{fa_land_nr}." new=".$form->{fa_land_nr_new});
883 # $::lxdebug->message(LXDebug->DEBUG2,"bufa old=".$form->{fa_bufa_nr}." new=".$form->{fa_bufa_nr_new});
884 my $change = $form->{fa_land_nr} eq $form->{fa_land_nr_new}
885 && $form->{fa_bufa_nr} eq $form->{fa_bufa_nr_new} ? '0' : '1';
886 $change = '0' if ($form->{saved} eq $locale->text('saved'));
889 if ($change eq '1') {
892 $fa_land_nr = $form->{fa_land_nr_new};
893 $fa_bufa_nr = $form->{fa_bufa_nr_new};
894 $form->{fa_land_nr} = $fa_land_nr;
895 $form->{fa_bufa_nr} = $fa_bufa_nr;
896 $form->{taxnumber} = '';
898 create_steuernummer();
901 $ustva->get_finanzamt();
905 $fa_land_nr = $form->{fa_land_nr};
906 $fa_bufa_nr = $form->{fa_bufa_nr};
909 # $::lxdebug->message(LXDebug->DEBUG2, "form stnr=".$form->{taxnumber}." fa_bufa_nr=".$fa_bufa_nr.
910 # " pattern=".$form->{elster_pattern}." fa_land_nr=".$fa_land_nr);
911 my $stnr = $form->{taxnumber};
913 my $taxnumber = $stnr eq '' ? $form->{taxnumber} : '';
915 $form->{fa_oeffnungszeiten} =~ s/\\\\n/\n/g;
918 $ustva->get_coa($form); # fetches coa and modifies some form variables
920 my $input_steuernummer = $ustva->steuernummer_input(
926 # $::lxdebug->message(LXDebug->DEBUG2, qq|$input_steuernummer|);
929 my $_hidden_variables_ref;
931 my %_hidden_local_variables = (
932 'fa_land_nr' => $fa_land_nr,
933 'fa_bufa_nr' => $fa_bufa_nr,
935 'taxnumber' => $stnr,
936 'lastsub' => 'config_step1',
941 foreach my $variable (keys %_hidden_local_variables) {
942 push @{ $_hidden_variables_ref },
943 { 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
946 my @_hidden_form_variables = qw(
947 fa_dauerfrist fa_steuerberater_city fa_steuerberater_name
948 fa_steuerberater_street fa_steuerberater_tel
949 fa_voranmeld fa_dauerfrist
955 foreach my $variable (@_hidden_form_variables) {
956 push @{ $_hidden_variables_ref},
957 { 'variable' => $variable, 'value' => $form->{$variable} };
961 input_steuernummer => $input_steuernummer,
962 readonly => '', #q|disabled="disabled"|,
963 callback => $form->{callback},
964 COA_Germany => $form->{COA_Germany},
965 hidden_variables => $_hidden_variables_ref,
968 # Ausgabe des Templates
969 print($form->parse_html_template('ustva/config_step2', $template_ref));
972 $::lxdebug->leave_sub();
975 sub create_steuernummer {
976 $::lxdebug->enter_sub();
978 $::auth->assert('advance_turnover_tax_return');
980 my $part = $::form->{part};
981 my $patterncount = $::form->{patterncount};
982 my $delimiter = $::form->{delimiter1};
983 my $elster_pattern = $::form->{elster_pattern};
986 # es gibt eine gespeicherte steuernummer $form->{taxnumber}
987 # und die parts und delimiter
992 my $taxnumber_new = $part;
994 for ($h = 1; $h < $patterncount; $h++) {
995 $delimiter = $::form->{delimiter2} if $h > 1;
996 $taxnumber_new .= qq|$delimiter|;
997 for (my $i = 1; $i <= length($elster_pattern); $i++) {
998 $taxnumber_new .= $::form->{"part_$h\_$i"};
1001 # $::lxdebug->message(LXDebug->DEBUG2, "oldstnr=".$::form->{taxnumber}." newstnr=".$taxnumber_new);
1002 if ($::form->{taxnumber} ne $taxnumber_new) {
1003 $::form->{taxnumber} = $taxnumber_new;
1004 $::form->{taxnumber_new} = $taxnumber_new;
1006 $::form->{taxnumber_new} = '';
1008 $::lxdebug->leave_sub();
1012 $::lxdebug->enter_sub();
1014 $::auth->assert('advance_turnover_tax_return');
1016 #zuerst die steuernummer aus den part, parts_X_Y und delimiter herstellen
1017 create_steuernummer();
1019 # Textboxen formatieren: Linebreaks entfernen
1021 $::form->{fa_oeffnungszeiten} =~ s/\r\n/\\n/g;
1023 #URL mit http:// davor?
1024 $::form->{fa_internet} =~ s/^http:\/\///;
1025 $::form->{fa_internet} = 'http://' . $::form->{fa_internet};
1027 # Hier kommt dann die Plausibilitätsprüfung der ELSTERSteuernummer TODO ??
1029 my $ustva = USTVA->new();
1030 $ustva->save_config();
1032 #$::form->{elster} = '1';
1033 $::form->{saved} = $::locale->text('saved');
1037 $::form->{saved} = $::locale->text('Choose a Tax Number');
1041 $::lxdebug->leave_sub();
1046 $::lxdebug->enter_sub();
1048 # allow Symbolic references just here:
1049 call_sub($::form->{"nextsub"});
1050 $::lxdebug->leave_sub();
1054 $::lxdebug->enter_sub();
1055 call_sub($::form->{"lastsub"});
1056 $::lxdebug->leave_sub();