From 9a1c5b19d56a9a543ce6b2c3aa0463d12764b406 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 30 Dec 2010 13:51:40 +0100 Subject: [PATCH] Taxbird-export: Mit Heuristik versuchen PLZ und Stadt aus dem Firmenadressfeld zu extrahieren MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Teilfix für Bug 1488 --- bin/mozilla/ustva.pl | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/bin/mozilla/ustva.pl b/bin/mozilla/ustva.pl index f04c8ee05..1bbf93145 100644 --- a/bin/mozilla/ustva.pl +++ b/bin/mozilla/ustva.pl @@ -919,14 +919,30 @@ sub generate_ustva { ::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; - $form->{co_zip} = $form->{co_city}; - $form->{co_zip} =~ s/\D//g; - $form->{co_city} =~ s/\d//g; - $form->{co_city} =~ s/^\s//g; - ($form->{co_phone_prefix}, $form->{co_phone}) = split("-", $form->{tel}); $form->{co_phone_prefix} =~ s/\s//g; $form->{co_phone} =~ s/\s//g; -- 2.20.1