Projekt

Allgemein

Profil

Herunterladen (42,6 KB) Statistiken
| Zweig: | Markierung: | Revision:
d319704a Moritz Bunkus
#!/bin/perl
#=====================================================================
# Lx-Office ERP
# Copyright (c) 2004 by Udo Spallek, Aachen
#
# Author: Udo Spallek
# Email: udono@gmx.net
# Web: http://www.lx-office.org
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#======================================================================
# German Tax authority Module and later ELSTER Interface
#======================================================================

require "$form->{path}/arap.pl";
40782548 Moritz Bunkus
require "bin/mozilla/common.pl";
d319704a Moritz Bunkus
#use strict;
#no strict 'refs';
#use diagnostics;
63a1c75d Stephan Köhler
#use warnings; # FATAL=> 'all';
d319704a Moritz Bunkus
#use vars qw($locale $form %myconfig);
#our ($myconfig);
#use CGI::Carp "fatalsToBrowser";

use SL::PE;
use SL::RP;
use SL::USTVA;
use SL::User;
1;

# this is for our long dates
# $locale->text('January')
# $locale->text('February')
# $locale->text('March')
# $locale->text('April')
# $locale->text('May ')
# $locale->text('June')
# $locale->text('July')
# $locale->text('August')
# $locale->text('September')
# $locale->text('October')
# $locale->text('November')
# $locale->text('December')

# this is for our short month
# $locale->text('Jan')
# $locale->text('Feb')
# $locale->text('Mar')
# $locale->text('Apr')
# $locale->text('May')
# $locale->text('Jun')
# $locale->text('Jul')
# $locale->text('Aug')
# $locale->text('Sep')
# $locale->text('Oct')
# $locale->text('Nov')
# $locale->text('Dec')
a205ed21 Udo Spallek
# $form->parse_html_template('generic/util_hidden_variables');

d319704a Moritz Bunkus
#############################

sub report {
$lxdebug->enter_sub();
a205ed21 Udo Spallek
d319704a Moritz Bunkus
my $myconfig = \%myconfig;
6c0e5cb7 Moritz Bunkus
d319704a Moritz Bunkus
$form->{title} = $locale->text('UStVA');
6c0e5cb7 Moritz Bunkus
$form->{kz10} = ''; #Berichtigte Anmeldung? Ja =1 Nein=0
d319704a Moritz Bunkus
6ab3da45 Udo Spallek
my $year = substr($form->datetonum($form->current_date(\%myconfig), \%myconfig ),
0, 4);
d319704a Moritz Bunkus
my $department = '';
local $hide = '';
$form->header;

# Einlesen der Finanzamtdaten
0246e125 Moritz Bunkus
USTVA->get_config($userspath, 'finanzamt.ini');
081a4f97 Moritz Bunkus
4dd73ccf Stephan Köhler
# Hier Einlesen der user-config
# steuernummer entfernt f?r prerelease
a205ed21 Udo Spallek
my @a = qw(
signature name company address businessnumber
tel fax email co_chief co_department
co_custom1 co_custom2 co_custom3 co_custom4 co_custom5
co_name1 co_name2 co_street co_street1 co_zip
co_city co_city1 co_country co_tel co_tel1
co_tel2 co_fax co_fax1 co_email co_email1
co_url co_url1 ustid duns co_bankname
co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1
co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2
co_accountnr3
);
4dd73ccf Stephan Köhler
d319704a Moritz Bunkus
map { $form->{$_} = $myconfig->{$_} } @a;

a205ed21 Udo Spallek
my $openings = $form->{FA_Oeffnungszeiten};
$openings =~ s/\\\\n/<br>/g;

my $company_given = ($form->{company} ne '')
? qq|<h3>$form->{company}</h3>\n|
: qq|<a href=am.pl?path=$form->{path}&action=config|
. qq|&level=Programm--Preferences&login=$form->{login}|
. qq|&password=$form->{password}>|
. $locale->text('No Company Name given') . qq|!</a><br>|;

081a4f97 Moritz Bunkus
4dd73ccf Stephan Köhler
# Anpassungen der Variablennamen auf pre 2.1.1 Namen
# kl?ren, ob $form->{company_street|_address} gesetzt sind
d319704a Moritz Bunkus
if ($form->{address} ne '') {
my $temp = $form->{address};
$temp =~ s/\\n/<br \/>/;
4dd73ccf Stephan Köhler
($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp);
b39c8ce9 Moritz Bunkus
$form->{co_city} =~ s/\\n//g;
4dd73ccf Stephan Köhler
}

a205ed21 Udo Spallek
my $address_given =
($form->{co_street} ne ''
and (
$form->{co_zip} ne ''
or $form->{co_city} ne ''
)
)
? qq|$form->{co_street}<br>|
. qq|$form->{co_street1}<br>|
. qq|$form->{co_zip} $form->{co_city}|
: qq|<a href=am.pl?path=$form->{path}&action=config|
. qq|&level=Programm--Preferences&login=$form->{login}|
. qq|&password=$form->{password}>|
. $locale->text('No Company Address given')
. qq|!</a>\n|;

081a4f97 Moritz Bunkus
$form->{co_email} = $form->{email} unless $form->{co_email};
$form->{co_tel} = $form->{tel} unless $form->{co_tel};
$form->{co_fax} = $form->{fax} unless $form->{co_fax};
$form->{co_url} = $form->{urlx} unless $form->{co_url};

a205ed21 Udo Spallek
my $taxnumber_given = ($form->{steuernummer} ne '')
? qq|$form->{steuernummer}|
: qq|<a href="ustva.pl?path=$form->{path}&action="config_step1"|
. qq|&level=Programm--Finanzamteinstellungen&login=$form->{login}|
. qq|&password=$form->{password}">Keine Steuernummer hinterlegt!|
. qq|</a><br>|;
d319704a Moritz Bunkus
a205ed21 Udo Spallek
my $ustva_vorauswahl = &ustva_vorauswahl();
d319704a Moritz Bunkus
a205ed21 Udo Spallek
my @all_years = $form->all_years(\%myconfig);
d319704a Moritz Bunkus
a205ed21 Udo Spallek
my $select_year = qq|<select name=year title="|
. $locale->text('Year') . qq|">|;
foreach my $key (@all_years) {
$select_year .= qq|<option |;
$select_year .= qq|selected| if ($key eq $form->{year});
$select_year .= qq| >$key</option>|;
d319704a Moritz Bunkus
}
a205ed21 Udo Spallek
$select_year .= qq|</select>|;

my $_checked = '';
$_checked = "checked" if ($form->{kz10} eq '1');
my $checkbox_kz_10 = qq|<input name="FA_10" id=FA_10 class=checkbox|
. qq| type=checkbox value="1" $_checked title = "|
. $locale->text('Amended Advance Turnover Tax Return (Nr. 10)')
. qq|">|
. $locale->text('Amended Advance Turnover Tax Return');

my $method_local = ($form->{method} eq 'accrual') ? $locale->text('accrual')
: ($form->{method} eq 'cash') ? $locale->text('cash')
: '';

my $period_local = ( $form->{FA_voranmeld} eq 'month') ? $locale->text('month')
: ( $form->{FA_voranmeld} eq 'quarter') ? $locale->text('quarter')
: '';

my $tax_office_banks_ref = [
{ BLZ => $form->{FA_BLZ_1},
Kontonummer => $form->{FA_Kontonummer_1},
Bankbezeichnung => $form->{FA_Bankbezeichnung_1}
},
{ BLZ => $form->{FA_BLZ_2},
Kontonummer => $form->{FA_Kontonummer_2},
Bankbezeichnung => $form->{FA_Bankbezeichnung_oertlich}
d319704a Moritz Bunkus
}
a205ed21 Udo Spallek
];
my $template_ref = {
openings => $openings,
company_given => $company_given,
address_given => $address_given,
taxnumber_given => $taxnumber_given,
select_year => $select_year,
period_local => $period_local,
method_local => $method_local,
ustva_vorauswahl => $ustva_vorauswahl,
checkbox_kz_10 => $checkbox_kz_10,
tax_office_banks => $tax_office_banks_ref,
select_options => &show_options,
};
print($form->parse_html_template('ustva/report', $template_ref));
d319704a Moritz Bunkus


$lxdebug->leave_sub();
}

a205ed21 Udo Spallek
d319704a Moritz Bunkus
sub help {
$lxdebug->enter_sub();
081a4f97 Moritz Bunkus
d319704a Moritz Bunkus
# parse help documents under doc
my $tmp = $form->{templates};
$form->{templates} = 'doc';
$form->{help} = 'ustva';
$form->{type} = 'help';
$form->{format} = 'html';
&generate_ustva();

#$form->{templates} = $tmp;
$lxdebug->leave_sub();
}

sub show {
$lxdebug->enter_sub();
081a4f97 Moritz Bunkus
d319704a Moritz Bunkus
#&generate_ustva();
no strict 'refs';
4dd73ccf Stephan Köhler
$lxdebug->leave_sub();
40782548 Moritz Bunkus
call_sub($form->{"nextsub"});
d319704a Moritz Bunkus
use strict 'refs';
}

sub ustva_vorauswahl {
$lxdebug->enter_sub();
081a4f97 Moritz Bunkus
a205ed21 Udo Spallek
my $select_vorauswahl;

d319704a Moritz Bunkus
#Aktuelles Datum zerlegen:
63a1c75d Stephan Köhler
my $date = $form->datetonum($form->current_date(\%myconfig), \%myconfig);
d319704a Moritz Bunkus
#$locale->date($myconfig, $form->current_date($myconfig), 0)=~ /(\d\d).(\d\d).(\d\d\d\d)/;
63a1c75d Stephan Köhler
$form->{day} = substr($date, 6, 2);
$form->{month} = substr($date, 4, 2);
$form->{year} = substr($date, 0, 4);
$lxdebug->message(LXDebug::DEBUG1, qq|
Actual date from Database: $date\n
Actual year from Database: $form->{year}\n
Actual day from Database: $form->{day}\n
Actual month from Database: $form->{month}\n|);
081a4f97 Moritz Bunkus
d319704a Moritz Bunkus
my $sel = '';
my $yymmdd = '';

# Testdaten erzeugen:
#$form->{day}= '11';
#$form->{month}= '01';
#$form->{year}= 2004;
a205ed21 Udo Spallek
$select_vorauswahl = qq|
d319704a Moritz Bunkus
<input type=hidden name=day value=$form->{day}>
<input type=hidden name=month value=$form->{month}>
<input type=hidden name=yymmdd value=$yymmdd>
<input type=hidden name=sel value=$sel>
a205ed21 Udo Spallek
|;
d319704a Moritz Bunkus
if ($form->{FA_voranmeld} eq 'month') {

# Vorauswahl bei monatlichem Voranmeldungszeitraum

6c0e5cb7 Moritz Bunkus
my %liste = ('01' => $locale->text('January'),
'02' => $locale->text('February'),
'03' => $locale->text('March'),
'04' => $locale->text('April'),
'05' => $locale->text('May'),
'06' => $locale->text('June'),
'07' => $locale->text('July'),
'08' => $locale->text('August'),
'09' => $locale->text('September'),
'10' => $locale->text('October'),
'11' => $locale->text('November'),
'12' => $locale->text('December'),
'13' => $locale->text('Yearly'),
);
081a4f97 Moritz Bunkus
d319704a Moritz Bunkus
my $yy = $form->{year} * 10000;
$yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
$sel = '';
6c0e5cb7 Moritz Bunkus
my $dfv = '';
081a4f97 Moritz Bunkus
63a1c75d Stephan Köhler
# Offset f?r Dauerfristverl?ngerung
$dfv = '100' if ($form->{FA_dauerfrist} eq '1');
d319704a Moritz Bunkus
SWITCH: {
$yymmdd <= ($yy + 110 + $dfv) && do {
$form->{year} = $form->{year} - 1;
$sel = '12';
last SWITCH;
};
$yymmdd <= ($yy + 210 + $dfv) && do {
$sel = '01';
last SWITCH;
};
$yymmdd <= ($yy + 310 + $dfv) && do {
$sel = '02';
last SWITCH;
};
$yymmdd <= ($yy + 410 + $dfv) && do {
$sel = '03';
last SWITCH;
};
$yymmdd <= ($yy + 510 + $dfv) && do {
$sel = '04';
last SWITCH;
};
$yymmdd <= ($yy + 610 + $dfv) && do {
$sel = '05';
last SWITCH;
};
$yymmdd <= ($yy + 710 + $dfv) && do {
$sel = '06';
last SWITCH;
};
$yymmdd <= ($yy + 810 + $dfv) && do {
$sel = '07';
last SWITCH;
};
$yymmdd <= ($yy + 910 + $dfv) && do {
$sel = '08';
last SWITCH;
};
$yymmdd <= ($yy + 1010 + $dfv) && do {
$sel = '09';
last SWITCH;
};
$yymmdd <= ($yy + 1110 + $dfv) && do {
$sel = '10';
last SWITCH;
};
$yymmdd <= ($yy + 1210) && do {
$sel = '11';
last SWITCH;
};
$yymmdd <= ($yy + 1231) && do {
$sel = '12';
last SWITCH;
};

}
a205ed21 Udo Spallek
$select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
6c0e5cb7 Moritz Bunkus
. $locale->text('Select a period') . qq|" >|;

d319704a Moritz Bunkus
my $key = '';
foreach $key (sort keys %liste) {
my $selected = '';
$selected = 'selected' if ($sel eq $key);
a205ed21 Udo Spallek
$select_vorauswahl .= qq|
6c0e5cb7 Moritz Bunkus
<option value="$key" $selected> $liste{$key}</option>
a205ed21 Udo Spallek
|;
d319704a Moritz Bunkus
}
a205ed21 Udo Spallek
$select_vorauswahl .= qq|</select>|;
d319704a Moritz Bunkus
} elsif ($form->{FA_voranmeld} eq 'quarter') {

# Vorauswahl bei quartalsweisem Voranmeldungszeitraum
2e2e8ce6 Udo Spallek
my %liste = ('41' => $locale->text('1. Quarter'),
'42' => $locale->text('2. Quarter'),
'43' => $locale->text('3. Quarter'),
'44' => $locale->text('4. Quarter'),
081a4f97 Moritz Bunkus
'13' => $locale->text('Yearly'),);
d319704a Moritz Bunkus
my $yy = $form->{year} * 10000;
$yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
$sel = '';
my $dfv = ''; # Offset f?r Dauerfristverl?ngerung
$dfv = '100' if ($form->{FA_dauerfrist} eq '1');

SWITCH: {
$yymmdd <= ($yy + 110 + $dfv) && do {
$form->{year} = $form->{year} - 1;
6ab3da45 Udo Spallek
$sel = '44';
d319704a Moritz Bunkus
last SWITCH;
};
$yymmdd <= ($yy + 410 + $dfv) && do {
6ab3da45 Udo Spallek
$sel = '41';
d319704a Moritz Bunkus
last SWITCH;
};
$yymmdd <= ($yy + 710 + $dfv) && do {
6ab3da45 Udo Spallek
$sel = '42';
d319704a Moritz Bunkus
last SWITCH;
};
$yymmdd <= ($yy + 1010 + $dfv) && do {
6ab3da45 Udo Spallek
$sel = '43';
d319704a Moritz Bunkus
last SWITCH;
};
$yymmdd <= ($yy + 1231) && do {
6ab3da45 Udo Spallek
$sel = '44';
d319704a Moritz Bunkus
};
}

a205ed21 Udo Spallek
$select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
d319704a Moritz Bunkus
. $locale->text('Select a period') . qq|" >|;
my $key = '';
foreach $key (sort keys %liste) {
my $selected = '';
$selected = 'selected' if ($sel eq $key);
a205ed21 Udo Spallek
$select_vorauswahl .= qq|
f575aa99 Stephan Köhler
<option value="$key" $selected>$liste{$key}</option>
d319704a Moritz Bunkus
|;
}
a205ed21 Udo Spallek
$select_vorauswahl .= qq|\n</select>
d319704a Moritz Bunkus
|;

} else {

# keine Vorauswahl bei Voranmeldungszeitraum
a205ed21 Udo Spallek
$select_vorauswahl .= qq|<select id="zeitraum" name="period" title="|
d319704a Moritz Bunkus
. $locale->text('Select a period') . qq|" >|;

2e2e8ce6 Udo Spallek
my %listea = ('41' => '1. Quarter',
'42' => '2. Quarter',
'43' => '3. Quarter',
'44' => '4. Quarter',);
d319704a Moritz Bunkus
my %listeb = ('01' => 'January',
'02' => 'February',
'03' => 'March',
'04' => 'April',
'05' => 'May',
'06' => 'June',
'07' => 'July',
'08' => 'August',
'09' => 'September',
'10' => 'October',
'11' => 'November',
f575aa99 Stephan Köhler
'12' => 'December',
081a4f97 Moritz Bunkus
'13' => 'Yearly',);
d319704a Moritz Bunkus
my $key = '';
foreach $key (sort keys %listea) {
a205ed21 Udo Spallek
$select_vorauswahl .= qq|
081a4f97 Moritz Bunkus
<option value="$key">|
. $locale->text("$listea{$key}")
. qq|</option>\n|;
d319704a Moritz Bunkus
}

foreach $key (sort keys %listeb) {
a205ed21 Udo Spallek
$select_vorauswahl .= qq|
081a4f97 Moritz Bunkus
<option value="$key">|
. $locale->text("$listeb{$key}")
. qq|</option>\n|;
d319704a Moritz Bunkus
}
a205ed21 Udo Spallek
$select_vorauswahl .= qq|</select>|;
d319704a Moritz Bunkus
}
$lxdebug->leave_sub();
a205ed21 Udo Spallek
return $select_vorauswahl;
d319704a Moritz Bunkus
}

a205ed21 Udo Spallek
#sub config {
# $lxdebug->enter_sub();
# config_step1();
# $lxdebug->leave_sub();
#}
d319704a Moritz Bunkus
sub debug {
4dd73ccf Stephan Köhler
$lxdebug->enter_sub();
d319704a Moritz Bunkus
$form->debug();
4dd73ccf Stephan Köhler
$lxdebug->leave_sub();
d319704a Moritz Bunkus
}

sub show_options {
$lxdebug->enter_sub();

# $form->{PD}{$form->{type}} = "selected";
# $form->{DF}{$form->{format}} = "selected";
# $form->{OP}{$form->{media}} = "selected";
# $form->{SM}{$form->{sendmode}} = "selected";
my $type = qq| <input type=hidden name="type" value="ustva">|;
my $media = qq| <input type=hidden name="media" value="screen">|;
my $format =
qq| <option value=html selected>|
6c3f16ab Udo Spallek
. $locale->text('Preview')
d319704a Moritz Bunkus
. qq|</option>|;
d1c335e9 Moritz Bunkus
if ($latex_templates) {
d319704a Moritz Bunkus
$format .=
qq| <option value=pdf>|
6c3f16ab Udo Spallek
. $locale->text('UStVA (PDF-Dokument)')
d319704a Moritz Bunkus
. qq|</option>|;
}

#my $disabled= qq|disabled="disabled"|;
#$disabled='' if ($form->{elster} eq '1' );
if ($form->{elster} eq '1') {
$format .=
2e2e8ce6 Udo Spallek
qq|<option value=elsterwinston>|
6c3f16ab Udo Spallek
. $locale->text('ELSTER Export (Winston)')
2e2e8ce6 Udo Spallek
. qq|</option>|
. qq|<option value=elstertaxbird>|
6c3f16ab Udo Spallek
. $locale->text('ELSTER Export (Taxbird)')
2e2e8ce6 Udo Spallek
. qq|</option>|;
d319704a Moritz Bunkus
}

#$format .= qq|<option value=elster>|.$locale->text('ELSTER Export nach Winston').qq|</option>|;
a205ed21 Udo Spallek
my $show_options = qq|
d319704a Moritz Bunkus
$type
$media
<select name=format title = "|
6c3f16ab Udo Spallek
. $locale->text('Choose Outputformat') . qq|">$format</select>
d319704a Moritz Bunkus
|;
$lxdebug->leave_sub();
a205ed21 Udo Spallek
return $show_options;
d319704a Moritz Bunkus
}

sub generate_ustva {
$lxdebug->enter_sub();

0246e125 Moritz Bunkus
# Aufruf von get_config zum Einlesen der Finanzamtdaten aus finanzamt.ini
d319704a Moritz Bunkus
0246e125 Moritz Bunkus
USTVA->get_config($userspath, 'finanzamt.ini');
d319704a Moritz Bunkus
6ab3da45 Udo Spallek
# init some form vars
d319704a Moritz Bunkus
my @anmeldungszeitraum =
b85b47c5 Udo Spallek
qw('0401' '0402' '0403'
'0404' '0405' '0406'
'0407' '0408' '0409'
'0410' '0411' '0412'
'0441' '0442' '0443' '0444');

2e2e8ce6 Udo Spallek
foreach my $item (@anmeldungszeitraum) {
d319704a Moritz Bunkus
$form->{$item} = "";
}

#forgotten the year --> thisyear
if ($form->{year} !~ m/^\d\d\d\d$/) {
081a4f97 Moritz Bunkus
$form->{year} = substr(
$form->datetonum(
$form->current_date(\%myconfig), \%myconfig
),
0, 4);
$lxdebug->message(LXDebug::DEBUG1,
qq|Actual year from Database: $form->{year}\n|);
d319704a Moritz Bunkus
}

6ab3da45 Udo Spallek
#
# using dates in ISO-8601 format: yyyymmmdd for Postgres...
#
d319704a Moritz Bunkus
#yearly report
2e2e8ce6 Udo Spallek
if ($form->{period} eq "13") {
63a1c75d Stephan Köhler
$form->{fromdate} = "$form->{year}0101";
$form->{todate} = "$form->{year}1231";
d319704a Moritz Bunkus
}

#Quater reports
2e2e8ce6 Udo Spallek
if ($form->{period} eq "41") {
63a1c75d Stephan Köhler
$form->{fromdate} = "$form->{year}0101";
$form->{todate} = "$form->{year}0331";
d319704a Moritz Bunkus
$form->{'0441'} = "X";
}
2e2e8ce6 Udo Spallek
if ($form->{period} eq "42") {
63a1c75d Stephan Köhler
$form->{fromdate} = "$form->{year}0401";
$form->{todate} = "$form->{year}0630";
d319704a Moritz Bunkus
$form->{'0442'} = "X";
}
2e2e8ce6 Udo Spallek
if ($form->{period} eq "43") {
63a1c75d Stephan Köhler
$form->{fromdate} = "$form->{year}0701";
$form->{todate} = "$form->{year}0930";
d319704a Moritz Bunkus
$form->{'0443'} = "X";
}
2e2e8ce6 Udo Spallek
if ($form->{period} eq "44") {
63a1c75d Stephan Köhler
$form->{fromdate} = "$form->{year}1001";
$form->{todate} = "$form->{year}1231";
d319704a Moritz Bunkus
$form->{'0444'} = "X";
}

#Monthly reports
SWITCH: {
2e2e8ce6 Udo Spallek
$form->{period} eq "01" && do {
63a1c75d Stephan Köhler
$form->{fromdate} = "$form->{year}0101";
$form->{todate} = "$form->{year}0131";
d319704a Moritz Bunkus
$form->{'0401'} = "X";
last SWITCH;
};
2e2e8ce6 Udo Spallek
$form->{period} eq "02" && do {
63a1c75d Stephan Köhler
$form->{fromdate} = "$form->{year}0201";
d319704a Moritz Bunkus
#this works from 1901 to 2099, 1900 and 2100 fail.
my $leap = ($form->{year} % 4 == 0) ? "29" : "28";
63a1c75d Stephan Köhler
$form->{todate} = "$form->{year}02$leap";
d319704a Moritz Bunkus
$form->{"0402"} = "X";
last SWITCH;
};
2e2e8ce6 Udo Spallek
$form->{period} eq "03" && do {
63a1c75d Stephan Köhler
$form->{fromdate} = "$form->{year}0301";
$form->{todate} = "$form->{year}0331";
d319704a Moritz Bunkus
$form->{"0403"} = "X";
last SWITCH;
};
2e2e8ce6 Udo Spallek
$form->{period} eq "04" && do {
63a1c75d Stephan Köhler
$form->{fromdate} = "$form->{year}0401";
$form->{todate} = "$form->{year}0430";
d319704a Moritz Bunkus
$form->{"0404"} = "X";
last SWITCH;
};
2e2e8ce6 Udo Spallek
$form->{period} eq "05" && do {
63a1c75d Stephan Köhler
$form->{fromdate} = "$form->{year}0501";
$form->{todate} = "$form->{year}0531";
d319704a Moritz Bunkus
$form->{"0405"} = "X";
last SWITCH;
};
2e2e8ce6 Udo Spallek
$form->{period} eq "06" && do {
63a1c75d Stephan Köhler
$form->{fromdate} = "$form->{year}0601";
$form->{todate} = "$form->{year}0630";
d319704a Moritz Bunkus
$form->{"0406"} = "X";
last SWITCH;
};
2e2e8ce6 Udo Spallek
$form->{period} eq "07" && do {
63a1c75d Stephan Köhler
$form->{fromdate} = "$form->{year}0701";
$form->{todate} = "$form->{year}0731";
d319704a Moritz Bunkus
$form->{"0407"} = "X";
last SWITCH;
};
2e2e8ce6 Udo Spallek
$form->{period} eq "08" && do {
63a1c75d Stephan Köhler
$form->{fromdate} = "$form->{year}0801";
$form->{todate} = "$form->{year}0831";
d319704a Moritz Bunkus
$form->{"0408"} = "X";
last SWITCH;
};
2e2e8ce6 Udo Spallek
$form->{period} eq "09" && do {
63a1c75d Stephan Köhler
$form->{fromdate} = "$form->{year}0901";
$form->{todate} = "$form->{year}0930";
d319704a Moritz Bunkus
$form->{"0409"} = "X";
last SWITCH;
};
2e2e8ce6 Udo Spallek
$form->{period} eq "10" && do {
63a1c75d Stephan Köhler
$form->{fromdate} = "$form->{year}1001";
$form->{todate} = "$form->{year}1031";
d319704a Moritz Bunkus
$form->{"0410"} = "X";
last SWITCH;
};
2e2e8ce6 Udo Spallek
$form->{period} eq "11" && do {
63a1c75d Stephan Köhler
$form->{fromdate} = "$form->{year}1101";
$form->{todate} = "$form->{year}1130";
d319704a Moritz Bunkus
$form->{"0411"} = "X";
last SWITCH;
};
2e2e8ce6 Udo Spallek
$form->{period} eq "12" && do {
63a1c75d Stephan Köhler
$form->{fromdate} = "$form->{year}1201";
$form->{todate} = "$form->{year}1231";
d319704a Moritz Bunkus
$form->{"0412"} = "X";
last SWITCH;
};
}

b85b47c5 Udo Spallek
# Kontrollvariable f?r die Templates
$form->{'year2007'} = ($form->{year} >= 2007 ) ? "1":"0";
6ab3da45 Udo Spallek

# Get the USTVA
82ee2234 Stephan Köhler
USTVA->ustva(\%myconfig, \%$form);
081a4f97 Moritz Bunkus
63a1c75d Stephan Köhler
# reformat Dates to dateformat
081a4f97 Moritz Bunkus
$form->{fromdate} = $locale->date(\%myconfig, $form->{fromdate}, 0, 0, 0);

6ab3da45 Udo Spallek
$form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
081a4f97 Moritz Bunkus
$form->{todate} = $locale->date(\%myconfig, $form->{todate}, 0, 0, 0);
d319704a Moritz Bunkus
2e2e8ce6 Udo Spallek
$form->{longperiod} =
d319704a Moritz Bunkus
$locale->date(\%myconfig, $form->current_date(\%myconfig), 1, 0, 0);
63a1c75d Stephan Köhler
d319704a Moritz Bunkus
# if there are any dates construct a where
if ($form->{fromdate} || $form->{todate}) {

2e2e8ce6 Udo Spallek
$form->{todate} = $form->current_date($myconfig) unless ($form->{todate});
d319704a Moritz Bunkus
my $longtodate = $locale->date($myconfig, $form->{todate}, 1, 0, 0);
my $shorttodate = $locale->date($myconfig, $form->{todate}, 0, 0, 0);

my $longfromdate = $locale->date($myconfig, $form->{fromdate}, 1, 0, 0);
my $shortfromdate = $locale->date($myconfig, $form->{fromdate}, 0, 0, 0);

$form->{this_period} = "$shortfromdate<br>\n$shorttodate";
2e2e8ce6 Udo Spallek
$form->{longperiod} =
d319704a Moritz Bunkus
$locale->text('for Period')
. qq|<br>\n$longfromdate |
6c3f16ab Udo Spallek
. $locale->text('to (date)')
d319704a Moritz Bunkus
. qq| $longtodate|;
}

if ($form->{comparefromdate} || $form->{comparetodate}) {
my $longcomparefromdate =
$locale->date(\%myconfig, $form->{comparefromdate}, 1, 0, 0);
my $shortcomparefromdate =
$locale->date(\%myconfig, $form->{comparefromdate}, 0, 0, 0);

my $longcomparetodate =
$locale->date(\%myconfig, $form->{comparetodate}, 1, 0, 0);
my $shortcomparetodate =
$locale->date(\%myconfig, $form->{comparetodate}, 0, 0, 0);

$form->{last_period} = "$shortcomparefromdate<br>\n$shortcomparetodate";
2e2e8ce6 Udo Spallek
$form->{longperiod} .=
d319704a Moritz Bunkus
"<br>\n$longcomparefromdate "
6c3f16ab Udo Spallek
. $locale->text('to (date)')
d319704a Moritz Bunkus
. qq| $longcomparetodate|;
}

$form->{Datum_heute} =
$locale->date(\%myconfig, $form->current_date(\%myconfig), 0, 0, 0);

# setup variables for the form
4dd73ccf Stephan Köhler
my @a = qw(company businessnumber tel fax email
co_chief co_department co_custom1 co_custom2 co_custom3 co_custom4 co_custom5
co_name1 co_name2 co_street co_street1 co_zip co_city co_city1 co_country co_tel co_tel1 co_tel2
co_fax co_fax1 co_email co_email1 co_url co_url1 ustid duns
co_bankname co_bankname1 co_bankname2 co_bankname3 co_blz co_blz1
co_blz2 co_blz3 co_accountnr co_accountnr1 co_accountnr2 co_accountnr3);

d319704a Moritz Bunkus
map { $form->{$_} = $myconfig{$_} } @a;

if ($form->{address} ne '') {
my $temp = $form->{address};
$temp =~ s/\\n/<br \/>/;
4dd73ccf Stephan Köhler
($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp);
b39c8ce9 Moritz Bunkus
$form->{co_city} =~ s/\\n//g;
d319704a Moritz Bunkus
}

18942bd7 Udo Spallek
################################
6ab3da45 Udo Spallek
#
18942bd7 Udo Spallek
# Nation specific customisations
6ab3da45 Udo Spallek
#
18942bd7 Udo Spallek
################################
# Germany
if ( $form->{coa} eq 'Germany-DATEV-SKR03EU' or $form->{coa} eq 'Germany-DATEV-SKR04EU') {
#
# Outputformat specific customisation's
#
6ab3da45 Udo Spallek
18942bd7 Udo Spallek
my @category_cent = qw(
511 861 36 80 971 931 98 96 53 74
85 65 66 61 62 67 63 64 59 69
39 83 811 891 Z43 Z45 Z53 Z62 Z65 Z67
);
6ab3da45 Udo Spallek
18942bd7 Udo Spallek
my @category_euro = qw(
41 44 49 43 48 51 86 35 77 76 91 89
97 93 95 94 42 60 45 52 73 84 81
);
$form->{id} = [];
$form->{amount} = [];
6ab3da45 Udo Spallek
18942bd7 Udo Spallek
if ( $form->{format} eq 'pdf' or $form->{format} eq 'postscript') {
2e2e8ce6 Udo Spallek
18942bd7 Udo Spallek
$form->{IN} = "$form->{type}-$form->{year}.tex";
$form->{padding} = "~~";
$form->{bold} = "\textbf{";
$form->{endbold} = "}";
$form->{br} = '\\\\';
d319704a Moritz Bunkus
18942bd7 Udo Spallek
# Zahlenformatierung f?r Latex USTVA Formulare
6ab3da45 Udo Spallek
18942bd7 Udo Spallek
foreach my $number (@category_euro) {
$form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '');
}
6ab3da45 Udo Spallek
18942bd7 Udo Spallek
my ${decimal_comma} = ( $myconfig{numberformat} eq '1.000,00'
or $myconfig{numberformat} eq '1000,00' ) ? ',':'.';
6ab3da45 Udo Spallek
18942bd7 Udo Spallek
foreach my $number (@category_cent) {
$form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '');
$form->{$number} =~ s/${decimal_comma}/~~/g;
}
6ab3da45 Udo Spallek
18942bd7 Udo Spallek
} elsif ( $form->{format} eq 'html') { # Formatierungen f?r HTML Ausgabe
081a4f97 Moritz Bunkus
18942bd7 Udo Spallek
$form->{IN} = $form->{type} . '.html';
$form->{padding} = "&nbsp;&nbsp;";
$form->{bold} = "<b>";
$form->{endbold} = "</b>";
$form->{br} = "<br>";
$form->{address} =~ s/\\n/\n/g;
d319704a Moritz Bunkus
18942bd7 Udo Spallek
foreach $number (@category_cent) {
$form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '0');
}
foreach $number (@category_euro) {
$form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '0');
}
081a4f97 Moritz Bunkus
18942bd7 Udo Spallek
} elsif ( $form->{format} eq 'elsterwinston' ) {
6ab3da45 Udo Spallek
18942bd7 Udo Spallek
$form->{IN} = 'winston.xml';
#
# Build Winston filename
#
my $file = 'U'; # 1. char 'U' = USTVA
$file .= $form->{period};
#4. and 5. char = year modulo 100
$file .= sprintf("%02d", $form->{year} % 100);
#6. to 18. char = Elstersteuernummer
#Beispiel: Steuernummer in Bayern
#111/222/33334 ergibt f?r UStVA Jan 2004: U01049111022233334
$file .= $form->{elsterFFFF};
$file .= $form->{elstersteuernummer};
#file suffix
$file .= '.xml';
$form->{tmpfile} = "$userspath/$file";

$form->{attachment_filename} = "$file";
# Zahlenformatierung f?r Winston

my $temp_numberformat = $myconfig{numberformat};

# Numberformat must be '1000.00' for Winston

$myconfig{numberformat} = '1000.00';

foreach my $number (@category_cent) {
$form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '2', '') : '';
}
foreach my $number (@category_euro) {
$form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '0', '') : '';
}
# Re-set Numberformat
$myconfig{numberformat} = $temp_numberformat;
6ab3da45 Udo Spallek

18942bd7 Udo Spallek
# push Kennziffern to <%foreach Array fo easyer
# output in xml format. Thx to Moritz.
my %winston_id_for = (
# No Winston remap?!
);
6ab3da45 Udo Spallek
18942bd7 Udo Spallek
foreach my $kennziffer (@category_cent, @category_euro) {
6ab3da45 Udo Spallek
18942bd7 Udo Spallek
next if ( $kennziffer =~ m/Z\d\d/);
next if ( $form->{$kennziffer} == 0 );
if (defined $winston_id_for{$kennziffer} ) {
push(@{ $form->{id}}, $winston_id_for{$kennziffer});
} else {
push(@{ $form->{id}}, "$kennziffer");
}
push(@{ $form->{amount}}, $form->{$kennziffer});
}
6ab3da45 Udo Spallek

18942bd7 Udo Spallek
} elsif ( $form->{format} eq 'elstertaxbird' ) {
b9c7197f Udo Spallek
18942bd7 Udo Spallek
# Define serveral filenames
$form->{IN} = 'taxbird.txb';
b9c7197f Udo Spallek
18942bd7 Udo Spallek
$form->{attachment_filename} = "USTVA-" . $form->{period}
. sprintf("%02d", $form->{year} % 100) . ".txb";
$form->{tmpfile} = "$userspath/" . $form->{attachment_filename};

# TODO: set Output to UTF-8 or system Preference
#$form->{"iconv"} = Text::Iconv->new($myconfig{dbcharset}, "UTF-8");
#my $iconv = $self->{"iconv"};
#$iconv->convert($variable);
if ($form->{period} =~ /^[4]\d$/ ){
my %periods = ( # Lx => taxbird
'41' => '12',
'42' => '13',
'43' => '14',
'44' => '15',
);
b9c7197f Udo Spallek
18942bd7 Udo Spallek
foreach my $quarter ( keys %periods ) {
$form->{taxbird_period} = $periods{$quarter} if ( $form->{period} eq $quarter);
}
} elsif ($form->{period} =~ /^\d+$/ ) {
$form->{period} =~ s/^0//g;
my $period = $form->{period};
$period * 1;
$period--;
$form->{period} = $period;
b9c7197f Udo Spallek
} else {
18942bd7 Udo Spallek
$form->header;
USTVA::error( $locale->text('Wrong Period' ));
exit(0);
b9c7197f Udo Spallek
}
18942bd7 Udo Spallek
my %lands = ( # Lx => taxbird # TODO: besser als array...
'Baden W?rtemberg' => '0',
'Bayern' => '1',
'Berlin' => '2',
'Brandenburg' => '3',
'Bremen' => '4',
'Hamburg' => '5',
'Hessen' => '6',
'Mecklenburg Vorpommern' => '7',
'Niedersachsen' => '8',
'Nordrhein Westfalen' => '9',
'Rheinland Pfalz' => '10',
'Saarland' => '11',
'Sachsen' => '12',
'Sachsen Anhalt' => '13',
'Schleswig Holstein' => '14',
'Th?ringen' => '15',
);
foreach my $land ( keys %lands ){
$form->{taxbird_land_nr} = $lands{$land} if ($form->{elsterland} eq $land );
}
$form->{co_zip} = $form->{co_city};
$form->{co_zip} =~ s/\D//g;
$form->{co_city} =~ s/\d//g;
$form->{co_city} =~ s/^\s//g;
($form->{co_phone_prefix}, $form->{co_phone}) = split("-", $form->{tel});
$form->{co_phone_prefix} =~ s/\s//g;
$form->{co_phone} =~ s/\s//g;
$form->{taxbird_steuernummer} = $form->{steuernummer};
# $form->{taxbird_steuernummer} =~ s/\D//g;
$form->{taxbird_steuernummer} =~ s/\///; # ersten Querstrich ersetzen
# Numberformatting for Taxbird
my $temp_numberformat = $myconfig{numberformat};
# Numberformat must be '1000,00' for Taxbird ?!
$myconfig{numberformat} = '1000,00';
foreach my $number (@category_cent) {
$form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '2', '') : '';
}
foreach my $number (@category_euro) {
$form->{$number} = ( $form->{$number} !=0 ) ? $form->format_amount(\%myconfig, $form->{$number}, '0', '') : '';
}
# Re-set Numberformat
$myconfig{numberformat} = $temp_numberformat;
# push Kennziffern to <%foreach Array fo easyer
# output in xml format. Thx to Moritz.
my %taxbird_id_for = (
'511' => 'Kz51-calc',
'861' => 'Kz86-calc',
'971' => 'Kz97-calc',
'931' => 'Kz93-calc',
'811' => 'Kz81-calc',
'891' => 'Kz89-calc',
'Z45' => 'uebertrag',
'Z53' => 'ust-sum',
'Z62' => 'ust-minus-vost',
'Z65' => 'ust-sum+69',
'Z67' => 'ust-vz',
);
for my $kennziffer (@category_cent, @category_euro) {
6ab3da45 Udo Spallek
18942bd7 Udo Spallek
next if ($kennziffer eq 'Z43');
6ab3da45 Udo Spallek
18942bd7 Udo Spallek
if ($form->{$kennziffer} != 0){
if (defined $taxbird_id_for{$kennziffer}) {
push(@{ $form->{id}}, $taxbird_id_for{$kennziffer});
} else {
push(@{ $form->{id}}, "Kz$kennziffer");
}
push(@{ $form->{amount}}, $form->{$kennziffer});
}
}
} elsif ( $form->{format} eq '' ){ # No format error.
6ab3da45 Udo Spallek
$form->header;
18942bd7 Udo Spallek
USTVA::error( $locale->text('Application Error. No Format given' ) . "!");
exit(0);
} else { # All other Formats are wrong
$form->header;
USTVA::error( $locale->text('Application Error. Wrong Format') . ": " . $form->{format} );
6ab3da45 Udo Spallek
exit(0);
2e2e8ce6 Udo Spallek
}
18942bd7 Udo Spallek
# Austria
} elsif ($form->{coa} eq 'Austria') {

#
# Outputformat specific customisation's
#

my @category_euro = qw(
511 861 36 80 971 931 98 96 53 74
85 65 66 61 62 67 63 64 59 69
39 83 811 891 Z43 Z45 Z53 Z62 Z65 Z67
41 44 49 43 48 51 86 35 77 76 91 89
97 93 95 94 42 60 45 52 73 84 81
11e6f144 Udo Spallek
);

18942bd7 Udo Spallek
if ( $form->{format} eq 'html') { # Formatierungen f?r HTML Ausgabe
11e6f144 Udo Spallek
18942bd7 Udo Spallek
$form->{IN} = $form->{type} . '.html';
$form->{padding} = "&nbsp;&nbsp;";
$form->{bold} = "<b>";
$form->{endbold} = "</b>";
$form->{br} = "<br>";
$form->{address} =~ s/\\n/\n/g;

foreach $number (@category_euro) {
$form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '0');
11e6f144 Udo Spallek
}
18942bd7 Udo Spallek
}
11e6f144 Udo Spallek
2e2e8ce6 Udo Spallek
}
6ab3da45 Udo Spallek
18942bd7 Udo Spallek
# end nation specific customisations
11e6f144 Udo Spallek
6ab3da45 Udo Spallek
if ( $form->{period} eq '13' and $form->{format} ne 'html') {
$form->header;
USTVA::info(
$locale->text(
'Yearly taxreport not yet implemented')
. '!');
}
2e2e8ce6 Udo Spallek
$form->{templates} = $myconfig{templates};
$form->{templates} = "doc" if ( $form->{type} eq 'help' );
d319704a Moritz Bunkus
6ab3da45 Udo Spallek
$form->parse_template(\%myconfig, $userspath);
d319704a Moritz Bunkus
d726f05a Moritz Bunkus
$lxdebug->leave_sub();
d319704a Moritz Bunkus
}

a205ed21 Udo Spallek
sub config_step1 {
d319704a Moritz Bunkus
$lxdebug->enter_sub();
081a4f97 Moritz Bunkus
d319704a Moritz Bunkus
# edit all taxauthority prefs

$form->header;
0246e125 Moritz Bunkus
USTVA->get_config($userspath, 'finanzamt.ini');
d319704a Moritz Bunkus
my $land = $form->{elsterland};
my $amt = $form->{elsterFFFF};

a205ed21 Udo Spallek
if ($form->{cbscript} ne '' and $form->{cblogin} ne '') {
$callback = qq|$form->{cbscript}|
.qq|?action="config_step1"|
.qq|&login="$form->{cblogin}"|
.qq|&path="$form->{cbpath}"|
.qq|&root="$form->{cbroot}"|
.qq|&rpw="$form->{cbrpw}"|;
}
4dd73ccf Stephan Köhler
6c3f16ab Udo Spallek
$form->{title} = $locale->text('Tax Office Preferences');
d319704a Moritz Bunkus

a205ed21 Udo Spallek
my $select_tax_office = USTVA->fa_auswahl($land, $amt, &elster_hash());
my $checked_accrual = q|checked="checked"| if ($form->{method} eq 'accrual');
my $checked_cash = q|checked="checked"| if ($form->{method} eq 'cash');
my $checked_monthly = "checked" if ($form->{FA_voranmeld} eq 'month');
my $checked_quarterly = "checked" if ($form->{FA_voranmeld} eq 'quarter');
my $checked_dauerfristverlaengerung = "checked" if ($form->{FA_dauerfrist} eq '1');
my $checked_kz_71 = "checked" if ($form->{FA_71} eq 'X');
d319704a Moritz Bunkus
a205ed21 Udo Spallek
my $_hidden_variables_ref;
d319704a Moritz Bunkus
a205ed21 Udo Spallek
my %_hidden_local_variables = (
'saved' => $locale->text('Check Details'),
'nextsub' => 'config_step2',
'warnung' => '0',
);

foreach my $variable (keys %_hidden_local_variables) {
push @{ $_hidden_variables_ref },
{ 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
}
d319704a Moritz Bunkus
a205ed21 Udo Spallek
my @_hidden_form_variables = qw(
FA_Name FA_Strasse FA_PLZ
FA_Ort FA_Telefon FA_Fax
FA_PLZ_Grosskunden FA_PLZ_Postfach FA_Postfach
FA_BLZ_1 FA_Kontonummer_1 FA_Bankbezeichnung_1
FA_BLZ_2 FA_Kontonummer_2 FA_Bankbezeichnung_oertlich
FA_Oeffnungszeiten FA_Email FA_Internet
steuernummer elsterland elstersteuernummer
elsterFFFF path login
password
);
d319704a Moritz Bunkus
a205ed21 Udo Spallek
foreach my $variable (@_hidden_form_variables) {
push @{ $_hidden_variables_ref},
{ 'variable' => $variable, 'value' => $form->{$variable} };
d319704a Moritz Bunkus
}

a205ed21 Udo Spallek
# h?? kann die weg?
my $steuernummer_new = '';

# Variablen f?r das Template zur Verf?gung stellen
my $template_ref = {
select_tax_office => $select_tax_office,
checked_accrual => $checked_accrual,
checked_cash => $checked_cash,
checked_monthly => $checked_monthly,
checked_quarterly => $checked_quarterly,
checked_dauerfristverlaengerung => $checked_dauerfristverlaengerung,
hidden_variables => $_hidden_variables_ref,
};
# Ausgabe des Templates
print($form->parse_html_template('ustva/config_step1', $template_ref));

d319704a Moritz Bunkus
$lxdebug->leave_sub();
}

a205ed21 Udo Spallek
sub config_step2 {
d319704a Moritz Bunkus
$lxdebug->enter_sub();
$form->header();
a205ed21 Udo Spallek
# print qq|
# <body>
# |;

d319704a Moritz Bunkus
my $elsterland = '';
my $elster_amt = '';
my $elsterFFFF = '';
my $elstersteuernummer = '';
0246e125 Moritz Bunkus
USTVA->get_config($userspath, 'finanzamt.ini')
d319704a Moritz Bunkus
if ($form->{saved} eq $locale->text('saved'));

# Auf ?bergabefehler checken
081a4f97 Moritz Bunkus
USTVA::info( $locale->text('Missing Tax Authoritys Preferences') . "\n"
. $locale->text('USTVA-Hint: Tax Authoritys'))
d319704a Moritz Bunkus
if ( $form->{elsterFFFF_new} eq 'Auswahl'
|| $form->{elsterland_new} eq 'Auswahl');
081a4f97 Moritz Bunkus
USTVA::info( $locale->text('Missing Method!') . "\n"
. $locale->text('USTVA-Hint: Method'))
d319704a Moritz Bunkus
if ($form->{method} eq '');

# Kl?ren, ob Variablen bereits bef?llt sind UND ob ver?derungen auf
# der vorherigen Maske stattfanden: $change = 1(in der edit sub,
# mittels get_config)

081a4f97 Moritz Bunkus
my $change = $form->{elsterland} eq $form->{elsterland_new}
d319704a Moritz Bunkus
&& $form->{elsterFFFF} eq $form->{elsterFFFF_new} ? '0' : '1';
$change = '0' if ($form->{saved} eq $locale->text('saved'));
my $elster_init = &elster_hash();

my %elster_init = %$elster_init;

if ($change eq '1') {

# Daten ?ndern
$elsterland = $form->{elsterland_new};
$elsterFFFF = $form->{elsterFFFF_new};
$form->{elsterland} = $elsterland;
$form->{elsterFFFF} = $elsterFFFF;
$form->{steuernummer} = '';
a205ed21 Udo Spallek
create_steuernummer();
d319704a Moritz Bunkus
# rebuild elster_amt
my $amt = '';
foreach $amt (keys %{ $elster_init{ $form->{elsterland} } }) {
$elster_amt = $amt
if ($elster_init{ $form->{elsterland}{$amt} eq $form->{elsterFFFF} });
}

# load the predefined hash data into the FA_* Vars
my @variables = qw(FA_Name FA_Strasse FA_PLZ FA_Ort
FA_Telefon FA_Fax FA_PLZ_Grosskunden FA_PLZ_Postfach
FA_Postfach
FA_BLZ_1 FA_Kontonummer_1 FA_Bankbezeichnung_1
FA_BLZ_2 FA_Kontonummer_2 FA_Bankbezeichnung_oertlich
FA_Oeffnungszeiten FA_Email FA_Internet);

for (my $i = 0; $i <= 20; $i++) {
$form->{ $variables[$i] } =
$elster_init->{$elsterland}->{$elsterFFFF}->[$i];
}

} else {

$elsterland = $form->{elsterland};
$elsterFFFF = $form->{elsterFFFF};

}
my $stnr = $form->{steuernummer};
$stnr =~ s/\D+//g;
my $patterncount = $form->{patterncount};
my $elster_pattern = $form->{elster_pattern};
my $delimiter = $form->{delimiter};
a205ed21 Udo Spallek
my $steuernummer = $form->{steuernummer} if ($steuernummer eq '');
d319704a Moritz Bunkus
a205ed21 Udo Spallek
$form->{FA_Oeffnungszeiten} =~ s/\\\\n/\n/g;

my $input_steuernummer = USTVA->steuernummer_input(
$form->{elsterland},
$form->{elsterFFFF},
$form->{steuernummer}
);

$lxdebug->message(LXDebug::DEBUG1, qq|$input_steuernummer|);

my $_hidden_variables_ref;
d319704a Moritz Bunkus
a205ed21 Udo Spallek
my %_hidden_local_variables = (
'elsterland' => $elsterland,
'elsterFFFF' => $elsterFFFF,
'warnung' => $warnung,
'elstersteuernummer' => $elstersteuernummer,
'steuernummer' => $stnr,
'lastsub' => 'config_step1',
'nextsub' => 'save',
d319704a Moritz Bunkus
);
a205ed21 Udo Spallek
foreach my $variable (keys %_hidden_local_variables) {
push @{ $_hidden_variables_ref },
{ 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
d319704a Moritz Bunkus
}
a205ed21 Udo Spallek
my @_hidden_form_variables = qw(
FA_steuerberater_name FA_steuerberater_street
FA_steuerberater_city FA_steuerberater_tel
FA_voranmeld method
FA_dauerfrist FA_71
elster path
login password
type elster_init
saved callback
);



foreach my $variable (@_hidden_form_variables) {
push @{ $_hidden_variables_ref},
{ 'variable' => $variable, 'value' => $form->{$variable} };
}

my $template_ref = {
tax_office_data => $tax_office_data,
input_steuernummer => $input_steuernummer,
readonly => '', #q|disabled="disabled"|,
callback => $callback,
hidden_variables => $_hidden_variables_ref,
};
# Ausgabe des Templates
print($form->parse_html_template('ustva/config_step2', $template_ref));


d319704a Moritz Bunkus
$lxdebug->leave_sub();
}

sub create_steuernummer {
$lxdebug->enter_sub();
my $part = $form->{part};
my $patterncount = $form->{patterncount};
my $delimiter = $form->{delimiter};
my $elster_pattern = $form->{elster_pattern};

# rebuild steuernummer and elstersteuernummer
# es gibt eine gespeicherte steuernummer $form->{steuernummer}
# und die parts und delimiter

my $h = 0;
my $i = 0;

my $steuernummer_new = $part;
my $elstersteuernummer_new = $form->{elster_FFFF};
$elstersteuernummer_new .= '0';

for ($h = 1; $h < $patterncount; $h++) {
$steuernummer_new .= qq|$delimiter|;
for (my $i = 1; $i <= length($elster_pattern); $i++) {
$steuernummer_new .= $form->{"part_$h\_$i"};
$elstersteuernummer_new .= $form->{"part_$h\_$i"};
}
}
if ($form->{steuernummer} ne $steuernummer_new) {
$form->{steuernummer} = $steuernummer_new;
$form->{elstersteuernummer} = $elstersteuernummer_new;
$form->{steuernummer_new} = $steuernummer_new;
} else {
$form->{steuernummer_new} = '';
$form->{elstersteuernummer_new} = '';
}
$lxdebug->leave_sub();
}

sub save {
$lxdebug->enter_sub();
4dd73ccf Stephan Köhler
my $filename = "$form->{login}_$form->{filename}";
d319704a Moritz Bunkus
#zuerst die steuernummer aus den part, parts_X_Y und delimiter herstellen
a205ed21 Udo Spallek
create_steuernummer();
d319704a Moritz Bunkus
# Textboxen formatieren: Linebreaks entfernen
#
$form->{FA_Oeffnungszeiten} =~ s/\r\n/\\n/g;

#URL mit http:// davor?
$form->{FA_Internet} =~ s/^http:\/\///;
$form->{FA_Internet} = 'http://' . $form->{FA_Internet};

785ef602 Udo Spallek
my @config = qw(
elster elsterland elstersteuernummer steuernummer
elsteramt elsterFFFF FA_Name FA_Strasse
FA_PLZ FA_Ort FA_Telefon FA_Fax
FA_PLZ_Grosskunden FA_PLZ_Postfach FA_Postfach FA_BLZ_1
FA_Kontonummer_1 FA_Bankbezeichnung_1 FA_BLZ_2 FA_Kontonummer_2
d319704a Moritz Bunkus
FA_Bankbezeichnung_oertlich FA_Oeffnungszeiten
FA_Email FA_Internet FA_voranmeld method FA_steuerberater_name
FA_steuerberater_street FA_steuerberater_city FA_steuerberater_tel
FA_71 FA_dauerfrist);

# Hier kommt dann die Plausibilit?tspr?fung der ELSTERSteuernummer
if ($form->{elstersteuernummer} ne '000000000') {
$form->{elster} = '1';
open(CONF, ">$userspath/$filename") or $form->error("$filename : $!");

# create the config file
print CONF qq|# Configuration file for USTVA\n\n|;
my $key = '';
foreach $key (sort @config) {
$form->{$key} =~ s/\\/\\\\/g;
# strip M
$form->{$key} =~ s/\r\n/\n/g;
a205ed21 Udo Spallek
d319704a Moritz Bunkus
print CONF qq|$key=|;
if ($form->{$key} ne 'Y') {
print CONF qq|$form->{$key}\n|;
}
if ($form->{$key} eq 'Y') {
print CONF qq|checked \n|;
}
}
print CONF qq|\n\n|;
close CONF;
$form->{saved} = $locale->text('saved');

} else {

6c3f16ab Udo Spallek
$form->{saved} = $locale->text('Choose a Tax Number');
d319704a Moritz Bunkus
}

a205ed21 Udo Spallek
config_step2();
d319704a Moritz Bunkus
$lxdebug->leave_sub();
}


sub continue {
$lxdebug->enter_sub();
081a4f97 Moritz Bunkus
d319704a Moritz Bunkus
# allow Symbolic references just here:
no strict 'refs';
40782548 Moritz Bunkus
call_sub($form->{"nextsub"});
d319704a Moritz Bunkus
use strict 'refs';
$lxdebug->leave_sub();
}

081a4f97 Moritz Bunkus
sub back {
4dd73ccf Stephan Köhler
$lxdebug->enter_sub();
40782548 Moritz Bunkus
call_sub($form->{"lastsub"});
4dd73ccf Stephan Köhler
$lxdebug->leave_sub();
}
d319704a Moritz Bunkus
sub elster_hash {
$lxdebug->enter_sub();
a205ed21 Udo Spallek
my $finanzamt = USTVA->query_finanzamt(\%myconfig, \%$form);
d319704a Moritz Bunkus
$lxdebug->leave_sub();
return $finanzamt;
}