diff --git a/Plugin/Service/Validate/ValidationService.php b/Plugin/Service/Validate/ValidationService.php new file mode 100644 index 0000000..36affda --- /dev/null +++ b/Plugin/Service/Validate/ValidationService.php @@ -0,0 +1,31 @@ +getCountryCodeForVatNumber($countryIso2)]; + } + + /** + * Returns the country code to use in the VAT number which is not always the same as the normal country code + * + * @param string $countryCode + * @return string + */ + private function getCountryCodeForVatNumber(string $countryCode): string + { + // Greece uses a different code for VAT numbers then its country code + // See: http://ec.europa.eu/taxation_customs/vies/faq.html#item_11 + // And https://en.wikipedia.org/wiki/VAT_identification_number: + // "The full identifier starts with an ISO 3166-1 alpha-2 (2 letters) country code + // (except for Greece, which uses the ISO 639-1 language code EL for the Greek language, + // instead of its ISO 3166-1 alpha-2 country code GR)" + + return $countryCode === 'GR' ? 'EL' : $countryCode; + } +} diff --git a/etc/di.xml b/etc/di.xml index f60219e..422c07a 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -16,6 +16,11 @@ + + + +