Last active
February 13, 2017 14:44
-
-
Save angelodlfrtr/af1ae2a0159c655509e6 to your computer and use it in GitHub Desktop.
SIRET to no TVA
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
class String | |
# SIRET or SIREN to French VAT number | |
def to_tva | |
siren = self[0..8].to_i | |
cle_tva = (((siren % 97) * 3) + 12) % 97 | |
(cle_tva < 10) ? "FR0#{cle_tva} #{siren}" : "FR#{cle_tva} #{siren}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment