From 82fa9647c416c0ba045a7c676800b097dea3dade Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 11 Mar 2020 12:04:46 +0100 Subject: [PATCH] ZUGFeRD: UStID-Nummern validieren und normalisiert ausgeben --- SL/DB/Helper/ZUGFeRD.pm | 11 ++++++----- locale/de/all | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/SL/DB/Helper/ZUGFeRD.pm b/SL/DB/Helper/ZUGFeRD.pm index 051125677..99e08256e 100644 --- a/SL/DB/Helper/ZUGFeRD.pm +++ b/SL/DB/Helper/ZUGFeRD.pm @@ -13,6 +13,7 @@ use SL::DB::TaxKey; use SL::Helper::ISO3166; use SL::Helper::ISO4217; use SL::Helper::UNECERecommendation20; +use SL::VATIDNr; use Carp; use Encode qw(encode); @@ -409,13 +410,9 @@ sub _exchanged_document { sub _specified_tax_registration { my ($ustid_nr, %params) = @_; - return unless $ustid_nr; - - $ustid_nr = "DE$ustid_nr" unless $ustid_nr =~ m{^[A-Z]{2}}; - # $params{xml}->startTag("ram:SpecifiedTaxRegistration"); - $params{xml}->dataElement("ram:ID", _u8($ustid_nr), schemeID => "VA"); + $params{xml}->dataElement("ram:ID", _u8(SL::VATIDNr->normalize($ustid_nr)), schemeID => "VA"); $params{xml}->endTag; # } @@ -577,6 +574,10 @@ sub _validate_data { SL::X::ZUGFeRDValidation->throw(message => $prefix . $::locale->text('The VAT registration number is missing in the client configuration.')); } + if (!SL::VATIDNr->validate($::instance_conf->get_co_ustid)) { + SL::X::ZUGFeRDValidation->throw(message => $prefix . $::locale->text("The VAT ID number in the client configuration is invalid.")); + } + if (!$::instance_conf->get_company || any { my $get = "get_address_$_"; !$::instance_conf->$get } qw(street1 zipcode city)) { SL::X::ZUGFeRDValidation->throw(message => $prefix . $::locale->text('The company\'s address information is incomplete in the client configuration.')); } diff --git a/locale/de/all b/locale/de/all index 9ed72f372..6599fdbb5 100755 --- a/locale/de/all +++ b/locale/de/all @@ -3198,6 +3198,7 @@ $self->{texts} = { 'The SQL query does not contain any parameter that need to be configured.' => 'Die SQL-Abfrage enthält keine Parameter, die angegeben werden müssten.', 'The URL is missing.' => 'URL fehlt', 'The VAT ID number \'#1\' is invalid.' => 'Die UStID-Nummer »#1« ist ungültig.', + 'The VAT ID number in the client configuration is invalid.' => 'Die UStID-Nummer in der Mandantenkonfiguraiton ist ungültig.', 'The VAT registration number is missing in the client configuration.' => 'Die Umsatzsteuer-ID-Nummer fehlt in der Mandantenkonfiguration.', 'The WebDAV feature has been used.' => 'Das WebDAV-Feature wurde benutzt.', 'The XMP metadata does not declare the ZUGFeRD data.' => 'Die XMP-Metadaten enthalten keine ZUGFeRD-Deklaration.', -- 2.20.1