Created
May 5, 2014 08:03
-
-
Save kabutz/13ee4e22fc796a469d06 to your computer and use it in GitHub Desktop.
How to validate a Greek Tax Number (AFM)
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
// From http://www.gsis.gr/gsis/info/gsis_site/Services/Polites/sources.html | |
// gr.gsis.e7.E7File class | |
// Apache 2.0 license | |
public static boolean afmIsValid(String afm) { | |
int sum = 0; | |
if (afm.length() != 9) | |
return false; | |
for (int i = 0; i < 8; i++) | |
sum += (afm.charAt(i) - '0') << (8 - i); | |
return ((afm.charAt(8) - '0') == ((sum % 11) % 10)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment