package USTVA;
+use List::Util qw(first);
+
use SL::DBUtils;
+my @tax_office_information = (
+ { 'id' => 8, 'name' => 'Baden Württemberg', 'taxbird_nr' => '0', 'elster_format' => 'FF/BBB/UUUUP', },
+ { 'id' => 9, 'name' => 'Bayern', 'taxbird_nr' => '1', 'elster_format' => 'FFF/BBB/UUUUP', },
+ { 'id' => 11, 'name' => 'Berlin', 'taxbird_nr' => '2', 'elster_format' => 'FF/BBB/UUUUP', },
+ { 'id' => 12, 'name' => 'Brandenburg', 'taxbird_nr' => '3', 'elster_format' => 'FFF/BBB/UUUUP', },
+ { 'id' => 4, 'name' => 'Bremen', 'taxbird_nr' => '4', 'elster_format' => 'FF BBB UUUUP', },
+ { 'id' => 2, 'name' => 'Hamburg', 'taxbird_nr' => '5', 'elster_format' => 'FF/BBB/UUUUP', },
+ { 'id' => 6, 'name' => 'Hessen', 'taxbird_nr' => '6', 'elster_format' => '0FF BBB UUUUP', },
+ { 'id' => 13, 'name' => 'Mecklenburg Vorpommern', 'taxbird_nr' => '7', 'elster_format' => 'FFF/BBB/UUUUP', },
+ { 'id' => 3, 'name' => 'Niedersachsen', 'taxbird_nr' => '8', 'elster_format' => 'FF/BBB/UUUUP', },
+ { 'id' => 5, 'name' => 'Nordrhein Westfalen', 'taxbird_nr' => '9', 'elster_format' => 'FFF/BBBB/UUUP', },
+ { 'id' => 7, 'name' => 'Rheinland Pfalz', 'taxbird_nr' => '10', 'elster_format' => 'FF/BBB/UUUU/P', },
+ { 'id' => 10, 'name' => 'Saarland', 'taxbird_nr' => '11', 'elster_format' => 'FFF/BBB/UUUUP', },
+ { 'id' => 14, 'name' => 'Sachsen', 'taxbird_nr' => '12', 'elster_format' => 'FFF/BBB/UUUUP', },
+ { 'id' => 15, 'name' => 'Sachsen Anhalt', 'taxbird_nr' => '13', 'elster_format' => 'FFF/BBB/UUUUP', },
+ { 'id' => 1, 'name' => 'Schleswig Holstein', 'taxbird_nr' => '14', 'elster_format' => 'FF BBB UUUUP', },
+ { 'id' => 16, 'name' => 'Thüringen', 'taxbird_nr' => '15', 'elster_format' => 'FFF/BBB/UUUUP', },
+ );
+
+sub new {
+ my $type = shift;
+
+ my $self = {};
+
+ bless $self, $type;
+
+ $self->_init(@_);
+
+ return $self;
+}
+
+sub _init {
+ my $self = shift;
+
+ $self->{tax_office_information} = [];
+
+ foreach (@tax_office_information) {
+ my $entry = \%{ $_ };
+ $entry->{name} = $main::locale->{iconv_iso8859}->convert($entry->{name});
+ push @{ $self->{tax_office_information} }, $entry;
+ }
+}
+
sub get_coa {
my ( $self, $form, $myconfig) = @_;
$stnr =~ s/\D+//g;
#Pattern description Elstersteuernummer
- my %elster_STNRformat = (
- 'Mecklenburg Vorpommern' => 'FFF/BBB/UUUUP', # '/' 3
- 'Hessen' => '0FF BBB UUUUP', # ' ' 3
- 'Nordrhein Westfalen' => 'FFF/BBBB/UUUP', # '/' 3
- 'Schleswig Holstein' => 'FF BBB UUUUP', # ' ' 2
- 'Berlin' => 'FF/BBB/UUUUP', # '/' 3
- 'Thüringen' => 'FFF/BBB/UUUUP', # '/' 3
- 'Sachsen' => 'FFF/BBB/UUUUP', # '/' 3
- 'Hamburg' => 'FF/BBB/UUUUP', # '/' 3
- 'Baden Württemberg' => 'FF/BBB/UUUUP', # '/' 2
- 'Sachsen Anhalt' => 'FFF/BBB/UUUUP', # '/' 3
- 'Saarland' => 'FFF/BBB/UUUUP', # '/' 3
- 'Bremen' => 'FF BBB UUUUP', # ' ' 3
- 'Bayern' => 'FFF/BBB/UUUUP', # '/' 3
- 'Rheinland Pfalz' => 'FF/BBB/UUUU/P', # '/' 4
- 'Niedersachsen' => 'FF/BBB/UUUUP', # '/' 3
- 'Brandenburg' => 'FFF/BBB/UUUUP', # '/' 3
- );
#split the pattern
- my $elster_pattern = $elster_STNRformat{$elster_land};
+ my $tax_office = first { $_->{name} eq $elster_land } @{ $self->{tax_office_information} };
+ my $elster_pattern = $tax_office->{elster_format};
my @elster_pattern = split(' ', $elster_pattern);
my $delimiter = ' ';
my $patterncount = @elster_pattern;
my $checked = '';
$checked = 'checked' if ($elsterFFFF eq '' and $land eq '');
- #if ($ENV{HTTP_USER_AGENT} =~ /(mozilla|opera|w3m)/i){
- #$terminal='mozilla';
- #} elsif ($ENV{HTTP_USER_AGENT} =~ /(links|lynx)/i){
- #$terminal = 'lynx';
- #}
-
- #if ( $terminal eq 'mozilla' or $terminal eq 'js' ) {
my $fa_auswahl = qq|
<script language="Javascript">
function update_auswahl()
my $land = '';
foreach my $row (@$array_ref) {
my $FA_finanzamt = $row;
- $land = 'Schleswig Holstein' if (@$FA_finanzamt[0] eq '1');
- $land = 'Hamburg' if (@$FA_finanzamt[0] eq '2');
- $land = 'Niedersachsen' if (@$FA_finanzamt[0] eq '3');
- $land = 'Bremen' if (@$FA_finanzamt[0] eq '4');
- $land = 'Nordrhein Westfalen' if (@$FA_finanzamt[0] eq '5');
- $land = 'Hessen' if (@$FA_finanzamt[0] eq '6');
- $land = 'Rheinland Pfalz' if (@$FA_finanzamt[0] eq '7');
- $land = 'Baden Württemberg' if (@$FA_finanzamt[0] eq '8');
- $land = 'Bayern' if (@$FA_finanzamt[0] eq '9');
- $land = 'Saarland' if (@$FA_finanzamt[0] eq '10');
- $land = 'Berlin' if (@$FA_finanzamt[0] eq '11');
- $land = 'Brandenburg' if (@$FA_finanzamt[0] eq '12');
- $land = 'Mecklenburg Vorpommern' if (@$FA_finanzamt[0] eq '13');
- $land = 'Sachsen' if (@$FA_finanzamt[0] eq '14');
- $land = 'Sachsen Anhalt' if (@$FA_finanzamt[0] eq '15');
- $land = 'Thüringen' if (@$FA_finanzamt[0] eq '16');
-
- $land = $main::locale->{iconv}->convert($land);
+ my $tax_office = first { $_->{id} == $FA_finanzamt->[0] } @{ $self->{tax_office_information} };
+ $land = $tax_office->{name};
+
+ # $land = $main::locale->{iconv}->convert($land);
my $ffff = @$FA_finanzamt[1];
#our ($myconfig);
#use CGI::Carp "fatalsToBrowser";
+use List::Util qw(first);
+
use SL::PE;
use SL::RP;
use SL::USTVA;
$form->header;
# Einlesen der Finanzamtdaten
- USTVA->get_config($userspath, 'finanzamt.ini');
+ my $ustva = USTVA->new();
+ $ustva->get_config($userspath, 'finanzamt.ini');
# Hier Einlesen der user-config
# steuernummer entfernt für prerelease
# Which COA is in use?
- USTVA->get_coa($form, $myconfig);
+ $ustva->get_coa($form, $myconfig);
my $template_ref = {
openings => $openings,
# Aufruf von get_config zum Einlesen der Finanzamtdaten aus finanzamt.ini
- USTVA->get_config($userspath, 'finanzamt.ini');
+ my $ustva = USTVA->new();
+ $ustva->get_config($userspath, 'finanzamt.ini');
# init some form vars
my @anmeldungszeitraum =
# Get the USTVA
- USTVA->ustva(\%myconfig, \%$form);
+ $ustva->ustva(\%myconfig, \%$form);
# reformat Dates to dateformat
$form->{fromdate} = $locale->date(\%myconfig, $form->{fromdate}, 0, 0, 0);
# Outputformat specific customisation's
#
- my @category_cent = USTVA->report_variables({
+ my @category_cent = $ustva->report_variables({
myconfig => \%myconfig,
form => $form,
type => '',
push @category_cent, qw(83 Z43 Z45 Z53 Z62 Z65 Z67);
- my @category_euro = USTVA->report_variables({
+ my @category_euro = $ustva->report_variables({
myconfig => \%myconfig,
form => $form,
type => '',
exit(0);
}
- my %lands = ( # Lx => taxbird # TODO: besser als array...
- 'Baden Württemberg' => '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 );
- }
+ my $tax_office = first { $_->{name} eq $form->{elsterland} } @{ $ustva->{tax_office_information} };
+ $form->{taxbird_land_nr} = $tax_office->{taxbird_nr} if $tax_office;
$form->{co_zip} = $form->{co_city};
$form->{co_zip} =~ s/\D//g;
} else # Outputformat for generic output
{
- my @category_cent = USTVA->report_variables({
+ my @category_cent = $ustva->report_variables({
myconfig => \%myconfig,
form => $form,
type => '',
dec_places => '2',
});
- my @category_euro = USTVA->report_variables({
+ my @category_euro = $ustva->report_variables({
myconfig => \%myconfig,
form => $form,
type => '',
# edit all taxauthority prefs
$form->header;
- USTVA->get_config($userspath, 'finanzamt.ini');
+
+ my $ustva = USTVA->new();
+ $ustva->get_config($userspath, 'finanzamt.ini');
my $land = $form->{elsterland};
my $amt = $form->{elsterFFFF};
$form->{title} = $locale->text('Tax Office Preferences');
- my $select_tax_office = USTVA->fa_auswahl($land, $amt, &elster_hash());
+ my $select_tax_office = $ustva->fa_auswahl($land, $amt, $ustva->query_finanzamt(\%myconfig, $form));
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');
# Which COA is in use?
- USTVA->get_coa($form, \%myconfig);
+ $ustva->get_coa($form, \%myconfig);
# hä? kann die weg?
my $steuernummer_new = '';
my $elster_amt = '';
my $elsterFFFF = '';
my $elstersteuernummer = '';
- USTVA->get_config($userspath, 'finanzamt.ini')
+
+ my $ustva = USTVA->new();
+ $ustva->get_config($userspath, 'finanzamt.ini')
if ($form->{saved} eq $locale->text('saved'));
# Auf Übergabefehler checken
my $change = $form->{elsterland} eq $form->{elsterland_new}
&& $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 = $ustva->query_finanzamt(\%myconfig, $form);
my %elster_init = %$elster_init;
$form->{FA_Oeffnungszeiten} =~ s/\\\\n/\n/g;
- USTVA->get_coa($form, \%myconfig);
+ $ustva->get_coa($form, \%myconfig);
- my $input_steuernummer = USTVA->steuernummer_input(
+ my $input_steuernummer = $ustva->steuernummer_input(
$form->{elsterland},
$form->{elsterFFFF},
$form->{steuernummer}
$lxdebug->leave_sub();
}
-sub elster_hash {
- $lxdebug->enter_sub();
-
- $auth->assert('advance_turnover_tax_return');
-
- my $finanzamt = USTVA->query_finanzamt(\%myconfig, \%$form);
- $lxdebug->leave_sub();
- return $finanzamt;
-}