Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f8779cd3

Von Moritz Bunkus vor mehr als 15 Jahren hinzugefügt

  • ID f8779cd3dec79719e2b4ef77ee70f44afabad8d8
  • Vorgänger df53c167
  • Nachfolger 33244697

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.

Unterschiede anzeigen:

SL/USTVA.pm
25 25

  
26 26
package USTVA;
27 27

  
28
use List::Util qw(first);
29

  
28 30
use SL::DBUtils;
29 31

  
32
my @tax_office_information = (
33
  { 'id' =>  8, 'name' => 'Baden W?rttemberg',      'taxbird_nr' => '0',  'elster_format' => 'FF/BBB/UUUUP',  },
34
  { 'id' =>  9, 'name' => 'Bayern',                 'taxbird_nr' => '1',  'elster_format' => 'FFF/BBB/UUUUP', },
35
  { 'id' => 11, 'name' => 'Berlin',                 'taxbird_nr' => '2',  'elster_format' => 'FF/BBB/UUUUP',  },
36
  { 'id' => 12, 'name' => 'Brandenburg',            'taxbird_nr' => '3',  'elster_format' => 'FFF/BBB/UUUUP', },
37
  { 'id' =>  4, 'name' => 'Bremen',                 'taxbird_nr' => '4',  'elster_format' => 'FF BBB UUUUP',  },
38
  { 'id' =>  2, 'name' => 'Hamburg',                'taxbird_nr' => '5',  'elster_format' => 'FF/BBB/UUUUP',  },
39
  { 'id' =>  6, 'name' => 'Hessen',                 'taxbird_nr' => '6',  'elster_format' => '0FF BBB UUUUP', },
40
  { 'id' => 13, 'name' => 'Mecklenburg Vorpommern', 'taxbird_nr' => '7',  'elster_format' => 'FFF/BBB/UUUUP', },
41
  { 'id' =>  3, 'name' => 'Niedersachsen',          'taxbird_nr' => '8',  'elster_format' => 'FF/BBB/UUUUP',  },
42
  { 'id' =>  5, 'name' => 'Nordrhein Westfalen',    'taxbird_nr' => '9',  'elster_format' => 'FFF/BBBB/UUUP', },
43
  { 'id' =>  7, 'name' => 'Rheinland Pfalz',        'taxbird_nr' => '10', 'elster_format' => 'FF/BBB/UUUU/P', },
44
  { 'id' => 10, 'name' => 'Saarland',               'taxbird_nr' => '11', 'elster_format' => 'FFF/BBB/UUUUP', },
45
  { 'id' => 14, 'name' => 'Sachsen',                'taxbird_nr' => '12', 'elster_format' => 'FFF/BBB/UUUUP', },
46
  { 'id' => 15, 'name' => 'Sachsen Anhalt',         'taxbird_nr' => '13', 'elster_format' => 'FFF/BBB/UUUUP', },
47
  { 'id' =>  1, 'name' => 'Schleswig Holstein',     'taxbird_nr' => '14', 'elster_format' => 'FF BBB UUUUP',  },
48
  { 'id' => 16, 'name' => 'Th?ringen',              'taxbird_nr' => '15', 'elster_format' => 'FFF/BBB/UUUUP', },
49
  );
50

  
51
sub new {
52
  my $type = shift;
53

  
54
  my $self = {};
55

  
56
  bless $self, $type;
57

  
58
  $self->_init(@_);
59

  
60
  return $self;
61
}
62

  
63
sub _init {
64
  my $self = shift;
65

  
66
  $self->{tax_office_information} = [];
67

  
68
  foreach (@tax_office_information) {
69
    my $entry      = \%{ $_ };
70
    $entry->{name} = $main::locale->{iconv_iso8859}->convert($entry->{name});
71
    push @{ $self->{tax_office_information} }, $entry;
72
  }
73
}
74

  
30 75
sub get_coa {
31 76

  
32 77
  my ( $self, $form, $myconfig) = @_;
......
148 193
  $stnr =~ s/\D+//g;
149 194

  
150 195
  #Pattern description Elstersteuernummer
151
  my %elster_STNRformat = (
152
      'Mecklenburg Vorpommern' => 'FFF/BBB/UUUUP',    # '/' 3
153
      'Hessen'                 => '0FF BBB UUUUP',    # ' ' 3
154
      'Nordrhein Westfalen'    => 'FFF/BBBB/UUUP',    # '/' 3
155
      'Schleswig Holstein'     => 'FF BBB UUUUP',     # ' ' 2
156
      'Berlin'                 => 'FF/BBB/UUUUP',     # '/' 3
157
      'Th?ringen'              => 'FFF/BBB/UUUUP',    # '/' 3
158
      'Sachsen'                => 'FFF/BBB/UUUUP',    # '/' 3
159
      'Hamburg'                => 'FF/BBB/UUUUP',     # '/' 3
160
      'Baden W?rttemberg'      => 'FF/BBB/UUUUP',     # '/' 2
161
      'Sachsen Anhalt'         => 'FFF/BBB/UUUUP',    # '/' 3
162
      'Saarland'               => 'FFF/BBB/UUUUP',    # '/' 3
163
      'Bremen'                 => 'FF BBB UUUUP',     # ' ' 3
164
      'Bayern'                 => 'FFF/BBB/UUUUP',    # '/' 3
165
      'Rheinland Pfalz'        => 'FF/BBB/UUUU/P',    # '/' 4
166
      'Niedersachsen'          => 'FF/BBB/UUUUP',     # '/' 3
167
      'Brandenburg'            => 'FFF/BBB/UUUUP',    # '/' 3
168
  );
169 196

  
170 197
  #split the pattern
171
  my $elster_pattern = $elster_STNRformat{$elster_land};
198
  my $tax_office     = first { $_->{name} eq $elster_land } @{ $self->{tax_office_information} };
199
  my $elster_pattern = $tax_office->{elster_format};
172 200
  my @elster_pattern = split(' ', $elster_pattern);
173 201
  my $delimiter      = ' ';
174 202
  my $patterncount   = @elster_pattern;
......
259 287
  my $checked  = '';
260 288
  $checked = 'checked' if ($elsterFFFF eq '' and $land eq '');
261 289

  
262
  #if ($ENV{HTTP_USER_AGENT} =~ /(mozilla|opera|w3m)/i){
263
  #$terminal='mozilla';
264
  #} elsif ($ENV{HTTP_USER_AGENT} =~ /(links|lynx)/i){
265
  #$terminal = 'lynx';
266
  #}
267

  
268
  #if ( $terminal eq 'mozilla' or $terminal eq 'js' ) {
269 290
  my $fa_auswahl = qq|
270 291
        <script language="Javascript">
271 292
        function update_auswahl()
......
538 559
  my $land      = '';
539 560
  foreach my $row (@$array_ref) {
540 561
    my $FA_finanzamt = $row;
541
    $land = 'Schleswig Holstein'     if (@$FA_finanzamt[0] eq '1');
542
    $land = 'Hamburg'                if (@$FA_finanzamt[0] eq '2');
543
    $land = 'Niedersachsen'          if (@$FA_finanzamt[0] eq '3');
544
    $land = 'Bremen'                 if (@$FA_finanzamt[0] eq '4');
545
    $land = 'Nordrhein Westfalen'    if (@$FA_finanzamt[0] eq '5');
546
    $land = 'Hessen'                 if (@$FA_finanzamt[0] eq '6');
547
    $land = 'Rheinland Pfalz'        if (@$FA_finanzamt[0] eq '7');
548
    $land = 'Baden W?rttemberg'      if (@$FA_finanzamt[0] eq '8');
549
    $land = 'Bayern'                 if (@$FA_finanzamt[0] eq '9');
550
    $land = 'Saarland'               if (@$FA_finanzamt[0] eq '10');
551
    $land = 'Berlin'                 if (@$FA_finanzamt[0] eq '11');
552
    $land = 'Brandenburg'            if (@$FA_finanzamt[0] eq '12');
553
    $land = 'Mecklenburg Vorpommern' if (@$FA_finanzamt[0] eq '13');
554
    $land = 'Sachsen'                if (@$FA_finanzamt[0] eq '14');
555
    $land = 'Sachsen Anhalt'         if (@$FA_finanzamt[0] eq '15');
556
    $land = 'Th?ringen'              if (@$FA_finanzamt[0] eq '16');
557

  
558
    $land = $main::locale->{iconv}->convert($land);
562
    my $tax_office   = first { $_->{id} == $FA_finanzamt->[0] } @{ $self->{tax_office_information} };
563
    $land            = $tax_office->{name};
564

  
565
    # $land = $main::locale->{iconv}->convert($land);
559 566

  
560 567
    my $ffff = @$FA_finanzamt[1];
561 568

  
bin/mozilla/ustva.pl
34 34
#our ($myconfig);
35 35
#use CGI::Carp "fatalsToBrowser";
36 36

  
37
use List::Util qw(first);
38

  
37 39
use SL::PE;
38 40
use SL::RP;
39 41
use SL::USTVA;
......
88 90
  $form->header;
89 91

  
90 92
  # Einlesen der Finanzamtdaten
91
  USTVA->get_config($userspath, 'finanzamt.ini');
93
  my $ustva = USTVA->new();
94
  $ustva->get_config($userspath, 'finanzamt.ini');
92 95

  
93 96
  # Hier Einlesen der user-config
94 97
  # steuernummer entfernt f?r prerelease
......
186 189

  
187 190
  # Which COA is in use?
188 191

  
189
  USTVA->get_coa($form, $myconfig);
192
  $ustva->get_coa($form, $myconfig);
190 193

  
191 194
  my $template_ref = {
192 195
    openings         => $openings,
......
533 536

  
534 537
  # Aufruf von get_config zum Einlesen der Finanzamtdaten aus finanzamt.ini
535 538

  
536
  USTVA->get_config($userspath, 'finanzamt.ini');
539
  my $ustva = USTVA->new();
540
  $ustva->get_config($userspath, 'finanzamt.ini');
537 541

  
538 542
  # init some form vars
539 543
  my @anmeldungszeitraum =
......
674 678

  
675 679

  
676 680
  # Get the USTVA
677
  USTVA->ustva(\%myconfig, \%$form);
681
  $ustva->ustva(\%myconfig, \%$form);
678 682

  
679 683
  # reformat Dates to dateformat
680 684
  $form->{fromdate} = $locale->date(\%myconfig, $form->{fromdate}, 0, 0, 0);
......
756 760
    # Outputformat specific customisation's
757 761
    #
758 762

  
759
    my @category_cent = USTVA->report_variables({
763
    my @category_cent = $ustva->report_variables({
760 764
        myconfig    => \%myconfig,
761 765
        form        => $form,
762 766
        type        => '',
......
766 770

  
767 771
    push @category_cent, qw(83  Z43  Z45  Z53  Z62  Z65  Z67);
768 772

  
769
    my @category_euro = USTVA->report_variables({
773
    my @category_euro = $ustva->report_variables({
770 774
        myconfig    => \%myconfig,
771 775
        form        => $form,
772 776
        type        => '',
......
915 919
        exit(0);
916 920
      }
917 921

  
918
      my %lands = ( # Lx => taxbird # TODO: besser als array...
919
                  'Baden W?rttemberg'      => '0',
920
                  'Bayern'                 => '1',
921
                  'Berlin'                 => '2',
922
                  'Brandenburg'            => '3',
923
                  'Bremen'                 => '4',
924
                  'Hamburg'                => '5',
925
                  'Hessen'                 => '6',
926
                  'Mecklenburg Vorpommern' => '7',
927
                  'Niedersachsen'          => '8',
928
                  'Nordrhein Westfalen'    => '9',
929
                  'Rheinland Pfalz'        => '10',
930
                  'Saarland'               => '11',
931
                  'Sachsen'                => '12',
932
                  'Sachsen Anhalt'         => '13',
933
                  'Schleswig Holstein'     => '14',
934
                  'Th?ringen'              => '15',
935
            );
936
      foreach my $land ( keys %lands ){
937
        $form->{taxbird_land_nr} = $lands{$land} if ($form->{elsterland} eq $land );
938
      }
922
      my $tax_office           = first { $_->{name} eq $form->{elsterland} } @{ $ustva->{tax_office_information} };
923
      $form->{taxbird_land_nr} = $tax_office->{taxbird_nr} if $tax_office;
939 924

  
940 925
      $form->{co_zip} = $form->{co_city};
941 926
      $form->{co_zip} =~ s/\D//g;
......
1011 996
  } else  # Outputformat for generic output
1012 997
  {
1013 998

  
1014
    my @category_cent = USTVA->report_variables({
999
    my @category_cent = $ustva->report_variables({
1015 1000
        myconfig    => \%myconfig,
1016 1001
        form        => $form,
1017 1002
        type        => '',
......
1019 1004
        dec_places  => '2',
1020 1005
    });
1021 1006

  
1022
    my @category_euro = USTVA->report_variables({
1007
    my @category_euro = $ustva->report_variables({
1023 1008
        myconfig    => \%myconfig,
1024 1009
        form        => $form,
1025 1010
        type        => '',
......
1085 1070
  # edit all taxauthority prefs
1086 1071

  
1087 1072
  $form->header;
1088
  USTVA->get_config($userspath, 'finanzamt.ini');
1073

  
1074
  my $ustva = USTVA->new();
1075
  $ustva->get_config($userspath, 'finanzamt.ini');
1089 1076

  
1090 1077
  my $land = $form->{elsterland};
1091 1078
  my $amt  = $form->{elsterFFFF};
......
1094 1081
  $form->{title} = $locale->text('Tax Office Preferences');
1095 1082

  
1096 1083

  
1097
  my $select_tax_office = USTVA->fa_auswahl($land, $amt, &elster_hash());
1084
  my $select_tax_office = $ustva->fa_auswahl($land, $amt, $ustva->query_finanzamt(\%myconfig, $form));
1098 1085
  my $checked_accrual = q|checked="checked"| if ($form->{method} eq 'accrual');
1099 1086
  my $checked_cash = q|checked="checked"| if ($form->{method} eq 'cash');
1100 1087
  my $checked_monthly = "checked" if ($form->{FA_voranmeld} eq 'month');
......
1133 1120

  
1134 1121
# Which COA is in use?
1135 1122

  
1136
  USTVA->get_coa($form, \%myconfig);
1123
  $ustva->get_coa($form, \%myconfig);
1137 1124

  
1138 1125
  # h?? kann die weg?
1139 1126
  my $steuernummer_new = '';
......
1171 1158
  my $elster_amt         = '';
1172 1159
  my $elsterFFFF         = '';
1173 1160
  my $elstersteuernummer = '';
1174
  USTVA->get_config($userspath, 'finanzamt.ini')
1161

  
1162
  my $ustva = USTVA->new();
1163
  $ustva->get_config($userspath, 'finanzamt.ini')
1175 1164
    if ($form->{saved} eq $locale->text('saved'));
1176 1165

  
1177 1166
  # Auf ?bergabefehler checken
......
1190 1179
  my $change = $form->{elsterland} eq $form->{elsterland_new}
1191 1180
    && $form->{elsterFFFF} eq $form->{elsterFFFF_new} ? '0' : '1';
1192 1181
  $change = '0' if ($form->{saved} eq $locale->text('saved'));
1193
  my $elster_init = &elster_hash();
1182
  my $elster_init = $ustva->query_finanzamt(\%myconfig, $form);
1194 1183

  
1195 1184
  my %elster_init = %$elster_init;
1196 1185

  
......
1241 1230
  $form->{FA_Oeffnungszeiten} =~ s/\\\\n/\n/g;
1242 1231

  
1243 1232

  
1244
  USTVA->get_coa($form, \%myconfig);
1233
  $ustva->get_coa($form, \%myconfig);
1245 1234

  
1246
  my $input_steuernummer = USTVA->steuernummer_input(
1235
  my $input_steuernummer = $ustva->steuernummer_input(
1247 1236
                             $form->{elsterland},
1248 1237
                             $form->{elsterFFFF},
1249 1238
                             $form->{steuernummer}
......
1422 1411
  $lxdebug->leave_sub();
1423 1412
}
1424 1413

  
1425
sub elster_hash {
1426
  $lxdebug->enter_sub();
1427

  
1428
  $auth->assert('advance_turnover_tax_return');
1429

  
1430
  my $finanzamt = USTVA->query_finanzamt(\%myconfig, \%$form);
1431
  $lxdebug->leave_sub();
1432
  return $finanzamt;
1433
}

Auch abrufbar als: Unified diff