Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Проверка валидности ИНН юрлица на Ruby (согласно http://www.egrul.ru/test_inn.html)
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