Last active
December 26, 2023 18:40
-
-
Save emir/e5e427243c28fdeb79158a26d566ce79 to your computer and use it in GitHub Desktop.
PHP Vergi Numarası Doğrulama
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This method logically validates Turkish VAT number | |
* | |
* @param string $taxNumber | |
* @return bool | |
*/ | |
public function validateTaxNumber(string $taxNumber): bool | |
{ | |
if (strlen($taxNumber) !== 10) { | |
return false; | |
} | |
$total = 0; | |
$checkNum = null; | |
for ($i = 0; $i < 9; $i++) { | |
$tmp1 = ($taxNumber[$i] + (9 - $i)) % 10; | |
$tmp2 = ($tmp1 * (2 ** (9 - $i))) % 9; | |
if ($tmp1 !== 0 && $tmp2 === 0) { | |
$tmp2 = 9; | |
} | |
$total += $tmp2; | |
} | |
if ($total % 10 === 0) { | |
$checkNum = 0; | |
} else { | |
$checkNum = 10 - ($total % 10); | |
} | |
if ((int)$taxNumber[9] !== $checkNum) { | |
return false; | |
} | |
return true; | |
} |
eline sağlık ya internette harbiden yok
Bende Şuraya C# için bırakayım.
https://github.com/anghelvalentin/CountryValidator?ysclid=l9bhkrouo5362869525
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Eline sağlık çok iyi yapmışsın, işimi kolaylaştırdın. Yoksa bende js bulmuştum ordan evircektim