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 $::auth->assert('advance_turnover_tax_return');
515 # $form->{PD}{$form->{type}} = "selected";
516 # $form->{DF}{$form->{format}} = "selected";
517 # $form->{OP}{$form->{media}} = "selected";
518 # $form->{SM}{$form->{sendmode}} = "selected";
519 my $type = qq| <input type=hidden name="type" value="ustva">|;
520 my $media = qq| <input type=hidden name="media" value="screen">|;
522 qq| <option value=html selected>|
523 . $::locale->text('HTML')
526 #my $disabled= qq|disabled="disabled"|;
527 #$disabled='' if ($form->{elster} eq '1' );
528 #if ($::form->{elster} eq '1') {
531 qq|<option value=elstertaxbird>|
532 . $::locale->text('ELSTER Export (via Geierlein)')
536 my $show_options = qq|
539 <select name=format title = "|
540 . $::locale->text('Choose Outputformat') . qq|">$format</select>
542 $::lxdebug->leave_sub();
544 return $show_options;
548 $::lxdebug->enter_sub();
551 my $locale = $::locale;
552 my %myconfig = %::myconfig;
554 $::auth->assert('advance_turnover_tax_return');
556 my $defaults = SL::DB::Default->get;
557 $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates;
558 $form->{templates} = $defaults->templates;
561 my $ustva = USTVA->new();
562 $ustva->get_config();
563 $ustva->get_finanzamt();
565 # Setze Anmeldungszeitraum
567 $ustva->set_FromTo(\%$form);
570 $ustva->ustva(\%myconfig, \%$form);
572 # reformat Dates to dateformat
573 $form->{fromdate} = $locale->date(\%myconfig, $form->{fromdate}, 0, 0, 0);
575 $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
576 $form->{todate} = $locale->date(\%myconfig, $form->{todate}, 0, 0, 0);
578 $form->{longperiod} =
579 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1, 0, 0);
581 # if there are any dates construct a where
582 if ($form->{fromdate} || $form->{todate}) {
584 $form->{todate} = $form->current_date(\%myconfig) unless ($form->{todate});
586 my $longtodate = $locale->date(\%myconfig, $form->{todate}, 1, 0, 0);
587 my $shorttodate = $locale->date(\%myconfig, $form->{todate}, 0, 0, 0);
589 my $longfromdate = $locale->date(\%myconfig, $form->{fromdate}, 1, 0, 0);
590 my $shortfromdate = $locale->date(\%myconfig, $form->{fromdate}, 0, 0, 0);
592 $form->{this_period} = "$shortfromdate<br>\n$shorttodate";
593 $form->{longperiod} =
594 $locale->text('for Period')
595 . qq|<br>\n$longfromdate |
596 . $locale->text('to (date)')
600 if ($form->{comparefromdate} || $form->{comparetodate}) {
601 my $longcomparefromdate =
602 $locale->date(\%myconfig, $form->{comparefromdate}, 1, 0, 0);
603 my $shortcomparefromdate =
604 $locale->date(\%myconfig, $form->{comparefromdate}, 0, 0, 0);
606 my $longcomparetodate =
607 $locale->date(\%myconfig, $form->{comparetodate}, 1, 0, 0);
608 my $shortcomparetodate =
609 $locale->date(\%myconfig, $form->{comparetodate}, 0, 0, 0);
611 $form->{last_period} = "$shortcomparefromdate<br>\n$shortcomparetodate";
612 $form->{longperiod} .=
613 "<br>\n$longcomparefromdate "
614 . $locale->text('to (date)')
615 . qq| $longcomparetodate|;
618 $form->{Datum_heute} =
619 $locale->date(\%myconfig, $form->current_date(\%myconfig), 0, 0, 0);
621 # setup variables for the form
622 my @a = qw(tel fax email
623 co_chief co_department co_custom1 co_custom2 co_custom3 co_custom4 co_custom5
624 co_name1 co_name2 co_street co_street1 co_zip co_city co_city1 co_country co_tel co_tel1 co_tel2
625 co_fax co_fax1 co_email co_email1 co_url co_url1
626 co_bankname co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1
627 co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2 co_accountnr3);
629 $form->{$_} = $myconfig{$_} for @a;
630 $form->{$_} = $defaults->$_ for qw(company address co_ustid duns);
632 if ($form->{address} ne '') {
633 my $temp = $form->{address};
634 $temp =~ s/\n/<br \/>/;
635 ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp,2);
636 $form->{co_city} =~ s/\\n//g;
639 ################################
641 # Nation specific customisations
643 ################################
647 if ( $form->{coa} eq 'Germany-DATEV-SKR03EU' or $form->{coa} eq 'Germany-DATEV-SKR04EU') {
650 $form->{amount} = [];
652 if ( $form->{format} eq 'pdf' or $form->{format} eq 'postscript') {
654 $form->{IN} = "$form->{type}-$form->{year}.tex";
655 $form->{padding} = "~~";
656 $form->{bold} = "\textbf{";
657 $form->{endbold} = "}";
658 $form->{br} = '\\\\';
660 # Zahlenformatierung für Latex USTVA Formulare
662 foreach my $number (@{$::form->{category_euro}}) {
663 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '');
666 my ${decimal_comma} = ( $myconfig{numberformat} eq '1.000,00'
667 or $myconfig{numberformat} eq '1000,00' ) ? ',':'.';
669 foreach my $number (@{$::form->{category_cent}}) {
670 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '');
671 $form->{$number} =~ s/${decimal_comma}/~~/g;
674 } elsif ( $form->{format} eq 'html') { # Formatierungen für HTML Ausgabe
676 $form->{IN} = $form->{type} . '.html';
677 $form->{padding} = " ";
678 $form->{bold} = "<b>";
679 $form->{endbold} = "</b>";
680 $form->{br} = "<br>";
681 $form->{address} =~ s/\\n/\n/g;
683 foreach my $number (@{$::form->{category_cent}}) {
684 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '0');
687 foreach my $number (@{$::form->{category_euro}}) {
688 $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '0');
690 } elsif ( $form->{format} eq '' ){ # No format error.
693 USTVA::error( $locale->text('Application Error. No Format given' ) . "!");
694 $::dispatcher->end_request;
696 } else { # All other Formats are wrong
698 USTVA::error( $locale->text('Application Error. Wrong Format') . ": " . $form->{format} );
699 $::dispatcher->end_request;
703 } else # Outputformat for generic output
708 if ( $form->{format} eq 'generic') { # Formatierungen für HTML Ausgabe
711 for my $kennziffer (@{$::form->{category_cent}}, @{$::form->{category_euro}}) {
713 $rec_ref->{id} = $kennziffer;
714 $rec_ref->{amount} = $form->format_amount(\%myconfig, $form->{$kennziffer}, 2, '0');
716 $::lxdebug->message($LXDebug::DEBUG, "Kennziffer $kennziffer: '$form->{$kennziffer}'" );
717 $::lxdebug->dump($LXDebug::DEBUG, $rec_ref );
718 push @ { $form->{USTVA} }, $rec_ref;
725 if ( $form->{period} eq '13' and $form->{format} ne 'html') {
729 'Yearly taxreport not yet implemented')
733 $form->{templates} = "doc" if ( $form->{type} eq 'help' );
735 if ($form->{format} eq 'generic'){
740 taxnumber => $defaults->taxnumber,
743 print($form->parse_html_template('ustva/generic_taxreport', $template_ref));
745 } elsif ( $form->{format} eq 'elstertaxbird' ) {
746 $form->parse_template(\%myconfig);
749 # add a prefix for ustva pos numbers, i.e.: 81 -> post_ustva_81
750 $form->{"pos_ustva_$_"} = $form->{$_} for grep { m{^\d+} } keys %{ $form };
751 $form->{title} = $locale->text('Advance turnover tax return');
754 print $form->parse_html_template('ustva/ustva');
759 $::lxdebug->leave_sub();
763 $::lxdebug->enter_sub();
765 $::auth->assert('advance_turnover_tax_return');
767 $::form->{title} = $::locale->text('Tax Office Preferences');
769 # edit all taxauthority prefs
771 setup_ustva_config_step1_action_bar();
775 my $ustva = USTVA->new();
776 $ustva->get_config();
777 $ustva->get_finanzamt();
779 my $land = $::form->{fa_land_nr};
780 my $amt = $::form->{fa_bufa_nr};
783 $::form->{title} = $::locale->text('Tax Office Preferences');
786 my $select_tax_office = $ustva->fa_auswahl($land, $amt, $ustva->query_finanzamt(\%::myconfig, $::form));
787 my $method_local = ($::form->{accounting_method} eq 'accrual') ? $::locale->text('accrual')
788 : ($::form->{accounting_method} eq 'cash') ? $::locale->text('cash')
791 my $checked_monthly = $::form->{fa_voranmeld} eq 'month' ? "checked" : '';
792 my $checked_quarterly = $::form->{fa_voranmeld} eq 'quarter' ? "checked" : '';
793 my $checked_dauerfristverlaengerung = $::form->{da_dauerfrist} eq '1' ? "checked" : '';
795 my $_hidden_variables_ref;
797 my %_hidden_local_variables = (
798 'saved' => $::locale->text('Check Details'),
801 foreach my $variable (keys %_hidden_local_variables) {
802 push @{ $_hidden_variables_ref },
803 { 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
806 my @_hidden_form_variables = $ustva->get_fiamt_vars();
807 push @_hidden_form_variables ,qw(fa_bufa_nr taxnumber accounting_method coa);
809 foreach my $variable (@_hidden_form_variables) {
810 push @{ $_hidden_variables_ref},
811 { 'variable' => $variable, 'value' => $::form->{$variable} };
814 $ustva->get_coa($::form); # fetches coa and modifies some form variables
816 # Variablen für das Template zur Verfügung stellen
818 select_tax_office => $select_tax_office,
819 method_local => $method_local,
820 checked_monthly => $checked_monthly,
821 checked_quarterly => $checked_quarterly,
822 checked_dauerfristverlaengerung => $checked_dauerfristverlaengerung,
823 hidden_variables => $_hidden_variables_ref,
827 # Ausgabe des Templates
828 print($::form->parse_html_template('ustva/config_step1', $template_ref));
830 $::lxdebug->leave_sub();
834 $::lxdebug->enter_sub();
837 my $locale = $::locale;
838 my %myconfig = %::myconfig;
840 $::auth->assert('advance_turnover_tax_return');
842 setup_ustva_config_step2_action_bar();
849 my $ustva = USTVA->new();
850 $ustva->get_config() if ($form->{saved} eq $locale->text('saved'));
851 my $coa = $::form->{coa};
852 $form->{"COA_$coa"} = '1';
853 $form->{COA_Germany} = '1' if ($coa =~ m/^germany/i);
854 $ustva->get_finanzamt();
857 # Auf Übergabefehler checken
858 USTVA::info( $locale->text('Missing Tax Authoritys Preferences') . "\n"
859 . $locale->text('USTVA-Hint: Tax Authoritys'))
860 if ( $form->{fa_bufa_nr_new} eq 'Auswahl'
861 || $form->{fa_land_nr_new} eq 'Auswahl');
862 USTVA::info( $locale->text('Missing Method!') . "\n"
863 . $locale->text('USTVA-Hint: Method'))
864 if ($form->{accounting_method} eq '');
866 # Klären, ob Variablen bereits befüllt sind UND ob veränderungen auf
867 # der vorherigen Maske stattfanden: $change = 1(in der edit sub,
868 # mittels get_config)
870 # $::lxdebug->message(LXDebug->DEBUG2,"land old=".$form->{fa_land_nr}." new=".$form->{fa_land_nr_new});
871 # $::lxdebug->message(LXDebug->DEBUG2,"bufa old=".$form->{fa_bufa_nr}." new=".$form->{fa_bufa_nr_new});
872 my $change = $form->{fa_land_nr} eq $form->{fa_land_nr_new}
873 && $form->{fa_bufa_nr} eq $form->{fa_bufa_nr_new} ? '0' : '1';
874 $change = '0' if ($form->{saved} eq $locale->text('saved'));
877 if ($change eq '1') {
880 $fa_land_nr = $form->{fa_land_nr_new};
881 $fa_bufa_nr = $form->{fa_bufa_nr_new};
882 $form->{fa_land_nr} = $fa_land_nr;
883 $form->{fa_bufa_nr} = $fa_bufa_nr;
884 $form->{taxnumber} = '';
886 create_steuernummer();
889 $ustva->get_finanzamt();
893 $fa_land_nr = $form->{fa_land_nr};
894 $fa_bufa_nr = $form->{fa_bufa_nr};
897 # $::lxdebug->message(LXDebug->DEBUG2, "form stnr=".$form->{taxnumber}." fa_bufa_nr=".$fa_bufa_nr.
898 # " pattern=".$form->{elster_pattern}." fa_land_nr=".$fa_land_nr);
899 my $stnr = $form->{taxnumber};
901 my $taxnumber = $stnr eq '' ? $form->{taxnumber} : '';
903 $form->{fa_oeffnungszeiten} =~ s/\\\\n/\n/g;
906 $ustva->get_coa($form); # fetches coa and modifies some form variables
908 my $input_steuernummer = $ustva->steuernummer_input(
914 # $::lxdebug->message(LXDebug->DEBUG2, qq|$input_steuernummer|);
917 my $_hidden_variables_ref;
919 my %_hidden_local_variables = (
920 'fa_land_nr' => $fa_land_nr,
921 'fa_bufa_nr' => $fa_bufa_nr,
922 'taxnumber' => $stnr,
923 'lastsub' => 'config_step1',
928 foreach my $variable (keys %_hidden_local_variables) {
929 push @{ $_hidden_variables_ref },
930 { 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
933 my @_hidden_form_variables = qw(
934 fa_dauerfrist fa_steuerberater_city fa_steuerberater_name
935 fa_steuerberater_street fa_steuerberater_tel
936 fa_voranmeld fa_dauerfrist
942 foreach my $variable (@_hidden_form_variables) {
943 push @{ $_hidden_variables_ref},
944 { 'variable' => $variable, 'value' => $form->{$variable} };
948 input_steuernummer => $input_steuernummer,
949 readonly => '', #q|disabled="disabled"|,
950 COA_Germany => $form->{COA_Germany},
951 hidden_variables => $_hidden_variables_ref,
954 # Ausgabe des Templates
955 print($form->parse_html_template('ustva/config_step2', $template_ref));
958 $::lxdebug->leave_sub();
961 sub create_steuernummer {
962 $::lxdebug->enter_sub();
964 $::auth->assert('advance_turnover_tax_return');
966 my $part = $::form->{part};
967 my $patterncount = $::form->{patterncount};
968 my $delimiter = $::form->{delimiter1};
969 my $elster_pattern = $::form->{elster_pattern};
972 # es gibt eine gespeicherte steuernummer $form->{taxnumber}
973 # und die parts und delimiter
978 my $taxnumber_new = $part;
980 for ($h = 1; $h < $patterncount; $h++) {
981 $delimiter = $::form->{delimiter2} if $h > 1;
982 $taxnumber_new .= qq|$delimiter|;
983 for (my $i = 1; $i <= length($elster_pattern); $i++) {
984 $taxnumber_new .= $::form->{"part_$h\_$i"};
987 # $::lxdebug->message(LXDebug->DEBUG2, "oldstnr=".$::form->{taxnumber}." newstnr=".$taxnumber_new);
988 if ($::form->{taxnumber} ne $taxnumber_new) {
989 $::form->{taxnumber} = $taxnumber_new;
990 $::form->{taxnumber_new} = $taxnumber_new;
992 $::form->{taxnumber_new} = '';
994 $::lxdebug->leave_sub();
998 $::lxdebug->enter_sub();
1000 $::auth->assert('advance_turnover_tax_return');
1002 #zuerst die steuernummer aus den part, parts_X_Y und delimiter herstellen
1003 create_steuernummer();
1005 # Textboxen formatieren: Linebreaks entfernen
1007 $::form->{fa_oeffnungszeiten} =~ s/\r\n/\\n/g;
1009 #URL mit http:// davor?
1010 $::form->{fa_internet} =~ s/^http:\/\///;
1011 $::form->{fa_internet} = 'http://' . $::form->{fa_internet};
1013 # Hier kommt dann die Plausibilitätsprüfung der ELSTERSteuernummer TODO ??
1015 my $ustva = USTVA->new();
1016 $ustva->save_config();
1018 #$::form->{elster} = '1';
1019 $::form->{saved} = $::locale->text('saved');
1023 $::form->{saved} = $::locale->text('Choose a Tax Number');
1027 $::lxdebug->leave_sub();
1032 $::lxdebug->enter_sub();
1034 # allow Symbolic references just here:
1035 call_sub($::form->{"nextsub"});
1036 $::lxdebug->leave_sub();
1040 $::lxdebug->enter_sub();
1041 call_sub($::form->{"lastsub"});
1042 $::lxdebug->leave_sub();
1045 sub setup_ustva_report_action_bar {
1046 for my $bar ($::request->layout->get('actionbar')) {
1050 submit => [ '#form_do', { action => 'generate_ustva' } ],
1051 accesskey => 'enter',
1055 call => [ 'sendGeierlein' ],
1056 disabled => !length($::lx_office_conf{paths}{geierlein_path} // '') ? t8('The Geierlein path has not been set in the configuration.') : undef,
1057 tooltip => t8('Transfer data to Geierlein ELSTER application'),
1063 sub setup_ustva_config_step1_action_bar {
1064 for my $bar ($::request->layout->get('actionbar')) {
1068 submit => [ '#form', { action => 'config_step2' } ],
1069 accesskey => 'enter',
1075 sub setup_ustva_config_step2_action_bar {
1076 for my $bar ($::request->layout->get('actionbar')) {
1080 submit => [ '#form', { action => 'save' } ],
1081 accesskey => 'enter',
1085 call => [ 'kivi.history_back' ],