Created
February 18, 2015 17:58
-
-
Save genee19/c10f072c87480f1848c3 to your computer and use it in GitHub Desktop.
Проверка валидности ИНН юрлица на Ruby (согласно http://www.egrul.ru/test_inn.html)
This file contains hidden or 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
def valid_le_tax_id? (tax_id) | |
tax_id = tax_id.to_s.split('') | |
weights = [2,4,10,3,5,9,4,6,8,0] | |
sum = tax_id.each_with_index.reduce(0){|result,item| | |
result += item[0].to_i * weights[item[1]] | |
}%11%10 | |
return sum == tax_id[9].to_i | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment