欧盟增值税验证
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了欧盟增值税验证相关的知识,希望对你有一定的参考价值。
Look if the given input could be a legal VAT-number.Accepts input with or without '.' between the numbers and must contain a County-code
/** * http://www.pfz.nl/wiki/invoer-validatie/#Geldig_BTW.2FVAT_nummer * * Look if the given input could be a legal VAT-number. * Accepts input with or without '.' between the numbers, must contain a County-code * * Note: This only checks the syntax, NOT IF THE VAT REALLY EXISTS OR IS ACTIVE! * * @author Sebastiaan Stok <[email protected]> * * @param string $psVatInput * @return bool */ function isVAT($psVatInput) { // Common syntax return false; } $functionName = 'isVAT_'. $aVatMatch[1]; return $functionName($psVatInput); } 'AT' => 'U[0-9]{8}', 'BE' => '0[0-9]{9}', 'BG' => '[0-9]{9,10}', 'CY' => '[0-9]{8}[A-Za-z]', 'CZ' => '[0-9]{8,10}', 'DE' => '[0-9]{9}', 'DK' => '[0-9]{2} ?[0-9]{2} ?[0-9]{2} ?[0-9]{2}', 'EE' => '[0-9]{9}', 'EL' => '[0-9]{9}', 'ES' => '([A-Za-z0-9][0-9]{7}[A-Za-z0-9])', 'FI' => '[0-9]{8}', 'FR' => '[A-Za-z0-9]{2} ?[0-9]{9}', 'GB' => '([0-9]{3} ?[0-9]{4} ?[0-9]{2}|[0-9]{3} ?[0-9]{4} ?[0-9]{2} ?[0-9]{3}|GD[0-9]{3}|HA[0-9]{3})', 'HU' => '[0-8]{8}', 'IE' => '[0-9][A-Za-z0-9+*][0-9]{5}[A-Za-z]', 'IT' => '[0-9]{11}', 'LT' => '([0-9]{9}|[0-9]{12})', 'LU' => '[0-9]{8}', 'LV' => '[0-9]{11}', 'MT' => '[0-9]{8}', 'NL' => '[0-9]{9}B[0-9]{2}', 'PL' => '[0-9]{10}', 'PT' => '[0-9]{9}', 'RO' => '[0-9]{2,10}', 'SE' => '[0-9]{12}', 'SI' => '[0-9]{8}', 'SK' => '[0-9]{10}', ); if (!isset($aVatRegexes[$aVatMatch[1]]) || !preg_match('/^([a-z]{2})[ ]*'.$aVatRegexes[$aVatMatch[1]].'$/is', $psVatInput)) { return false; } return true; } /** * Checks whether or not the sofinummer provided passes the test of 11. * @version 2.0 * @param $sofinummer The sofinummer to be checked. * @return boolean * @author Ivo Peters * @author Berry Langerak, al had Ivo hem als eerste goed :) **/ function isVAT_NL( $psVatInput ) { // remove spaces and dots $sVatnr = $aMatch[1]; // lijst met nummers die qua check kloppen, maar toch niet geldig zijn '111111110', '999999990', '000000000', ); return false; } for ($i = 9, $som = -$sVatnr % 10; $i > 1; $i--) { $som += $i * $sVatnr{(9 - $i)}; } return ($som % 11 == 0); } return false; } /** * Check if the number might be a belgian VAT-number. * Accepts input with or without '.' and spaces between the numbers, * spaces at begin and end of string are ignored * it must contain a County-code (BE) at the start (case insensitive) * after the country code 9 or 10 digits follow. * if 10 digits are given, the first must be zero * * Note: This only checks the syntax, NOT IF THE VAT REALLY EXITS OR IS ACTIVE! * * @author Ivo Peters * * @param string $psVatInput * @return bool */ function isVAT_BE($psVatInput) { // remove spaces and dots } return false; } /** * Check if the number might be a GB VAT-number. * Accepts input with or without '.' and spaces between the numbers, * spaces at begin and end of string are ignored * it must contain a County-code (GB) at the start (case insensitive) * after the country code 9 digits follow. * * Note: This only checks the syntax, NOT IF THE VAT REALLY EXITS OR IS ACTIVE! * * @author Ivo Peters * * @param string $psVatInput * @return bool */ function isVAT_GB($psVatInput) { // remove spaces and dots $iSum = 0; for ($i = 0; $i < 7; $i++) { } return (97 - $iSum % 97 == $sVatnr % 100); } return false; }
以上是关于欧盟增值税验证的主要内容,如果未能解决你的问题,请参考以下文章