+
+ } elsif ( $form->{format} eq 'elstertaxbird' ) {
+
+ # Define serveral filenames
+ $form->{IN} = 'taxbird.txb';
+
+ $form->{attachment_filename} = "USTVA-" . $form->{period}
+ . sprintf("%02d", $form->{year} % 100) . ".txb";
+
+ $form->{attachment_filename} =~ s|.*/||;
+ $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',
+ );
+
+ 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->{taxbird_period} = $period;
+ } else {
+ $form->header;
+ USTVA::error( $locale->text('Wrong Period' ));
+ ::end_of_request();
+ }
+
+ # heuristics for address splitting
+ # lx-office holds the entire address in a single field.
+ # taxbird expects it to be splitted into street, zipcode and city
+ if ($form->{co_street} =~ /\n/) {
+ my $new_co_street;
+ for (split /\n/, $form->{co_street}) {
+ if (/(\d{3,5})\s+(\w+)/) {
+ $form->{co_zip} = $1;
+ $form->{co_city} = $2;
+ } else {
+ $new_co_street .= $_;
+ }
+ }
+ $form->{co_street} = $new_co_street;
+ } else {
+ $form->{co_zip} = $form->{co_city};
+ $form->{co_zip} =~ s/\D//g;
+ $form->{co_city} =~ s/\d//g;
+ $form->{co_city} =~ s/^\s//g;
+ }
+
+ my $tax_office = first { $_->{name} eq $form->{elsterland} } @{ $ustva->{tax_office_information} };
+ $form->{taxbird_land_nr} = $tax_office->{taxbird_nr} if $tax_office;
+