From: Moritz Bunkus Date: Tue, 5 May 2009 13:11:14 +0000 (+0000) Subject: Codecleanup UStVA & Bugfixes bei Verwendung von UTF-8 X-Git-Tag: release-2.6.0beta2~40 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=f8779cd3dec79719e2b4ef77ee70f44afabad8d8;p=kivitendo-erp.git Codecleanup UStVA & Bugfixes bei Verwendung von UTF-8 Das UStVA-Modul enthält hardgecodet die Namen der Bundesländer. Diese enthalten Umlaute, die in ISO-8859-1 codiert sind. Wird hingegen ein anderes Datenbank-Charset wie UTF-8 verwendet, so klappt die UStVA-Konfiguration nicht. Das wurde behoben, indem die Ländernamen nun zentral an einer Stelle verwaltet und in das Datenbankcharset konvertiert werden, bevor sie benutzt werden. Fix für Bug 952. --- diff --git a/SL/USTVA.pm b/SL/USTVA.pm index 0d114137f..ed0166986 100644 --- a/SL/USTVA.pm +++ b/SL/USTVA.pm @@ -25,8 +25,53 @@ 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) = @_; @@ -148,27 +193,10 @@ sub steuernummer_input { $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; @@ -259,13 +287,6 @@ sub fa_auswahl { 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|