Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a68089fb

Von mh@waldpark.octosoft.eu vor mehr als 8 Jahren hinzugefügt

  • ID a68089fb83a276f3ce78e5bd145c1cf05cc9a762
  • Vorgänger 233f338c
  • Nachfolger 52518527

Geierlein: alter Elsterexport überarbeitet

Generierung der Params in ODGeierlein

Neuer Controller für AJAX Request
Verallgemeinern (Teile aus ustva.pl nach SL/USTVA.pm

elster_format angepasst

Die Formate der Steuernummern für Baden-Württemberg und Rheinland-Pfalz
sind in Geierlein anders als früher in taxbird

Geierlein auf gleichem Webserver

Da LocalStorage nur innerhalb einer Domaine funktioniert,
Wurde nun innerhalb Kivitendo der crome/content Baum von Geierlein installiert.

Also
cd geierlein/chrome/content
mkdir {kivitendoDocumentRoot}/geierlein
tar cf - * | tar xf - -C {kivitendoDocumentRoot}/geierlein

Natürlich gibt es auch Möglichkeiten, dies per alias-Config im apache2 zu machen

Konfigurerierbar in kivitendo.conf

Falls geierlein_path gestetzt ist das Feature enabled
Pfadnahme zeigt zu geierleinverzeichnis innerhalb des kivitendo Verzeichnisses

UStVa Einstellungen in Datenbank

Kein finanzamt.ini mehr sondern fa_bufa_nr in Defaults,
über diese BundesFinanzamtnummer greift man auf Finanzamt Rose-Objekt zu.
Das ist nun auch modifizierbar.
Nutzung von Rose,
Sonderfälle in stnr pattern (BaWü)

Falls keine Daten in Defaults wird ein ggf. vorhandenes finanzamt.ini gelesen
und die Daten von dort übernommen

Die Steuernummer wird nun nicht mehr in der Mandantenkonfig
sondern in den UStVa Einstellungen editiert

Bisher Keine Umstellung auf IBAN, BIC (ist dies notwendig?)

Übergabe ohne kz83
Geierlein berechnet das Ergebnis selbst,
es werden nun nur Eingangsbeträge übergeben

UTF-8 Umwandlung finanzamt.ini Texte

Links zu Mandantenkonfig eingearbeitet

Implementiert RedMine Feature #168

Unterschiede anzeigen:

SL/Controller/ODGeierlein.pm
1
package SL::Controller::ODGeierlein;
2

  
3
use strict;
4
use utf8;
5
use List::Util qw(first);
6

  
7
use parent qw(SL::Controller::Base);
8

  
9
use SL::USTVA;
10

  
11
use Rose::Object::MakeMethods::Generic;
12

  
13
#
14
# actions
15
#
16

  
17
sub action_send {
18
  $::lxdebug->enter_sub();
19
  my ($self) = @_;
20
  my $err = '';
21

  
22
  # Aufruf von get_config zum Einlesen der Daten aus Finanzamt und Defaults
23

  
24
  my $ustva = USTVA->new();
25
  $ustva->get_config();
26
  $ustva->get_finanzamt();
27
  $ustva->set_FromTo(\%$::form);
28
  $::lxdebug->message($LXDebug::DEBUG2,"fromdate=".$::form->{fromdate}." todate=".$::form->{todate}." meth=".$::form->{method});
29

  
30
  my $tax_office     = first { $_->{id} eq $::form->{fa_land_nr} } @{ $ustva->{tax_office_information} };
31

  
32
  if ( !$::form->{co_zip} ) {
33
    $::form->{co_zip} = $::form->{co_city};
34
    $::form->{co_zip} =~ s/\D//g;
35
    $::form->{co_city} =~ s/\d//g;
36
    $::form->{co_city} =~ s/^\s//g;
37
  }
38
  $::form->{period}=~ s/^0//;
39

  
40
  # Aufbau der Geierlein Parameter
41
  my $params=
42
    "name = "  .$::form->{company}."\nstrasse = ".$::form->{co_street}.
43
    "\nplz = "    .$::form->{co_zip}."\nort = "  .$::form->{co_city}.
44
    "\ntelefon = ".$::form->{co_tel}."\nemail = ".$::form->{co_email}.
45
    "\nland = ".$tax_office->{taxbird_nr}."\nsteuernummer = ".$::form->{taxnumber}."\njahr = ".$::form->{year}.
46
    "\nzeitraum = ".$::form->{period}."\n";
47

  
48
  $::lxdebug->message($LXDebug::DEBUG2,"param1=".$params );
49

  
50
  # USTVA Daten erzeugen
51
  # benötigt $form->{fromdate}, $form->{todate} $form->{method}
52
  $ustva->ustva(\%::myconfig, \%$::form);
53

  
54
  my @category_cent = $ustva->report_variables({
55
    myconfig    => \%::myconfig,
56
    form        => $::form,
57
    type        => '',
58
    attribute   => 'position',
59
    dec_places  => '2',
60
  });
61

  
62
  #push @category_cent, qw(Z43  Z45  Z53  Z54  Z62  Z65  Z67);
63

  
64
  my @category_euro = $ustva->report_variables({
65
    myconfig    => \%::myconfig,
66
    form        => $::form,
67
    type        => '',
68
    attribute   => 'position',
69
    dec_places  => '0',
70
  });
71

  
72
  # Numberformatting for Geierlein
73
  my $temp_numberformat = $::myconfig{numberformat};
74
  # Numberformat must be '1000,00' ?!
75
  $::myconfig{numberformat} = '1000,00';
76
  foreach my $number (@{ $::form->{category_cent} }) {
77
    $::form->{$number} = ($::form->{$number} !=0) ? $::form->format_amount(\%::myconfig, $::form->{$number},'2',''):'';
78
  }
79

  
80
  foreach my $number (@{ $::form->{category_euro} }) {
81
    $::form->{$number} = ($::form->{$number} !=0) ? $::form->format_amount(\%::myconfig, $::form->{$number},'0',''):'';
82
  }
83
  # Re-set Numberformat
84
  $::myconfig{numberformat} = $temp_numberformat;
85

  
86
  # Berichtigte Anmeldung
87
  $params .= "kz10 = 1\n" if $::form->{FA_10};
88

  
89
  # Belege (Verträge, Rechnungen, Erläuterungen usw.) werden gesondert eingereicht
90
  $params .= "kz22 = 1\n" if $::form->{FA_22};
91

  
92
  # Verrechnung des Erstattungsbetrags erwünscht / Erstattungsbetrag ist abgetreten
93
  $params .= "kz29 = 1\n" if $::form->{FA_29};
94

  
95
  # Die Einzugsermächtigung wird ausnahmsweise (z.B. wegen Verrechnungswünschen) für diesen Voranmeldungszeitraum widerrufen.
96
  #  Ein ggf. verbleibender Restbetrag ist gesondert zu entrichten.
97
  $params .= "kz26 = 1\n" if $::form->{FA_26};
98

  
99
  my @unused_ids = qw(511 861 971 931 Z43 811 891 Z43 Z45 Z53 Z54 Z62 Z65 Z67 83);
100

  
101
  for my $kennziffer (@{$::form->{category_cent}}, @{$::form->{category_euro}}) {
102
    $::lxdebug->message($LXDebug::DEBUG2,"kennziffer ".$kennziffer."=".$::form->{$kennziffer});
103

  
104
    next if first { $_ eq $kennziffer } @unused_ids;
105

  
106
    if ($::form->{$kennziffer} != 0) {
107
      $params .= "kz".$kennziffer." = ".$::form->{$kennziffer}."\n";
108
    }
109
  }
110

  
111
  $::lxdebug->message($LXDebug::DEBUG2,"param2=".$params );
112

  
113

  
114
  $self->js->flash($err?'error':'info',
115
                   $err?$err:
116
                   $::locale->text('USTVA Data sent to geierlein'));
117
  $self->js->run('openGeierlein',$params) if !$err;
118
  $::lxdebug->leave_sub();
119
  $self->js->render;
120
}
121

  
122

  
123

  
124
#
125
# filters / helpers
126
#
127

  
128

  
129
1;
SL/DB/MetaSetup/Default.pm
49 49
  duns                                      => { type => 'text' },
50 50
  email_journal                             => { type => 'integer', default => 2 },
51 51
  expense_accno_id                          => { type => 'integer' },
52
  fa_bufa_nr                                => { type => 'text' },
53
  fa_dauerfrist                             => { type => 'text' },
54
  fa_steuerberater_city                     => { type => 'text' },
55
  fa_steuerberater_name                     => { type => 'text' },
56
  fa_steuerberater_street                   => { type => 'text' },
57
  fa_steuerberater_tel                      => { type => 'text' },
58
  fa_voranmeld                              => { type => 'text' },
52 59
  feature_balance                           => { type => 'boolean', default => 'true', not_null => 1 },
53 60
  feature_datev                             => { type => 'boolean', default => 'true', not_null => 1 },
54 61
  feature_erfolgsrechnung                   => { type => 'boolean', default => 'false', not_null => 1 },
SL/USTVA.pm
28 28
use List::Util qw(first);
29 29

  
30 30
use SL::DBUtils;
31
use SL::DB::Default;
32
use SL::DB::Finanzamt;
31 33

  
32 34
use utf8;
33 35
use strict;
34 36

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

  
56
  my @fiamt_config = qw(taxnumber fa_bufa_nr fa_dauerfrist fa_steuerberater_city fa_steuerberater_name
57
  fa_steuerberater_street fa_steuerberater_tel fa_voranmeld);
58

  
59
  my @fiamt_finanzamt = qw(
60
    fa_land_nr          fa_bufa_nr            fa_name             fa_strasse            
61
    fa_plz              fa_ort                fa_telefon          fa_fax
62
    fa_plz_grosskunden  fa_plz_postfach       fa_postfach         
63
    fa_blz_1 fa_kontonummer_1 fa_bankbezeichnung_1
64
    fa_blz_2 fa_kontonummer_2 fa_bankbezeichnung_2 fa_oeffnungszeiten
65
    fa_email fa_internet);
66

  
67

  
54 68
sub new {
55 69
  my $type = shift;
56 70

  
......
133 147

  
134 148
}
135 149

  
136
sub create_steuernummer {
137
  $main::lxdebug->enter_sub();
138

  
139
  my $form = $main::form;
140

  
141
  our ($elster_FFFF);
142

  
143
  my $part           = $form->{part};
144
  my $patterncount   = $form->{patterncount};
145
  my $delimiter      = $form->{delimiter};
146
  my $elster_pattern = $form->{elster_pattern};
147

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

  
152
  my $h = 0;
153
  my $i = 0;
154

  
155
  my $steuernummer_new        = $part;
156
  my $elstersteuernummer_new  = $elster_FFFF;
157
  $elstersteuernummer_new    .= '0';
158

  
159
  for ($h = 1; $h < $patterncount; $h++) {
160
    $steuernummer_new .= qq|$delimiter|;
161
    for ($i = 1; $i <= length($elster_pattern); $i++) {
162
      $steuernummer_new       .= $form->{"part_$h\_$i"};
163
      $elstersteuernummer_new .= $form->{"part_$h\_$i"};
164
    }
165
  }
166
  if ($form->{steuernummer} ne $steuernummer_new) {
167
    $form->{steuernummer}       = $steuernummer_new;
168
    $form->{elstersteuernummer} = $elstersteuernummer_new;
169
    $form->{steuernummer_new}   = $steuernummer_new;
170
  }
171
  $main::lxdebug->leave_sub();
172
  return ($steuernummer_new, $elstersteuernummer_new);
173
}
174 150

  
175 151
sub steuernummer_input {
176 152
  $main::lxdebug->enter_sub();
......
191 167
  #Pattern description Elstersteuernummer
192 168

  
193 169
  #split the pattern
194
  my $tax_office     = first { $_->{name} eq $elster_land } @{ $self->{tax_office_information} };
170
  my $tax_office     = first { $_->{id} eq $elster_land } @{ $self->{tax_office_information} };
195 171
  my $elster_pattern = $tax_office->{elster_format};
172
 # $::lxdebug->message(LXDebug->DEBUG2, "stnr=".$stnr." elster_FFFF=".$elster_FFFF.
173
 #                     " pattern=".$elster_pattern." land=".$elster_land);
196 174
  my @elster_pattern = split(' ', $elster_pattern);
197
  my $delimiter      = '&nbsp;';
175
  my $delimiter1      = '&nbsp;';
176
  my $delimiter2      = '&nbsp;';
198 177
  my $patterncount   = @elster_pattern;
199 178
  if ($patterncount < 2) {
200 179
    @elster_pattern = ();
201 180
    @elster_pattern = split('/', $elster_pattern);
202
    $delimiter      = '/';
181
    $delimiter1      = '/';
182
    $delimiter2      = '/';
203 183
    $patterncount   = @elster_pattern;
184
    if ($patterncount < 2) {
185
        @elster_pattern = ();
186
        @elster_pattern = split(' ', $elster_pattern);
187
        $delimiter1      = ' ';
188
        $delimiter2      = ' ';
189
        $patterncount   = @elster_pattern;
190
    }
204 191
  }
205 192

  
206 193
  # no we have an array of patternparts and a delimiter
......
208 195

  
209 196
  $steuernummer_input .= qq|<b><font size="+1">|;
210 197
  my $part = '';
198
#  $::lxdebug->message(LXDebug->DEBUG2, "pattern0=".$elster_pattern[0]);
211 199
SWITCH: {
212 200
    $elster_pattern[0] eq 'FFF' && do {
213 201
      $part = substr($elster_FFFF, 1, 4);
......
219 207
      $steuernummer_input .= qq|$part|;
220 208
      last SWITCH;
221 209
    };
210
    $elster_pattern[0] eq 'FFBBB' && do {
211
      $part = substr($elster_FFFF, 2, 4);
212
      $steuernummer_input .= qq|$part|;
213
      $delimiter1 = '';
214
      $patterncount++ ;
215
      # Sonderfall BW
216
      @elster_pattern = ('FF','BBB','UUUUP');
217
      last SWITCH;
218
    };
222 219
    $elster_pattern[0] eq 'FF' && do {
223 220
      $part = substr($elster_FFFF, 2, 4);
224 221
      $steuernummer_input .= qq|$part|;
......
231 228
  }
232 229

  
233 230
  #now the rest of the Steuernummer ...
234
  $steuernummer_input .= qq|</b></font>|;
231
  $steuernummer_input .= qq|</font></b>|;
235 232
  $steuernummer_input .= qq|\n
236 233
           <input type=hidden name="elster_pattern" value="$elster_pattern">
237 234
           <input type=hidden name="patterncount" value="$patterncount">
238 235
           <input type=hidden name="patternlength" value="$patterncount">
239
           <input type=hidden name="delimiter" value="$delimiter">
236
           <input type=hidden name="delimiter1" value="$delimiter1">
237
           <input type=hidden name="delimiter2" value="$delimiter2">
240 238
           <input type=hidden name="part" value="$part">
241 239
  |;
242 240

  
243 241
  my $k = 0;
244 242

  
245 243
  for (my $h = 1; $h < $patterncount; $h++) {
244
    my $delimiter = ( $h==1?$delimiter1:$delimiter2);
246 245
    $steuernummer_input .= qq|&nbsp;$delimiter&nbsp;\n|;
246
#  $::lxdebug->message(LXDebug->DEBUG2, "pattern[$h]=".$elster_pattern[$h]);
247 247
    for (my $i = 1; $i <= length($elster_pattern[$h]); $i++) {
248 248
      $steuernummer_input .= qq|<select name="part_$h\_$i">\n|;
249 249

  
......
269 269
sub fa_auswahl {
270 270
  $main::lxdebug->enter_sub();
271 271

  
272
#  use SL::Form;
273

  
274 272
  # Referenz wird übergeben, hash of hash wird nicht
275 273
  # in neues  Hash kopiert, sondern direkt über die Referenz verändert
276 274
  # Prototyp für diese Konstruktion
277 275

  
278 276
  my ($self, $land, $elsterFFFF, $elster_init) = @_;
279 277

  
278
#  $::lxdebug->message(LXDebug->DEBUG2,"land=".$land." amt=".$elsterFFFF);
280 279
  my $terminal = '';
281 280
  my $FFFF     = $elsterFFFF;
282 281
  my $ffff     = '';
283 282
  my $checked  = '';
284 283
  $checked = 'checked' if ($elsterFFFF eq '' and $land eq '');
285 284
  my %elster_land_fa;
285
  my %elster_land_name = ();
286 286

  
287 287
  my $fa_auswahl = qq|
288 288
        <script language="Javascript">
289 289
        function update_auswahl()
290 290
        {
291
                var elsterBLAuswahl = document.verzeichnis.elsterland_new;
292
                var elsterFAAuswahl = document.verzeichnis.elsterFFFF_new;
291
                var elsterBLAuswahl = document.verzeichnis.fa_land_nr_new;
292
                var elsterFAAuswahl = document.verzeichnis.fa_bufa_nr_new;
293 293

  
294 294
                elsterFAAuswahl.options.length = 0; // dropdown aufräumen
295 295
                |;
296 296

  
297 297
  foreach my $elster_land (sort keys %$elster_init) {
298 298
    $fa_auswahl .= qq|
299
               if (elsterBLAuswahl.options[elsterBLAuswahl.selectedIndex].
300
               value == "$elster_land")
299
               if (elsterBLAuswahl.options[elsterBLAuswahl.selectedIndex].value == "$elster_land")
301 300
               {
302 301
               |;
303 302
    my $j              = 0;
304 303
    %elster_land_fa = ();
305 304
    $FFFF = '';
306 305
    for $FFFF (keys %{ $elster_init->{$elster_land} }) {
307
      $elster_land_fa{$FFFF} = $elster_init->{$elster_land}->{$FFFF}->[0];
306
        if ( $FFFF eq 'name' ) {
307
            $elster_land_name{$elster_land} = $elster_init->{$elster_land}{$FFFF};
308
            delete $elster_init->{$elster_land}{$FFFF};
309
        } else {
310
            $elster_land_fa{$FFFF} = $elster_init->{$elster_land}{$FFFF}->fa_name;
311
       }
308 312
    }
309 313
    foreach $ffff (sort { $elster_land_fa{$a} cmp $elster_land_fa{$b} }
310 314
                   keys(%elster_land_fa)
......
326 330
               Bundesland
327 331
            </td>
328 332
            <td>
329
              <select size="1" name="elsterland_new" onchange="update_auswahl()">|;
333
              <select size="1" name="fa_land_nr_new" onchange="update_auswahl()">|;
330 334
  if ($land eq '') {
331 335
    $fa_auswahl .= qq|<option value="Auswahl" $checked>| . $main::locale->text('Select federal state...') . qq|</option>\n|;
332 336
  }
333 337
  foreach my $elster_land (sort keys %$elster_init) {
334 338
    $fa_auswahl .= qq|
335 339
                  <option value="$elster_land"|;
340
#  $::lxdebug->message(LXDebug->DEBUG2,"land=".$land." elster_land=".$elster_land." lname=".$elster_land_name{$elster_land});
336 341
    if ($elster_land eq $land and $checked eq '') {
337 342
      $fa_auswahl .= qq| selected|;
338 343
    }
339
    $fa_auswahl .= qq|>$elster_land</option>
344
    $fa_auswahl .= qq|>$elster_land_name{$elster_land}</option>
340 345
             |;
341 346
  }
342 347
  $fa_auswahl .= qq|
348
              </select>
343 349
            </td>
344 350
          </tr>
345 351
          |;
......
348 354
  $elster_land = ($land ne '') ? $land : '';
349 355
  %elster_land_fa = ();
350 356
  for $FFFF (keys %{ $elster_init->{$elster_land} }) {
351
    $elster_land_fa{$FFFF} = $elster_init->{$elster_land}->{$FFFF}->[0];
357
    $elster_land_fa{$FFFF} = $elster_init->{$elster_land}{$FFFF}->fa_name;
352 358
  }
353 359

  
354 360
  $fa_auswahl .= qq|
......
356 362
              <td>Finanzamt
357 363
              </td>
358 364
              <td>
359
                 <select size="1" name="elsterFFFF_new">|;
365
                 <select size="1" name="fa_bufa_nr_new">|;
360 366
  if ($elsterFFFF eq '') {
361 367
    $fa_auswahl .= qq|<option value="Auswahl" $checked>| . $main::locale->text('Select tax office...') . qq|</option>|;
362 368
  } else {
......
373 379
    }
374 380
  }
375 381
  $fa_auswahl .= qq|
376
                 </td>
377
              </tr>
378
            </table>
379
            </select>|;
382
                 </select>
383
              </td>
384
          </tr>
385
        </table>|;
380 386

  
381 387
  $main::lxdebug->leave_sub();
382 388

  
......
518 524
  };
519 525
  $tst->finish();
520 526

  
521
  #$dbh->disconnect();
522

  
523
  my @vars = (
524
    'FA_Land_Nr',             #  0
525
    'FA_BUFA_Nr',             #  1
526
                              #'FA_Verteiler',                             #  2
527
    'FA_Name',                #  3
528
    'FA_Strasse',             #  4
529
    'FA_PLZ',                 #  5
530
    'FA_Ort',                 #  6
531
    'FA_Telefon',             #  7
532
    'FA_Fax',                 #  8
533
    'FA_PLZ_Grosskunden',     #  9
534
    'FA_PLZ_Postfach',        # 10
535
    'FA_Postfach',            # 11
536
    'FA_BLZ_1',               # 12
537
    'FA_Kontonummer_1',       # 13
538
    'FA_Bankbezeichnung_1',   # 14
539
                              #'FA_BankIBAN_1',                            # 15
540
                              #'FA_BankBIC_1',                             # 16
541
                              #'FA_BankInhaber_BUFA_Nr_1',                 # 17
542
    'FA_BLZ_2',               # 18
543
    'FA_Kontonummer_2',       # 19
544
    'FA_Bankbezeichnung_2',   # 20
545
                              #'FA_BankIBAN_2',                            # 21
546
                              #'FA_BankBIC_2',                             # 22
547
                              #'FA_BankInhaber_BUFA_Nr_2',                 # 23
548
    'FA_Oeffnungszeiten',     # 24
549
    'FA_Email',               # 25
550
    'FA_Internet'             # 26
551
                              #'FA_zustaendige_Hauptstelle_BUFA_Nr',       # 27
552
                              #'FA_zustaendige_vorgesetzte_Finanzbehoerde' # 28
553
  );
554

  
555
  my $field = join(', ', @vars);
556 527

  
557
  my $query = "SELECT $field FROM finanzamt ORDER BY FA_Land_nr";
558
  my $sth = $dbh->prepare($query) or $self->error($dbh->errstr);
559
  $sth->execute || $form->dberror($query);
560
  my $array_ref = $sth->fetchall_arrayref();
561
  my $land      = '';
528
  my $fiamt =  SL::DB::Finanzamt->_get_manager_class->get_all(sort => 'fa_land_nr');
529
  my $land      = 0;
562 530
  my %finanzamt;
563
  foreach my $row (@$array_ref) {
564
    my $FA_finanzamt = $row;
565
    my $tax_office   = first { $_->{id} == $FA_finanzamt->[0] } @{ $self->{tax_office_information} };
566
    $land            = $tax_office->{name};
567

  
568
    # $land = $main::locale->{iconv}->convert($land);
569

  
570
    my $ffff = @$FA_finanzamt[1];
571

  
572
    my $rec = {};
573
    $rec->{$land} = $ffff;
574

  
575
    shift @$row;
576
    shift @$row;
577

  
578
    $finanzamt{$land}{$ffff} = [@$FA_finanzamt];
531
  foreach my $row (@$fiamt) {
532
    my $tax_office   = first { $_->{id} == $row->fa_land_nr } @{ $self->{tax_office_information} };
533
    $land            = $tax_office->{id};
534
    $finanzamt{$land}{$row->fa_bufa_nr}  = $row;
535
    $finanzamt{$land}{'name'} ||= $tax_office->{name};
579 536
  }
580

  
581
  $sth->finish();
582
  $dbh->disconnect();
583

  
584 537
  $main::lxdebug->leave_sub();
585 538

  
586 539
  return \%finanzamt;
......
654 607
  my $last_period     = 0;
655 608
  my $category        = "pos_ustva";
656 609

  
610
  $form->{coa} = $::instance_conf->get_coa;
611

  
657 612
  my @category_cent = USTVA->report_variables({
658 613
      myconfig    => $myconfig,
659 614
      form        => $form,
......
662 617
      dec_places  => '2',
663 618
  });
664 619

  
665
  push @category_cent, qw(83  Z43  Z45  Z53  Z62  Z65  Z67);
666

  
620
  if ( $form->{coa} eq 'Germany-DATEV-SKR03EU' or $form->{coa} eq 'Germany-DATEV-SKR04EU') {
621
      push @category_cent, qw(Z43  Z45  Z53  Z54  Z62  Z65  Z67);
622
  }
667 623
  my @category_euro = USTVA->report_variables({
668 624
      myconfig    => $myconfig,
669 625
      form        => $form,
......
672 628
      dec_places  => '0',
673 629
  });
674 630

  
675
  push @category_euro, USTVA->report_variables({
676
      myconfig    => $myconfig,
677
      form        => $form,
678
      type        => '',
679
      attribute   => 'position',
680
      dec_places  => '0',
681
  });
682

  
631
  @{$form->{category_cent}} = @category_cent;
632
  @{$form->{category_euro}} = @category_euro;
683 633
  $form->{decimalplaces} *= 1;
684 634

  
685 635
  foreach my $item (@category_cent) {
......
688 638
  foreach my $item (@category_euro) {
689 639
    $form->{"$item"} = 0;
690 640
  }
691
  my $coa_name = $::instance_conf->get_coa;
692
  $form->{coa} = $coa_name;
693 641

  
694 642
  # Controlvariable for templates
643
  my $coa_name = $form->{coa};
695 644
  $form->{"$coa_name"} = '1';
696 645

  
697
  $main::lxdebug->message(LXDebug->DEBUG2(), "COA: '$form->{coa}',  \$form->{$coa_name} = 1");
698

  
699 646
  &get_accounts_ustva($dbh, $last_period, $form->{fromdate}, $form->{todate},
700 647
                      $form, $category);
701 648

  
......
777 724
  my $arwhere  = "";
778 725
  my $item;
779 726

  
780
    my $gltaxkey_where = "((tk.pos_ustva = 46) OR (tk.pos_ustva>=59 AND tk.pos_ustva<=67) or (tk.pos_ustva>=89 AND tk.pos_ustva<=93))";
727
  my $gltaxkey_where = "((tk.pos_ustva = 46) OR (tk.pos_ustva>=59 AND tk.pos_ustva<=67) or (tk.pos_ustva>=89 AND tk.pos_ustva<=93))";
781 728

  
782 729
  if ($fromdate) {
783
    if ($form->{method} eq 'cash') {
730
    if ($form->{accounting_method} eq 'cash') {
784 731
      $subwhere .= " AND transdate >= '$fromdate'";
785 732
      $glwhere = " AND ac.transdate >= '$fromdate'";
786 733
      $ARwhere .= " AND acc.transdate >= '$fromdate'";
......
816 763
  #
817 764
  ############################################
818 765

  
819
  if ($form->{method} eq 'cash') {
766
  if ($form->{accounting_method} eq 'cash') {
820 767

  
821 768
    $query = qq|
822 769
       SELECT
......
860 807
       GROUP BY tk.pos_ustva
861 808
    |;
862 809

  
863
  } elsif ($form->{method} eq 'accrual') {
810
  } elsif ($form->{accounting_method} eq 'accrual') {
864 811
    #########################################
865 812
    # Method eq 'accrual' = Soll Versteuerung
866 813
    #########################################
......
889 836

  
890 837
  } else {
891 838

  
892
    $form->error("Unknown tax method: $form->{method}")
839
    $form->error("Unknown tax method: $form->{accounting_method}")
893 840

  
894 841
  }
895 842

  
......
994 941

  
995 942
}
996 943

  
997
sub get_config {
944
sub set_FromTo {
998 945
  $main::lxdebug->enter_sub();
999 946

  
1000
  my ($self, $userspath, $filename) = @_;
947
  my ($self, $form) = @_;
1001 948

  
1002
  my $form = $main::form;
949
  # init some form vars
950
  my @anmeldungszeitraum =
951
    qw('0401' '0402' '0403'
952
       '0404' '0405' '0406'
953
       '0407' '0408' '0409'
954
       '0410' '0411' '0412'
955
       '0441' '0442' '0443' '0444');
1003 956

  
1004
  $form->error("Missing Parameter: @_") if !$userspath || !$filename;
957
  foreach my $item (@anmeldungszeitraum) {
958
    $form->{$item} = "";
959
  }
1005 960

  
1006
  $filename = "$::myconfig{login}_$filename";
1007
  $filename =~ s|.*/||;
1008
  $filename = "$userspath/$filename";
1009
  open my $FACONF, "<", $filename or do {# Annon Sub
1010
    # catch open error
1011
    # create file if file does not exist
1012
    open my $FANEW, ">", $filename  or $form->error("CREATE: $filename : $!");
1013
    close $FANEW                    or $form->error("CLOSE: $filename : $!");
961
  #forgotten the year --> thisyear
962
  if ($form->{year} !~ m/^\d\d\d\d$/) {
963
      $form->{year} = substr(
964
          $form->datetonum(
965
              $form->current_date(\%::myconfig), \%::myconfig
966
          ),
967
          0, 4);
968
      $::lxdebug->message(LXDebug->DEBUG1,
969
                          qq|Actual year from Database: $form->{year}\n|);
970
  }
1014 971

  
1015
    #try again open file
1016
    open my $FACONF, "<", $filename or $form->error("OPEN: $filename : $!");
1017
  };
972
  #
973
  # using dates in ISO-8601 format: yyyymmmdd  for Postgres...
974
  #
975

  
976
  #yearly report
977
  if ($form->{period} eq "13") {
978
      $form->{fromdate} = "$form->{year}0101";
979
      $form->{todate}   = "$form->{year}1231";
980
  }
981

  
982
  #quarter reports
983
  if ($form->{period} eq "41") {
984
      $form->{fromdate} = "$form->{year}0101";
985
      $form->{todate}   = "$form->{year}0331";
986
      $form->{'0441'}   = "X";
987
  }
988
  if ($form->{period} eq "42") {
989
      $form->{fromdate} = "$form->{year}0401";
990
      $form->{todate}   = "$form->{year}0630";
991
      $form->{'0442'}   = "X";
992
  }
993
  if ($form->{period} eq "43") {
994
      $form->{fromdate} = "$form->{year}0701";
995
      $form->{todate}   = "$form->{year}0930";
996
      $form->{'0443'}   = "X";
997
  }
998
  if ($form->{period} eq "44") {
999
      $form->{fromdate} = "$form->{year}1001";
1000
      $form->{todate}   = "$form->{year}1231";
1001
      $form->{'0444'}   = "X";
1002
  }
1003

  
1004
   #Monthly reports
1005
  SWITCH: {
1006
      $form->{period} eq "01" && do {
1007
        $form->{fromdate} = "$form->{year}0101";
1008
        $form->{todate}   = "$form->{year}0131";
1009
        $form->{'0401'}   = "X";
1010
        last SWITCH;
1011
      };
1012
      $form->{period} eq "02" && do {
1013
        $form->{fromdate} = "$form->{year}0201";
1014

  
1015
        #this works from 1901 to 2099, 1900 and 2100 fail.
1016
        my $leap = ($form->{year} % 4 == 0) ? "29" : "28";
1017
        $form->{todate} = "$form->{year}02$leap";
1018
        $form->{"0402"} = "X";
1019
        last SWITCH;
1020
      };
1021
      $form->{period} eq "03" && do {
1022
        $form->{fromdate} = "$form->{year}0301";
1023
        $form->{todate}   = "$form->{year}0331";
1024
        $form->{"0403"}   = "X";
1025
        last SWITCH;
1026
      };
1027
      $form->{period} eq "04" && do {
1028
        $form->{fromdate} = "$form->{year}0401";
1029
        $form->{todate}   = "$form->{year}0430";
1030
        $form->{"0404"}   = "X";
1031
        last SWITCH;
1032
      };
1033
      $form->{period} eq "05" && do {
1034
        $form->{fromdate} = "$form->{year}0501";
1035
        $form->{todate}   = "$form->{year}0531";
1036
        $form->{"0405"}   = "X";
1037
        last SWITCH;
1038
      };
1039
      $form->{period} eq "06" && do {
1040
        $form->{fromdate} = "$form->{year}0601";
1041
        $form->{todate}   = "$form->{year}0630";
1042
        $form->{"0406"}   = "X";
1043
        last SWITCH;
1044
      };
1045
      $form->{period} eq "07" && do {
1046
        $form->{fromdate} = "$form->{year}0701";
1047
        $form->{todate}   = "$form->{year}0731";
1048
        $form->{"0407"}   = "X";
1049
        last SWITCH;
1050
      };
1051
      $form->{period} eq "08" && do {
1052
        $form->{fromdate} = "$form->{year}0801";
1053
        $form->{todate}   = "$form->{year}0831";
1054
        $form->{"0408"}   = "X";
1055
        last SWITCH;
1056
      };
1057
      $form->{period} eq "09" && do {
1058
        $form->{fromdate} = "$form->{year}0901";
1059
        $form->{todate}   = "$form->{year}0930";
1060
        $form->{"0409"}   = "X";
1061
        last SWITCH;
1062
      };
1063
      $form->{period} eq "10" && do {
1064
        $form->{fromdate} = "$form->{year}1001";
1065
        $form->{todate}   = "$form->{year}1031";
1066
        $form->{"0410"}   = "X";
1067
        last SWITCH;
1068
      };
1069
      $form->{period} eq "11" && do {
1070
        $form->{fromdate} = "$form->{year}1101";
1071
        $form->{todate}   = "$form->{year}1130";
1072
        $form->{"0411"}   = "X";
1073
        last SWITCH;
1074
      };
1075
      $form->{period} eq "12" && do {
1076
        $form->{fromdate} = "$form->{year}1201";
1077
        $form->{todate}   = "$form->{year}1231";
1078
        $form->{"0412"}   = "X";
1079
        last SWITCH;
1080
      };
1081
    }
1082

  
1083
  # Kontrollvariablen für die Templates
1084
  $form->{"year$_"} = ($form->{year} >= $_ ) ? "1":"0" for 2007..2107;
1085

  
1086
  $main::lxdebug->leave_sub();
1087
}
1088

  
1089
sub get_fiamt_vars {
1090
    return @fiamt_finanzamt;
1091
}
1092

  
1093
sub get_oldconfig {
1094
  $main::lxdebug->enter_sub();
1095

  
1096
  my $ret = 0;
1097
  my %oldkeys = (
1098
      'steuernummer' => 'taxnumber',
1099
      'elsterFFFF' => 'fa_bufa_nr',
1100
      'FA_dauerfrist' => 'fa_dauerfrist',
1101
      'FA_steuerberater_city' => 'fa_steuerberater_city',
1102
      'FA_steuerberater_name' => 'fa_steuerberater_name',
1103
      'FA_steuerberater_street' => 'fa_steuerberater_street',
1104
      'FA_steuerberater_tel' => 'fa_steuerberater_tel',
1105
      'FA_voranmeld' => 'fa_voranmeld',
1106
      );
1107

  
1108
  my $filename = $::lx_office_conf{paths}{userspath}."/finanzamt.ini";
1109
  my $FACONF;
1110
  return unless (open( $FACONF, "<", $filename));
1018 1111

  
1019 1112
  while (<$FACONF>) {
1020 1113
    last if (/^\[/);
......
1026 1119
    # remove any trailing whitespace
1027 1120
    s/^\s*(.*?)\s*$/$1/;
1028 1121
    my ($key, $value) = split(/=/, $_, 2);
1029

  
1030
    $form->{$key} = "$value";
1031

  
1122
    
1123
    $main::lxdebug->message(LXDebug->DEBUG2(), "oldkey: ".$key." val=".$value." newkey=".
1124
                          $oldkeys{$key}." oval=".$::form->{$oldkeys{$key}});
1125
    if ( $oldkeys{$key} && $::form->{$oldkeys{$key}} eq '' ) {
1126
        $::form->{$oldkeys{$key}} = $::locale->{iconv_utf8}->convert($value);
1127
        $main::lxdebug->message(LXDebug->DEBUG2(), "set ".$oldkeys{$key}."=".$::form->{$oldkeys{$key}});
1128
        $ret = 1;
1129
    }
1032 1130
  }
1131
  $main::lxdebug->leave_sub();
1132
  return $ret;
1133
}
1033 1134

  
1034
  close $FACONF;
1135
sub get_config {
1136
    $main::lxdebug->enter_sub();
1137
    my $defaults   = SL::DB::Default->get;
1138
    my @rd_config =  @fiamt_config;
1139
    push @rd_config ,qw(accounting_method coa company address co_ustid duns);
1140
    $::form->{$_} = $defaults->$_ for @rd_config;
1141

  
1142
    if ( $::form->{taxnumber} eq '' || $::form->{fa_bufa_nr} eq '') {
1143
        #alte finanzamt.ini lesen, ggf abspeichern
1144
        if ( get_oldconfig() ) {
1145
            get_finanzamt();
1146
            save_config();
1147
        }
1148
    }
1035 1149

  
1036
  $main::lxdebug->leave_sub();
1150
    my $coa = $::form->{coa};
1151
    $::form->{"COA_$coa"} = '1';
1152
    $::form->{COA_Germany} = '1' if ($coa =~ m/^germany/i);
1153
    $main::lxdebug->leave_sub();
1037 1154
}
1038 1155

  
1156
sub get_finanzamt {
1157
    $main::lxdebug->enter_sub();
1158
    if ( $::form->{fa_bufa_nr} && $::form->{fa_bufa_nr} ne '' ) {
1159
        my $fiamt =  SL::DB::Finanzamt->_get_manager_class->get_first(
1160
                 query => [ fa_bufa_nr => $::form->{fa_bufa_nr} ]);
1161
        $::form->{$_} = $fiamt->$_ for @fiamt_finanzamt;
1162
    }
1163
    $main::lxdebug->leave_sub();
1164
}
1165

  
1166
sub save_config {
1167
    $main::lxdebug->enter_sub();
1168
    my $defaults  = SL::DB::Default->get;
1169
    $defaults->$_($::form->{$_}) for @fiamt_config;
1170
    $defaults->save;
1171
    if ( $defaults->fa_bufa_nr ) {
1172
        my $fiamt =  SL::DB::Finanzamt->_get_manager_class->get_first(
1173
                 query => [ fa_bufa_nr => $defaults->fa_bufa_nr ]);
1174
        $fiamt->$_($::form->{$_}) for @fiamt_finanzamt;
1175
        $fiamt->save;
1176
    }
1177
    $main::lxdebug->leave_sub();
1178
}
1039 1179

  
1040 1180
1;
bin/mozilla/ustva.pl
98 98

  
99 99
  # Einlesen der Finanzamtdaten
100 100
  my $ustva = USTVA->new();
101
  $ustva->get_config($::lx_office_conf{paths}{userspath}, 'finanzamt.ini');
101
  $ustva->get_config();
102
  $ustva->get_finanzamt();
102 103

  
104
  my $geierlein_enabled = 0;
105
  my $geierlein_path = $::lx_office_conf{paths}{geierlein_path};
106

  
107
  if ( $geierlein_path && length($geierlein_path) > 0 ) {$geierlein_enabled=1;} 
108

  
109
#  $::lxdebug->message(LXDebug->DEBUG2,"geierlein_enabled=".$geierlein_enabled." path=".$geierlein_path);
103 110
  # Hier Einlesen der user-config
104 111
  # steuernummer entfernt für prerelease
105 112
  my @a = qw(
......
116 123
  );
117 124

  
118 125
  $form->{$_} = $myconfig{$_} for @a;
119
  $form->{$_} = $defaults->$_ for qw(company address co_ustid duns);
120 126

  
121
  my $openings = $form->{FA_Oeffnungszeiten};
127
  my $openings = $form->{fa_oeffnungszeiten};
122 128
  $openings =~ s/\\\\n/<br>/g;
123 129

  
124 130
  my $company_given = ($form->{company} ne '')
125 131
    ? qq|<h3>$form->{company}</h3>\n|
126
    : qq|<a href="am.pl?action=config">|
132
    : qq|<a href="controller.pl?action=ClientConfig/edit">|
127 133
      . $locale->text('No Company Name given') . qq|!</a><br>|;
128 134

  
129 135

  
......
142 148
    ? qq|$form->{co_street}<br>|
143 149
        . qq|$form->{co_street1}<br>|
144 150
        . qq|$form->{co_zip} $form->{co_city}|
145
    : qq|<a href="am.pl?action=config|
146
        . qq|&level=Programm--Preferences">|
151
    : qq|<a href="controller.pl?action=ClientConfig/edit">|
147 152
        . $locale->text('No Company Address given')
148 153
        . qq|!</a>\n|;
149 154

  
......
152 157
  $form->{co_fax}   = $form->{fax}   unless $form->{co_fax};
153 158
  $form->{co_url}   = $form->{urlx}  unless $form->{co_url};
154 159

  
155
  my $taxnumber_given = ($form->{steuernummer} ne '') ? $form->{steuernummer} : qq|<a href="ustva.pl?action=config_step1">Keine Steuernummer hinterlegt!</a><br>|;
156

  
160
  my $taxnumber_given = ($form->{taxnumber} ne '') ? $form->{taxnumber} : qq|<a href="ustva.pl?action=config_step1">Keine Steuernummer hinterlegt!</a><br>|;
161
  my $fa_name_given = ($form->{fa_name} ne '') ? $form->{fa_name} : qq|<a href="ustva.pl?action=config_step1">Kein Finanzamt hinterlegt!</a><br>|;
157 162
  my $ustva_vorauswahl = &ustva_vorauswahl();
158 163

  
159 164
  my @all_years = $form->all_years(\%myconfig);
......
171 176
  $_checked = "checked" if ($form->{kz10} eq '1');
172 177
  my $checkbox_kz_10 = qq|<input name="FA_10" id=FA_10 class=checkbox|
173 178
    . qq| type=checkbox value="1" $_checked title = "|
174
    . $locale->text('Amended Advance Turnover Tax Return (Nr. 10)')
179
    . $locale->text('Amended Advance Turnover Tax Return').'(Nr. 10)'
175 180
    . qq|">|
176 181
    . $locale->text('Amended Advance Turnover Tax Return');
177 182

  
178
  my $method_local = ($form->{method} eq 'accrual') ? $locale->text('accrual')
179
                   : ($form->{method} eq 'cash')    ? $locale->text('cash')
183
  $_checked = "checked" if ($form->{kz22} eq '1');
184
  my $checkbox_kz_22 = qq|<input name="FA_22" id=FA_22 class=checkbox|
185
    . qq| type=checkbox value="1" $_checked title = "|
186
    . $locale->text('Receipts attached/extra').'(Nr. 22)'
187
    . qq|">|
188
    . $locale->text('Receipts attached/extra');
189

  
190
  $_checked = "checked" if ($form->{kz29} eq '1');
191
  my $checkbox_kz_29 = qq|<input name="FA_29" id=FA_29 class=checkbox|
192
    . qq| type=checkbox value="1" $_checked title = "|
193
    . $locale->text('Accounting desired').'(Nr. 29)'
194
    . qq|">|
195
    . $locale->text('Accounting desired');
196

  
197
  $_checked = "checked" if ($form->{kz26} eq '1');
198
  my $checkbox_kz_26 = qq|<input name="FA_26" id=FA_26 class=checkbox|
199
    . qq| type=checkbox value="1" $_checked title = "|
200
    . $locale->text('Direct debit revoked').'(Nr. 26)'
201
    . qq|">|
202
    . $locale->text('Direct debit revoked');
203

  
204
  my $method_local = ($form->{accounting_method} eq 'accrual') ? $locale->text('accrual')
205
                   : ($form->{accounting_method} eq 'cash')    ? $locale->text('cash')
180 206
                   : '';
181 207

  
182
  my $period_local = ( $form->{FA_voranmeld} eq 'month')   ? $locale->text('month')
183
                   : ( $form->{FA_voranmeld} eq 'quarter') ? $locale->text('quarter')
208
  my $period_local = ( $form->{fa_voranmeld} eq 'month')   ? $locale->text('month')
209
                   : ( $form->{fa_voranmeld} eq 'quarter') ? $locale->text('quarter')
184 210
                   : '';
185 211

  
186
  my $tax_office_banks_ref = [
187
    { BLZ             => $form->{FA_BLZ_1},
188
      Kontonummer     => $form->{FA_Kontonummer_1},
189
      Bankbezeichnung => $form->{FA_Bankbezeichnung_1}
212
  my @tax_office_banks_ref = (
213
    { BLZ             => $form->{fa_blz_1},
214
      Kontonummer     => $form->{fa_kontonummer_1},
215
      Bankbezeichnung => $form->{fa_bankbezeichnung_1}
190 216
    },
191
    { BLZ             => $form->{FA_BLZ_2},
192
      Kontonummer     => $form->{FA_Kontonummer_2},
193
      Bankbezeichnung => $form->{FA_Bankbezeichnung_oertlich}
217
    { BLZ             => $form->{fa_blz_2},
218
      Kontonummer     => $form->{fa_kontonummer_2},
219
      Bankbezeichnung => $form->{fa_bankbezeichnung_2}
194 220
    }
195
  ];
196

  
197
  # Which COA is in use?
221
  );
198 222

  
199 223
  $ustva->get_coa($form); # fetches coa and modifies some form variables
200 224

  
......
203 227
    company_given    => $company_given,
204 228
    address_given    => $address_given,
205 229
    taxnumber_given  => $taxnumber_given,
230
    fa_name_given    => $fa_name_given,
206 231
    taxnumber        => $defaults->taxnumber,
207 232
    select_year      => $select_year,
208 233
    period_local     => $period_local,
209 234
    method_local     => $method_local,
210 235
    ustva_vorauswahl => $ustva_vorauswahl,
211 236
    checkbox_kz_10   => $checkbox_kz_10,
212
    tax_office_banks => $tax_office_banks_ref,
237
    checkbox_kz_22   => $checkbox_kz_22,
238
    checkbox_kz_29   => $checkbox_kz_29,
239
    checkbox_kz_26   => $checkbox_kz_26,
240
    tax_office_banks => \@tax_office_banks_ref,
241
    geierlein_enabled => $geierlein_enabled,
242
    geierlein_path   => $geierlein_path,
213 243
    select_options   => &show_options,
214 244

  
215 245
  };
......
243 273

  
244 274
  $::auth->assert('advance_turnover_tax_return');
245 275

  
246
  #&generate_ustva();
276
  #generate_ustva();
247 277
  $::lxdebug->leave_sub();
248 278
  call_sub($::form->{"nextsub"});
249 279
}
......
280 310
  #$form->{month}= '01';
281 311
  #$form->{year}= 2004;
282 312
  $select_vorauswahl = qq|
283
     <input type=hidden name=day value=$form->{day}>
284
     <input type=hidden name=month value=$form->{month}>
285
     <input type=hidden name=yymmdd value=$yymmdd>
286
     <input type=hidden name=sel value=$sel>
313
     <input type="hidden" name="day" value="$form->{day}">
314
     <input type="hidden" name="month" value="$form->{month}">
315
     <input type="hidden" name="yymmdd" value="$yymmdd">
316
     <input type="hidden" name="sel" value="$sel">
287 317
  |;
288 318

  
289
  if ($form->{FA_voranmeld} eq 'month') {
319
  if ($form->{fa_voranmeld} eq 'month') {
290 320

  
291 321
    # Vorauswahl bei monatlichem Voranmeldungszeitraum
292 322

  
......
311 341
    my $dfv = '';
312 342

  
313 343
    # Offset für Dauerfristverlängerung
314
    $dfv = '100' if ($form->{FA_dauerfrist} eq '1');
344
    $dfv = '100' if ($form->{fa_dauerfrist} eq '1');
315 345

  
316 346
  SWITCH: {
317 347
      $yymmdd <= ($yy + 110 + $dfv) && do {
......
382 412
    }
383 413
    $select_vorauswahl .= qq|</select>|;
384 414

  
385
  } elsif ($form->{FA_voranmeld} eq 'quarter') {
415
  } elsif ($form->{fa_voranmeld} eq 'quarter') {
386 416

  
387 417
    # Vorauswahl bei quartalsweisem Voranmeldungszeitraum
388 418
    my %liste = ('41'  => $locale->text('1. Quarter'),
......
395 425
    $yymmdd = "$form->{year}$form->{month}$form->{day}" * 1;
396 426
    $sel    = '';
397 427
    my $dfv = '';    # Offset für Dauerfristverlängerung
398
    $dfv = '100' if ($form->{FA_dauerfrist} eq '1');
428
    $dfv = '100' if ($form->{fa_dauerfrist} eq '1');
399 429

  
400 430
  SWITCH: {
401 431
      $yymmdd <= ($yy + 110 + $dfv) && do {
......
506 536
    . $::locale->text('HTML')
507 537
    . qq|</option>|;
508 538

  
539
  #my $disabled= qq|disabled="disabled"|;
540
  #$disabled='' if ($form->{elster} eq '1' );
541
  #if ($::form->{elster} eq '1') {
542
  if ( 1 ) {
543
    $format .=
544
        qq|<option value=elstertaxbird>|
545
      . $::locale->text('ELSTER Export (via Geierlein)')
546
      . qq|</option>|;
547
  }
548

  
509 549
  my $show_options = qq|
510 550
    $type
511 551
    $media
......
530 570
  $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates;
531 571
  $form->{templates} = $defaults->templates;
532 572

  
533
  # Aufruf von get_config zum Einlesen der Finanzamtdaten aus finanzamt.ini
534 573

  
535 574
  my $ustva = USTVA->new();
536
  $ustva->get_config($::lx_office_conf{paths}{userspath}, 'finanzamt.ini');
537

  
538
  # init some form vars
539
  my @anmeldungszeitraum =
540
    qw('0401' '0402' '0403'
541
       '0404' '0405' '0406'
542
       '0407' '0408' '0409'
543
       '0410' '0411' '0412'
544
       '0441' '0442' '0443' '0444');
545

  
546
  foreach my $item (@anmeldungszeitraum) {
547
    $form->{$item} = "";
548
  }
549

  
550
    #forgotten the year --> thisyear
551
    if ($form->{year} !~ m/^\d\d\d\d$/) {
552
      $form->{year} = substr(
553
                             $form->datetonum(
554
                                    $form->current_date(\%myconfig), \%myconfig
555
                             ),
556
                             0, 4);
557
      $::lxdebug->message(LXDebug->DEBUG1,
558
                        qq|Actual year from Database: $form->{year}\n|);
559
    }
575
  $ustva->get_config();
576
  $ustva->get_finanzamt();
560 577

  
561
    #
562
    # using dates in ISO-8601 format: yyyymmmdd  for Postgres...
563
    #
578
  # Setze Anmeldungszeitraum
564 579

  
565
    #yearly report
566
    if ($form->{period} eq "13") {
567
      $form->{fromdate} = "$form->{year}0101";
568
      $form->{todate}   = "$form->{year}1231";
569
    }
570

  
571
    #Quater reports
572
    if ($form->{period} eq "41") {
573
      $form->{fromdate} = "$form->{year}0101";
574
      $form->{todate}   = "$form->{year}0331";
575
      $form->{'0441'}   = "X";
576
    }
577
    if ($form->{period} eq "42") {
578
      $form->{fromdate} = "$form->{year}0401";
579
      $form->{todate}   = "$form->{year}0630";
580
      $form->{'0442'}   = "X";
581
    }
582
    if ($form->{period} eq "43") {
583
      $form->{fromdate} = "$form->{year}0701";
584
      $form->{todate}   = "$form->{year}0930";
585
      $form->{'0443'}   = "X";
586
    }
587
    if ($form->{period} eq "44") {
588
      $form->{fromdate} = "$form->{year}1001";
589
      $form->{todate}   = "$form->{year}1231";
590
      $form->{'0444'}   = "X";
591
    }
592

  
593
    #Monthly reports
594
  SWITCH: {
595
      $form->{period} eq "01" && do {
596
        $form->{fromdate} = "$form->{year}0101";
597
        $form->{todate}   = "$form->{year}0131";
598
        $form->{'0401'}   = "X";
599
        last SWITCH;
600
      };
601
      $form->{period} eq "02" && do {
602
        $form->{fromdate} = "$form->{year}0201";
603

  
604
        #this works from 1901 to 2099, 1900 and 2100 fail.
605
        my $leap = ($form->{year} % 4 == 0) ? "29" : "28";
606
        $form->{todate} = "$form->{year}02$leap";
607
        $form->{"0402"} = "X";
608
        last SWITCH;
609
      };
610
      $form->{period} eq "03" && do {
611
        $form->{fromdate} = "$form->{year}0301";
612
        $form->{todate}   = "$form->{year}0331";
613
        $form->{"0403"}   = "X";
614
        last SWITCH;
615
      };
616
      $form->{period} eq "04" && do {
617
        $form->{fromdate} = "$form->{year}0401";
618
        $form->{todate}   = "$form->{year}0430";
619
        $form->{"0404"}   = "X";
620
        last SWITCH;
621
      };
622
      $form->{period} eq "05" && do {
623
        $form->{fromdate} = "$form->{year}0501";
624
        $form->{todate}   = "$form->{year}0531";
625
        $form->{"0405"}   = "X";
626
        last SWITCH;
627
      };
628
      $form->{period} eq "06" && do {
629
        $form->{fromdate} = "$form->{year}0601";
630
        $form->{todate}   = "$form->{year}0630";
631
        $form->{"0406"}   = "X";
632
        last SWITCH;
633
      };
634
      $form->{period} eq "07" && do {
635
        $form->{fromdate} = "$form->{year}0701";
636
        $form->{todate}   = "$form->{year}0731";
637
        $form->{"0407"}   = "X";
638
        last SWITCH;
639
      };
640
      $form->{period} eq "08" && do {
641
        $form->{fromdate} = "$form->{year}0801";
642
        $form->{todate}   = "$form->{year}0831";
643
        $form->{"0408"}   = "X";
644
        last SWITCH;
645
      };
646
      $form->{period} eq "09" && do {
647
        $form->{fromdate} = "$form->{year}0901";
648
        $form->{todate}   = "$form->{year}0930";
649
        $form->{"0409"}   = "X";
650
        last SWITCH;
651
      };
652
      $form->{period} eq "10" && do {
653
        $form->{fromdate} = "$form->{year}1001";
654
        $form->{todate}   = "$form->{year}1031";
655
        $form->{"0410"}   = "X";
656
        last SWITCH;
657
      };
658
      $form->{period} eq "11" && do {
659
        $form->{fromdate} = "$form->{year}1101";
660
        $form->{todate}   = "$form->{year}1130";
661
        $form->{"0411"}   = "X";
662
        last SWITCH;
663
      };
664
      $form->{period} eq "12" && do {
665
        $form->{fromdate} = "$form->{year}1201";
666
        $form->{todate}   = "$form->{year}1231";
667
        $form->{"0412"}   = "X";
668
        last SWITCH;
669
      };
670
    }
671

  
672
  # Kontrollvariablen für die Templates
673
  $form->{"year$_"} = ($form->{year} >= $_ ) ? "1":"0" for 2007..2107;
580
  $ustva->set_FromTo(\%$form);
674 581

  
675 582
  # Get the USTVA
676 583
  $ustva->ustva(\%myconfig, \%$form);
......
737 644

  
738 645
  if ($form->{address} ne '') {
739 646
    my $temp = $form->{address};
740
    $temp =~ s/\\n/<br \/>/;
741
    ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp);
647
    $temp =~ s/\n/<br \/>/;
648
    ($form->{co_street}, $form->{co_city}) = split("<br \/>", $temp,2);
742 649
    $form->{co_city} =~ s/\\n//g;
743 650
  }
744 651

  
......
752 659

  
753 660
  if ( $form->{coa} eq 'Germany-DATEV-SKR03EU' or $form->{coa} eq 'Germany-DATEV-SKR04EU') {
754 661

  
755
    #
756
    # Outputformat specific customisation's
757
    #
758

  
759
    my @category_cent = $ustva->report_variables({
760
        myconfig    => \%myconfig,
761
        form        => $form,
762
        type        => '',
763
        attribute   => 'position',
764
        dec_places  => '2',
765
    });
766

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

  
769
    my @category_euro = $ustva->report_variables({
770
        myconfig    => \%myconfig,
771
        form        => $form,
772
        type        => '',
773
        attribute   => 'position',
774
        dec_places  => '0',
775
    });
662
   $form->{id} = [];
663
   $form->{amount} = [];
776 664

  
777
    $form->{id} = [];
778
    $form->{amount} = [];
779

  
780
    if ( $form->{format} eq 'pdf' or $form->{format} eq 'postscript') {
665
   if ( $form->{format} eq 'pdf' or $form->{format} eq 'postscript') {
781 666

  
782 667
      $form->{IN} = "$form->{type}-$form->{year}.tex";
783 668
      $form->{padding} = "~~";
......
787 672

  
788 673
      # Zahlenformatierung für Latex USTVA Formulare
789 674

  
790
      foreach my $number (@category_euro) {
675
      foreach my $number (@{$::form->{category_euro}}) {
791 676
        $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '');
792 677
      }
793 678

  
794 679
      my ${decimal_comma} = ( $myconfig{numberformat} eq '1.000,00'
795 680
           or $myconfig{numberformat} eq '1000,00' ) ? ',':'.';
796 681

  
797
      foreach my $number (@category_cent) {
682
      foreach my $number (@{$::form->{category_cent}}) {
798 683
        $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '');
799 684
        $form->{$number} =~ s/${decimal_comma}/~~/g;
800 685
      }
......
808 693
      $form->{br}      = "<br>";
809 694
      $form->{address} =~ s/\\n/\n/g;
810 695

  
811
      foreach my $number (@category_cent) {
696
      foreach my $number (@{$::form->{category_cent}}) {
812 697
        $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '2', '0');
813 698
      }
814 699

  
815
      foreach my $number (@category_euro) {
700
      foreach my $number (@{$::form->{category_euro}}) {
816 701
        $form->{$number} = $form->format_amount(\%myconfig, $form->{$number}, '0', '0');
817 702
      }
818 703
    } elsif ( $form->{format} eq '' ){ # No format error.
704

  
819 705
      $form->header;
820 706
      USTVA::error( $locale->text('Application Error. No Format given' ) . "!");
821 707
      $::dispatcher->end_request;
......
830 716
  } else  # Outputformat for generic output
831 717
  {
832 718

  
833
    my @category_cent = $ustva->report_variables({
834
        myconfig    => \%myconfig,
835
        form        => $form,
836
        type        => '',
837
        attribute   => 'position',
838
        dec_places  => '2',
839
    });
840

  
841
    my @category_euro = $ustva->report_variables({
842
        myconfig    => \%myconfig,
843
        form        => $form,
844
        type        => '',
845
        attribute   => 'position',
846
        dec_places  => '0',
847
    });
848

  
849 719
    $form->{USTVA} = [];
850 720

  
851 721
    if ( $form->{format} eq 'generic') { # Formatierungen für HTML Ausgabe
852 722

  
853 723
      my $rec_ref = {};
854
      for my $kennziffer (@category_cent, @category_euro) {
724
      for my $kennziffer (@{$::form->{category_cent}}, @{$::form->{category_euro}}) {
855 725
        $rec_ref = {};
856 726
        $rec_ref->{id} = $kennziffer;
857 727
        $rec_ref->{amount} = $form->format_amount(\%myconfig, $form->{$kennziffer}, 2, '0');
......
885 755

  
886 756
    print($form->parse_html_template('ustva/generic_taxreport', $template_ref));
887 757

  
758
  } elsif ( $form->{format} eq 'elstertaxbird' ) {
759
   $form->parse_template(\%myconfig);
888 760
  } else
889 761
  {
890 762
   # add a prefix for ustva pos numbers, i.e.: 81 ->  post_ustva_81
......
912 784
  $::form->header;
913 785

  
914 786
  my $ustva = USTVA->new();
915
  $ustva->get_config($::lx_office_conf{paths}{userspath}, 'finanzamt.ini');
787
  $ustva->get_config();
788
  $ustva->get_finanzamt();
916 789

  
917
  my $land = $::form->{elsterland};
918
  my $amt  = $::form->{elsterFFFF};
790
  my $land = $::form->{fa_land_nr};
791
  my $amt  = $::form->{fa_bufa_nr};
919 792

  
920 793

  
921 794
  $::form->{title} = $::locale->text('Tax Office Preferences');
922 795

  
923 796

  
924 797
  my $select_tax_office               = $ustva->fa_auswahl($land, $amt, $ustva->query_finanzamt(\%::myconfig, $::form));
925
  my $checked_accrual                 = $::form->{method}        eq 'accrual' ? q|checked="checked"| : '';
926
  my $checked_cash                    = $::form->{method}        eq 'cash'    ? q|checked="checked"| : '';
927
  my $checked_monthly                 = $::form->{FA_voranmeld}  eq 'month'   ? "checked"            : '';
928
  my $checked_quarterly               = $::form->{FA_voranmeld}  eq 'quarter' ? "checked"            : '';
929
  my $checked_dauerfristverlaengerung = $::form->{FA_dauerfrist} eq '1'       ? "checked"            : '';
930
  my $checked_kz_71                   = $::form->{FA_71}         eq 'X'       ? "checked"            : '';
798
  my $method_local = ($::form->{accounting_method} eq 'accrual') ? $::locale->text('accrual')
799
                   : ($::form->{accounting_method} eq 'cash')    ? $::locale->text('cash')
800
                   : '';
801

  
802
  my $checked_monthly                 = $::form->{fa_voranmeld}  eq 'month'   ? "checked"            : '';
803
  my $checked_quarterly               = $::form->{fa_voranmeld}  eq 'quarter' ? "checked"            : '';
804
  my $checked_dauerfristverlaengerung = $::form->{da_dauerfrist} eq '1'       ? "checked"            : '';
931 805

  
932 806
  my $_hidden_variables_ref;
933 807

  
......
942 816
        { 'variable' => $variable, 'value' => $_hidden_local_variables{$variable} };
943 817
  }
944 818

  
945
  my @_hidden_form_variables = qw(
946
    FA_Name             FA_Strasse        FA_PLZ
947
    FA_Ort              FA_Telefon        FA_Fax
948
    FA_PLZ_Grosskunden  FA_PLZ_Postfach   FA_Postfach
949
    FA_BLZ_1            FA_Kontonummer_1  FA_Bankbezeichnung_1
950
    FA_BLZ_2            FA_Kontonummer_2  FA_Bankbezeichnung_oertlich
951
    FA_Oeffnungszeiten  FA_Email          FA_Internet
952
    steuernummer        elsterland        elstersteuernummer
953
    elsterFFFF
954
  );
819
  my @_hidden_form_variables = $ustva->get_fiamt_vars();
820
  push @_hidden_form_variables ,qw(fa_bufa_nr taxnumber accounting_method coa);
955 821

  
956 822
  foreach my $variable (@_hidden_form_variables) {
957 823
    push @{ $_hidden_variables_ref},
958 824
        { 'variable' => $variable, 'value' => $::form->{$variable} };
959 825
  }
960 826

  
961
# Which COA is in use?
962

  
963 827
  $ustva->get_coa($::form); # fetches coa and modifies some form variables
964 828

  
965
  # hä? kann die weg?
966
  my $steuernummer_new = '';
967

  
968 829
  # Variablen für das Template zur Verfügung stellen
969 830
  my $template_ref = {
970 831
     select_tax_office               => $select_tax_office,
971
     checked_accrual                 => $checked_accrual,
972
     checked_cash                    => $checked_cash,
832
     method_local                    => $method_local,
973 833
     checked_monthly                 => $checked_monthly,
... Dieser Diff wurde abgeschnitten, weil er die maximale Anzahl anzuzeigender Zeilen überschreitet.

Auch abrufbar als: Unified diff