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);
47 use SL::Locale::String qw(t8);
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 ),
99 setup_ustva_report_action_bar();
102 # Einlesen der Finanzamtdaten
103 my $ustva = USTVA->new();
104 $ustva->get_config();
105 $ustva->get_finanzamt();
107 # Hier Einlesen der user-config
108 # steuernummer entfernt für prerelease
111 tel fax email co_chief co_department
112 co_custom1 co_custom2 co_custom3 co_custom4 co_custom5
113 co_name1 co_name2 co_street co_street1 co_zip
114 co_city co_city1 co_country co_tel co_tel1
115 co_tel2 co_fax co_fax1 co_email co_email1
116 co_url co_url1 co_bankname
117 co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1
118 co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2
122 $form->{$_} = $myconfig{$_} for @a;
124 my $openings = $form->{fa_oeffnungszeiten};
125 $openings =~ s/\\\\n/<br>/g;
127 my $company_given = ($form->{company} ne '')
128 ? qq|<h3>$form->{company}</h3>\n|
129 : qq|<a href="controller.pl?action=ClientConfig/edit">|
130 . $locale->text('No Company Name given') . qq|!</a><br>|;
133 # Anpassungen der Variablennamen auf pre 2.1.1 Namen
134 # klären, ob $form->{company_street|_address} gesetzt sind
135 if ($form->{address} ne '') {
136 my $temp = $form->{address};
137 $temp =~ s/\n/<br \/>/;
138 ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp);
139 $form->{co_city} =~ s/\n//g;
144 ($form->{co_street} && ($form->{co_zip} || $form->{co_city}))
145 ? qq|$form->{co_street}<br>|
146 . qq|$form->{co_street1}<br>|
147 . qq|$form->{co_zip} $form->{co_city}|
148 : qq|<a href="controller.pl?action=ClientConfig/edit">|
149 . $locale->text('No Company Address given')
152 $form->{co_email} = $form->{email} unless $form->{co_email};
153 $form->{co_tel} = $form->{tel} unless $form->{co_tel};
154 $form->{co_fax} = $form->{fax} unless $form->{co_fax};
155 $form->{co_url} = $form->{urlx} unless $form->{co_url};
157 my $taxnumber_given = ($form->{taxnumber} ne '') ? $form->{taxnumber} : qq|<a href="ustva.pl?action=config_step1">Keine Steuernummer hinterlegt!</a><br>|;
158 my $fa_name_given = ($form->{fa_name} ne '') ? $form->{fa_name} : qq|<a href="ustva.pl?action=config_step1">Kein Finanzamt hinterlegt!</a><br>|;
159 my $ustva_vorauswahl = &ustva_vorauswahl();
161 my @all_years = $form->all_years(\%myconfig);
163 my $select_year = qq|<select name=year title="|
164 . $locale->text('Year') . qq|">|;
165 foreach my $key (@all_years) {
166 $select_year .= qq|<option |;
167 $select_year .= qq|selected| if ($key eq $form->{year});
168 $select_year .= qq| >$key</option>|;
170 $select_year .= qq|</select>|;
173 $_checked = "checked" if ($form->{kz10} eq '1');
174 my $checkbox_kz_10 = qq|<input name="FA_10" id=FA_10 class=checkbox|
175 . qq| type=checkbox value="1" $_checked title = "|
176 . $locale->text('Amended Advance Turnover Tax Return').'(Nr. 10)'
178 . $locale->text('Amended Advance Turnover Tax Return');
180 $_checked = "checked" if ($form->{kz22} eq '1');
181 my $checkbox_kz_22 = qq|<input name="FA_22" id=FA_22 class=checkbox|
182 . qq| type=checkbox value="1" $_checked title = "|
183 . $locale->text('Receipts attached/extra').'(Nr. 22)'
185 . $locale->text('Receipts attached/extra');
187 $_checked = "checked" if ($form->{kz29} eq '1');
188 my $checkbox_kz_29 = qq|<input name="FA_29" id=FA_29 class=checkbox|
189 . qq| type=checkbox value="1" $_checked title = "|
190 . $locale->text('Accounting desired').'(Nr. 29)'
192 . $locale->text('Accounting desired');
194 $_checked = "checked" if ($form->{kz26} eq '1');
195 my $checkbox_kz_26 = qq|<input name="FA_26" id=FA_26 class=checkbox|
196 . qq| type=checkbox value="1" $_checked title = "|
197 . $locale->text('Direct debit revoked').'(Nr. 26)'
199 . $locale->text('Direct debit revoked');
201 my $method_local = ($form->{accounting_method} eq 'accrual') ? $locale->text('accrual')
202 : ($form->{accounting_method} eq 'cash') ? $locale->text('cash')
205 my $period_local = ( $form->{fa_voranmeld} eq 'month') ? $locale->text('month')
206 : ( $form->{fa_voranmeld} eq 'quarter') ? $locale->text('quarter')
209 my @tax_office_banks_ref = (
210 { BLZ => $form->{fa_blz_1},
211 Kontonummer => $form->{fa_kontonummer_1},
212 Bankbezeichnung => $form->{fa_bankbezeichnung_1}
214 { BLZ => $form->{fa_blz_2},
215 Kontonummer => $form->{fa_kontonummer_2},
216 Bankbezeichnung => $form->{fa_bankbezeichnung_2}
220 $ustva->get_coa($form); # fetches coa and modifies some form variables
223 openings => $openings,
224 company_given => $company_given,
225 address_given => $address_given,
226 taxnumber_given => $taxnumber_given,
227 fa_name_given => $fa_name_given,
228 taxnumber => $defaults->taxnumber,
229 select_year => $select_year,
230 period_local => $period_local,
231 method_local => $method_local,
232 ustva_vorauswahl => $ustva_vorauswahl,
233 checkbox_kz_10 => $checkbox_kz_10,
234 checkbox_kz_22 => $checkbox_kz_22,
235 checkbox_kz_29 => $checkbox_kz_29,
236 checkbox_kz_26 => $checkbox_kz_26,
237 tax_office_banks => \@tax_office_banks_ref,
238 select_options => &show_options,
242 print($form->parse_html_template('ustva/report', $template_ref));
244 $::lxdebug->leave_sub();
250 $::lxdebug->enter_sub();
252 $::auth->assert('advance_turnover_tax_return');
254 # parse help documents under doc
255 $::form->{templates} = 'doc';
256 $::form->{help} = 'ustva';
257 $::form->{type} = 'help';
258 $::form->{format} = 'html';
261 $::lxdebug->leave_sub();
265 $::lxdebug->enter_sub();
267 $::auth->assert('advance_turnover_tax_return');
270 $::lxdebug->leave_sub();
271 call_sub($::form->{"nextsub"});
274 sub ustva_vorauswahl {
275 $::lxdebug->enter_sub();
278 my $locale = $::locale;
279 my %myconfig = %::myconfig;
281 $::auth->assert('advance_turnover_tax_return');
283 my $select_vorauswahl;
285 #Aktuelles Datum zerlegen:
286 my $date = $form->datetonum($form->current_date(\%myconfig), \%myconfig);
288 #$locale->date($myconfig, $form->current_date($myconfig), 0)=~ /(\d\d).(\d\d).(\d\d\d\d)/;
289 $form->{day} = substr($date, 6, 2);
290 $form->{month} = substr($date, 4, 2);
291 $form->{year} = substr($date, 0, 4);
292 $::lxdebug->message(LXDebug->DEBUG1, qq|
293 Actual date from Database: $date\n
294 Actual year from Database: $form->{year}\n
295 Actual day from Database: $form->{day}\n
296 Actual month from Database: $form->{month}\n|);
301 # Testdaten erzeugen:
303 #$form->{month}= '01';
304 #$form->{year}= 2004;
305 $select_vorauswahl = qq|
306 <input type="hidden" name="day" value="$form->{day}">
307 <input type="hidden" name="month" value="$form->{month}">
308 <input type="hidden" name="yymmdd" value="$yymmdd">
309 <input type="hidden" name="sel" value="$sel">
312 if ($form->{fa_voranmeld} eq 'month') {
314 # Vorauswahl bei monatlichem Voranmeldungszeitraum
316 my %liste = ('01' => $locale->text('January'),
317 '02' => $locale->text('February'),
318 '03' => $locale->text('March'),
319 '04' => $locale->text('April'),
320 '05' => $locale->text('May'),
321 '06' => $locale->text('June'),
322 '07' => $locale->text('July'),
323 '08' => $locale->text('August'),
324 '09' => $locale->text('September'),
325 '10' => $locale->text('October'),
326 '11' => $locale->text('November'),
327 '12' => $locale->text('December'),
328 '13' => $locale->text('Yearly'),
331 my $yy = $form->{year} * 10000;
332 $yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
336 # Offset für Dauerfristverlängerung
337 $dfv = '100' if ($form->{fa_dauerfrist} eq '1');
340 $yymmdd <= ($yy + 110 + $dfv) && do {
341 $form->{year} = $form->{year} - 1;
345 $yymmdd <= ($yy + 210 + $dfv) && do {
349 $yymmdd <= ($yy + 310 + $dfv) && do {
353 $yymmdd <= ($yy + 410 + $dfv) && do {
357 $yymmdd <= ($yy + 510 + $dfv) && do {
361 $yymmdd <= ($yy + 610 + $dfv) && do {
365 $yymmdd <= ($yy + 710 + $dfv) && do {
369 $yymmdd <= ($yy + 810 + $dfv) && do {
373 $yymmdd <= ($yy + 910 + $dfv) && do {
377 $yymmdd <= ($yy + 1010 + $dfv) && do {
381 $yymmdd <= ($yy + 1110 + $dfv) && do {
385 $yymmdd <= ($yy + 1210) && do {
389 $yymmdd <= ($yy + 1231) && do {
395 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
396 . $locale->text('Select a period') . qq|" >|;
399 foreach $key (sort keys %liste) {
401 $selected = 'selected' if ($sel eq $key);
402 $select_vorauswahl .= qq|
403 <option value="$key" $selected> $liste{$key}</option>
406 $select_vorauswahl .= qq|</select>|;
408 } elsif ($form->{fa_voranmeld} eq 'quarter') {
410 # Vorauswahl bei quartalsweisem Voranmeldungszeitraum
411 my %liste = ('41' => $locale->text('1. Quarter'),
412 '42' => $locale->text('2. Quarter'),
413 '43' => $locale->text('3. Quarter'),
414 '44' => $locale->text('4. Quarter'),
415 '13' => $locale->text('Yearly'),);
417 my $yy = $form->{year} * 10000;
418 $yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
420 my $dfv = ''; # Offset für Dauerfristverlängerung
421 $dfv = '100' if ($form->{fa_dauerfrist} eq '1');
424 $yymmdd <= ($yy + 110 + $dfv) && do {
425 $form->{year} = $form->{year} - 1;
429 $yymmdd <= ($yy + 410 + $dfv) && do {
433 $yymmdd <= ($yy + 710 + $dfv) && do {
437 $yymmdd <= ($yy + 1010 + $dfv) && do {
441 $yymmdd <= ($yy + 1231) && do {
446 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
447 . $locale->text('Select a period') . qq|" >|;
449 foreach $key (sort keys %liste) {
451 $selected = 'selected' if ($sel eq $key);
452 $select_vorauswahl .= qq|
453 <option value="$key" $selected>$liste{$key}</option>
456 $select_vorauswahl .= qq|\n</select>
461 # keine Vorauswahl bei Voranmeldungszeitraum
462 $select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
463 . $locale->text('Select a period') . qq|" >|;
465 my %listea = ('41' => '1. Quarter',
466 '42' => '2. Quarter',
467 '43' => '3. Quarter',
468 '44' => '4. Quarter',);
470 my %listeb = ('01' => 'January',
484 foreach $key (sort keys %listea) {
485 $select_vorauswahl .= qq|
486 <option value="$key">|
487 . $locale->text("$listea{$key}")
491 foreach $key (sort keys %listeb) {
492 $select_vorauswahl .= qq|
493 <option value="$key">|
494 . $locale->text("$listeb{$key}")
497 $select_vorauswahl .= qq|</select>|;
499 $::lxdebug->leave_sub();
501 return $select_vorauswahl;
505 # $::lxdebug->enter_sub();
507 # $::lxdebug->leave_sub();
511 $::lxdebug->enter_sub();
513 $::lxdebug->leave_sub();
517 $::lxdebug->enter_sub();
519 $::auth->assert('advance_turnover_tax_return');
521 # $form->{PD}{$form->{type}} = "selected";
522 # $form->{DF}{$form->{format}} = "selected";
523 # $form->{OP}{$form->{media}} = "selected";
524 # $form->{SM}{$form->{sendmode}} = "selected";
525 my $type = qq| <input type=hidden name="type" value="ustva">|;
526 my $media = qq| <input type=hidden name="media" value="screen">|;
528 qq| <option value=html selected>|
529 . $::locale->text('HTML')
532 #my $disabled= qq|disabled="disabled"|;
533 #$disabled='' if ($form->{elster} eq '1' );
534 #if ($::form->{elster} eq '1') {
537 qq|<option value=elstertaxbird>|
538 . $::locale->text('ELSTER Export (via Geierlein)')
542 my $show_options = qq|
545 <select name=format title = "|
546 . $::locale->text('Choose Outputformat') . qq|">$format</select>
548 $::lxdebug->leave_sub();
550 return $show_options;
554 $::lxdebug->enter_sub();
557 my $locale = $::locale;
558 my %myconfig = %::myconfig;
560 $::auth->assert('advance_turnover_tax_return');
562 my $defaults = SL::DB::Default->get;
563 $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates;
564 $form->{templates} = $defaults->templates;
567 my $ustva = USTVA->new();
568 $ustva->get_config();
569 $ustva->get_finanzamt();
571 # Setze Anmeldungszeitraum
573 $ustva->set_FromTo(\%$form);
576 $ustva->ustva(\%myconfig, \%$form);
578 # reformat Dates to dateformat
579 $form->{fromdate} = $locale->date(\%myconfig, $form->{fromdate}, 0, 0, 0);
581 $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
582 $form->{todate} = $locale->date(\%myconfig, $form->{todate}, 0, 0, 0);
584 $form->{longperiod} =
585 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1, 0, 0);
587 # if there are any dates construct a where
588 if ($form->{fromdate} || $form->{todate}) {
590 $form->{todate} = $form->current_date(\%myconfig) unless ($form->{todate});
592 my $longtodate = $locale->date(\%myconfig, $form->{todate}, 1, 0, 0);
593 my $shorttodate = $locale->date(\%myconfig, $form->{todate}, 0, 0, 0);
595 my $longfromdate = $locale->date(\%myconfig, $form->{fromdate}, 1, 0, 0);
596 my $shortfromdate = $locale->date(\%myconfig, $form->{fromdate}, 0, 0, 0);
598 $form->{this_period} = "$shortfromdate<br>\n$shorttodate";
599 $form->{longperiod} =
600 $locale->text('for Period')
601 . qq|<br>\n$longfromdate |
602 . $locale->text('to (date)')
606 if ($form->{comparefromdate} || $form->{comparetodate}) {
607 my $longcomparefromdate =
608 $locale->date(\%myconfig, $form->{comparefromdate}, 1, 0, 0);
609 my $shortcomparefromdate =
610 $locale->date(\%myconfig, $form->{comparefromdate}, 0, 0, 0);
612 my $longcomparetodate =
613 $locale->date(\%myconfig, $form->{comparetodate}, 1, 0, 0);
614 my $shortcomparetodate =
615 $locale->date(\%myconfig, $form->{comparetodate}, 0, 0, 0);
617 $form->{last_period} = "$shortcomparefromdate<br>\n$shortcomparetodate";
618 $form->{longperiod} .=
619 "<br>\n$longcomparefromdate "
620 . $locale->text('to (date)')
621 . qq| $longcomparetodate|;
624 $form->{Datum_heute} =
625 $locale->date(\%myconfig, $form->current_date(\%myconfig), 0, 0, 0);
627 # setup variables for the form
628 my @a = qw(tel fax email
629 co_chief co_department co_custom1 co_custom2 co_custom3 co_custom4 co_custom5
630 co_name1 co_name2 co_street co_street1 co_zip co_city co_city1 co_country co_tel co_tel1 co_tel2
631 co_fax co_fax1 co_email co_email1 co_url co_url1
632 co_bankname co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1
633 co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2 co_accountnr3);
635 $form->{$_} = $myconfig{$_} for @a;
636 $form->{$_} = $defaults->$_ for qw(company address co_ustid duns);
638 if ($form->{address} ne '') {
639 my $temp = $form->{address};
640 $temp =~ s/\n/<br \/>/;
641 ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp,2);
642 $form->{co_city} =~ s/\\n//g;
645 ################################
647 # Nation specific customisations
649 ################################
653 if ( $form->{coa} eq 'Germany-DATEV-SKR03EU' or $form->{coa} eq 'Germany-DATEV-SKR04EU') {
656 $form->{amount} = [];
658 if ( $form->{format} eq 'pdf' or $form->{format} eq 'postscript') {
660 $form->{IN} = "$form->{type}-$form->{year}.tex";
661 $form->{padding} = "~~";
662 $form->{bold} = "\textbf{";
663 $form->{endbold} = "}";
664 $form->{br} = '\\\\';
666 # Zahlenformatierung für Latex USTVA Formulare
668 foreach my $number (@{$::form->{category_euro}}) {
669 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '');
672 my ${decimal_comma} = ( $myconfig{numberformat} eq '1.000,00'
673 or $myconfig{numberformat} eq '1000,00' ) ? ',':'.';
675 foreach my $number (@{$::form->{category_cent}}) {
676 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '');
677 $form->{$number} =~ s/${decimal_comma}/~~/g;
680 } elsif ( $form->{format} eq 'html') { # Formatierungen für HTML Ausgabe
682 $form->{IN} = $form->{type} . '.html';
683 $form->{padding} = " ";
684 $form->{bold} = "<b>";
685 $form->{endbold} = "</b>";
686 $form->{br} = "<br>";
687 $form->{address} =~ s/\\n/\n/g;
689 foreach my $number (@{$::form->{category_cent}}) {
690 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '0');
693 foreach my $number (@{$::form->{category_euro}}) {
694 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '0');
696 } elsif ( $form->{format} eq '' ){ # No format error.
699 USTVA::error( $locale->text('Application Error. No Format given' ) . "!");
700 $::dispatcher->end_request;
702 } else { # All other Formats are wrong
704 USTVA::error( $locale->text('Application Error. Wrong Format') . ": " . $form->{format} );
705 $::dispatcher->end_request;
709 } else # Outputformat for generic output
714 if ( $form->{format} eq 'generic') { # Formatierungen für HTML Ausgabe
717 for my $kennziffer (@{$::form->{category_cent}}, @{$::form->{category_euro}}) {
719 $rec_ref->{id} = $kennziffer;
720 $rec_ref->{amount} = $form->format_amount(\%myconfig, $form->{$kennziffer}, 2, '0');
722 $::lxdebug->message($LXDebug::DEBUG, "Kennziffer $kennziffer: '$form->{$kennziffer}'" );
723 $::lxdebug->dump($LXDebug::DEBUG, $rec_ref );
724 push @ { $form->{USTVA} }, $rec_ref;
731 if ( $form->{period} eq '13' and $form->{format} ne 'html') {
735 'Yearly taxreport not yet implemented')
739 $form->{templates} = "doc" if ( $form->{type} eq 'help' );
741 if ($form->{format} eq 'generic'){
746 taxnumber => $defaults->taxnumber,
749 print($form->parse_html_template('ustva/generic_taxreport', $template_ref));
751 } elsif ( $form->{format} eq 'elstertaxbird' ) {
752 $form->parse_template(\%myconfig);
755 # add a prefix for ustva pos numbers, i.e.: 81 -> post_ustva_81
756 $form->{"pos_ustva_$_"} = $form->{$_} for grep { m{^\d+} } keys %{ $form };
757 $form->{title} = $locale->text('Advance turnover tax return');
760 print $form->parse_html_template('ustva/ustva');
765 $::lxdebug->leave_sub();
769 $::lxdebug->enter_sub();
771 $::auth->assert('advance_turnover_tax_return');
773 $::form->{title} = $::locale->text('Tax Office Preferences');
775 # edit all taxauthority prefs
777 setup_ustva_config_step1_action_bar();
781 my $ustva = USTVA->new();
782 $ustva->get_config();
783 $ustva->get_finanzamt();
785 my $land = $::form->{fa_land_nr};
786 my $amt = $::form->{fa_bufa_nr};
789 $::form->{title} = $::locale->text('Tax Office Preferences');
792 my $select_tax_office = $ustva->fa_auswahl($land, $amt, $ustva->query_finanzamt(\%::myconfig, $::form));
793 my $method_local = ($::form->{accounting_method} eq 'accrual') ? $::locale->text('accrual')
794 : ($::form->{accounting_method} eq 'cash') ? $::locale->text('cash')
797 my $checked_monthly = $::form->{fa_voranmeld} eq 'month' ? "checked" : '';
798 my $checked_quarterly = $::form->{fa_voranmeld} eq 'quarter' ? "checked" : '';
799 my $checked_dauerfristverlaengerung = $::form->{da_dauerfrist} eq '1' ? "checked" : '';
801 my $_hidden_variables_ref;
803 my %_hidden_local_variables = (
804 'saved' => $::locale->text('Check Details'),
807 foreach my $variable (keys %_hidden_local_variables) {
808 push @{ $_hidden_variables_ref },
809 { 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
812 my @_hidden_form_variables = $ustva->get_fiamt_vars();
813 push @_hidden_form_variables ,qw(fa_bufa_nr taxnumber accounting_method coa);
815 foreach my $variable (@_hidden_form_variables) {
816 push @{ $_hidden_variables_ref},
817 { 'variable' => $variable, 'value' => $::form->{$variable} };
820 $ustva->get_coa($::form); # fetches coa and modifies some form variables
822 # Variablen für das Template zur Verfügung stellen
824 select_tax_office => $select_tax_office,
825 method_local => $method_local,
826 checked_monthly => $checked_monthly,
827 checked_quarterly => $checked_quarterly,
828 checked_dauerfristverlaengerung => $checked_dauerfristverlaengerung,
829 hidden_variables => $_hidden_variables_ref,
833 # Ausgabe des Templates
834 print($::form->parse_html_template('ustva/config_step1', $template_ref));
836 $::lxdebug->leave_sub();
840 $::lxdebug->enter_sub();
843 my $locale = $::locale;
844 my %myconfig = %::myconfig;
846 $::auth->assert('advance_turnover_tax_return');
848 setup_ustva_config_step2_action_bar();
855 my $ustva = USTVA->new();
856 $ustva->get_config() if ($form->{saved} eq $locale->text('saved'));
857 my $coa = $::form->{coa};
858 $form->{"COA_$coa"} = '1';
859 $form->{COA_Germany} = '1' if ($coa =~ m/^germany/i);
860 $ustva->get_finanzamt();
863 # Auf Übergabefehler checken
864 USTVA::info( $locale->text('Missing Tax Authoritys Preferences') . "\n"
865 . $locale->text('USTVA-Hint: Tax Authoritys'))
866 if ( $form->{fa_bufa_nr_new} eq 'Auswahl'
867 || $form->{fa_land_nr_new} eq 'Auswahl');
868 USTVA::info( $locale->text('Missing Method!') . "\n"
869 . $locale->text('USTVA-Hint: Method'))
870 if ($form->{accounting_method} eq '');
872 # Klären, ob Variablen bereits befüllt sind UND ob veränderungen auf
873 # der vorherigen Maske stattfanden: $change = 1(in der edit sub,
874 # mittels get_config)
876 # $::lxdebug->message(LXDebug->DEBUG2,"land old=".$form->{fa_land_nr}." new=".$form->{fa_land_nr_new});
877 # $::lxdebug->message(LXDebug->DEBUG2,"bufa old=".$form->{fa_bufa_nr}." new=".$form->{fa_bufa_nr_new});
878 my $change = $form->{fa_land_nr} eq $form->{fa_land_nr_new}
879 && $form->{fa_bufa_nr} eq $form->{fa_bufa_nr_new} ? '0' : '1';
880 $change = '0' if ($form->{saved} eq $locale->text('saved'));
883 if ($change eq '1') {
886 $fa_land_nr = $form->{fa_land_nr_new};
887 $fa_bufa_nr = $form->{fa_bufa_nr_new};
888 $form->{fa_land_nr} = $fa_land_nr;
889 $form->{fa_bufa_nr} = $fa_bufa_nr;
890 $form->{taxnumber} = '';
892 create_steuernummer();
895 $ustva->get_finanzamt();
899 $fa_land_nr = $form->{fa_land_nr};
900 $fa_bufa_nr = $form->{fa_bufa_nr};
903 # $::lxdebug->message(LXDebug->DEBUG2, "form stnr=".$form->{taxnumber}." fa_bufa_nr=".$fa_bufa_nr.
904 # " pattern=".$form->{elster_pattern}." fa_land_nr=".$fa_land_nr);
905 my $stnr = $form->{taxnumber};
907 my $taxnumber = $stnr eq '' ? $form->{taxnumber} : '';
909 $form->{fa_oeffnungszeiten} =~ s/\\\\n/\n/g;
912 $ustva->get_coa($form); # fetches coa and modifies some form variables
914 my $input_steuernummer = $ustva->steuernummer_input(
920 # $::lxdebug->message(LXDebug->DEBUG2, qq|$input_steuernummer|);
923 my $_hidden_variables_ref;
925 my %_hidden_local_variables = (
926 'fa_land_nr' => $fa_land_nr,
927 'fa_bufa_nr' => $fa_bufa_nr,
928 'taxnumber' => $stnr,
929 'lastsub' => 'config_step1',
934 foreach my $variable (keys %_hidden_local_variables) {
935 push @{ $_hidden_variables_ref },
936 { 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
939 my @_hidden_form_variables = qw(
940 fa_dauerfrist fa_steuerberater_city fa_steuerberater_name
941 fa_steuerberater_street fa_steuerberater_tel
942 fa_voranmeld fa_dauerfrist
948 foreach my $variable (@_hidden_form_variables) {
949 push @{ $_hidden_variables_ref},
950 { 'variable' => $variable, 'value' => $form->{$variable} };
954 input_steuernummer => $input_steuernummer,
955 readonly => '', #q|disabled="disabled"|,
956 COA_Germany => $form->{COA_Germany},
957 hidden_variables => $_hidden_variables_ref,
960 # Ausgabe des Templates
961 print($form->parse_html_template('ustva/config_step2', $template_ref));
964 $::lxdebug->leave_sub();
967 sub create_steuernummer {
968 $::lxdebug->enter_sub();
970 $::auth->assert('advance_turnover_tax_return');
972 my $part = $::form->{part};
973 my $patterncount = $::form->{patterncount};
974 my $delimiter = $::form->{delimiter1};
975 my $elster_pattern = $::form->{elster_pattern};
978 # es gibt eine gespeicherte steuernummer $form->{taxnumber}
979 # und die parts und delimiter
984 my $taxnumber_new = $part;
986 for ($h = 1; $h < $patterncount; $h++) {
987 $delimiter = $::form->{delimiter2} if $h > 1;
988 $taxnumber_new .= qq|$delimiter|;
989 for (my $i = 1; $i <= length($elster_pattern); $i++) {
990 $taxnumber_new .= $::form->{"part_$h\_$i"};
993 # $::lxdebug->message(LXDebug->DEBUG2, "oldstnr=".$::form->{taxnumber}." newstnr=".$taxnumber_new);
994 if ($::form->{taxnumber} ne $taxnumber_new) {
995 $::form->{taxnumber} = $taxnumber_new;
996 $::form->{taxnumber_new} = $taxnumber_new;
998 $::form->{taxnumber_new} = '';
1000 $::lxdebug->leave_sub();
1004 $::lxdebug->enter_sub();
1006 $::auth->assert('advance_turnover_tax_return');
1008 #zuerst die steuernummer aus den part, parts_X_Y und delimiter herstellen
1009 create_steuernummer();
1011 # Textboxen formatieren: Linebreaks entfernen
1013 $::form->{fa_oeffnungszeiten} =~ s/\r\n/\\n/g;
1015 #URL mit http:// davor?
1016 $::form->{fa_internet} =~ s/^http:\/\///;
1017 $::form->{fa_internet} = 'http://' . $::form->{fa_internet};
1019 # Hier kommt dann die Plausibilitätsprüfung der ELSTERSteuernummer TODO ??
1021 my $ustva = USTVA->new();
1022 $ustva->save_config();
1024 #$::form->{elster} = '1';
1025 $::form->{saved} = $::locale->text('saved');
1029 $::form->{saved} = $::locale->text('Choose a Tax Number');
1033 $::lxdebug->leave_sub();
1038 $::lxdebug->enter_sub();
1040 # allow Symbolic references just here:
1041 call_sub($::form->{"nextsub"});
1042 $::lxdebug->leave_sub();
1046 $::lxdebug->enter_sub();
1047 call_sub($::form->{"lastsub"});
1048 $::lxdebug->leave_sub();
1051 sub setup_ustva_report_action_bar {
1052 for my $bar ($::request->layout->get('actionbar')) {
1056 submit => [ '#form_do', { action => 'generate_ustva' } ],
1057 accesskey => 'enter',
1061 call => [ 'sendGeierlein' ],
1062 disabled => !length($::lx_office_conf{paths}{geierlein_path} // '') ? t8('The Geierlein path has not been set in the configuration.') : undef,
1063 tooltip => t8('Transfer data to Geierlein ELSTER application'),
1069 sub setup_ustva_config_step1_action_bar {
1070 for my $bar ($::request->layout->get('actionbar')) {
1074 submit => [ '#form', { action => 'config_step2' } ],
1075 accesskey => 'enter',
1081 sub setup_ustva_config_step2_action_bar {
1082 for my $bar ($::request->layout->get('actionbar')) {
1086 submit => [ '#form', { action => 'save' } ],
1087 accesskey => 'enter',
1091 call => [ 'kivi.history_back' ],