0.0
No commit activity in last 3 years
No release in over 3 years
Library to check or generate french VAT / SIREN / SIRET
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.15
~> 12.3.3
~> 3.0
 Project Readme

vat-siren-siret

Build Status Coverage Status Gem Version License GitHub pull requests

This library allows to check french VAT, SIRET and SIREN, to generate french VAT, SIRET and SIREN and to generate VAT or SIREN from SIRET, SIREN and VAT.

It has been largely inspired by the eponymous JS library and the ruby siret gem

Installation

Add this line to your application's Gemfile:

gem 'vat-siren-siret', '~> 1.0'

And then execute:

$ bundle

Or install it yourself as:

$ gem install vat-siren-siret

Usage

// Check string
Vss.siren?('813454717')      // true
Vss.siret?('81345471700014') // true
Vss.vat?('FR42813454717')    // true

// Generate VAT from SIREN / SIRET
Vss.to_vat('813454717')      // FR42813454717
Vss.to_vat('81345471700014') // FR42813454717

// Generate SIREN from SIRET / VAT
Vss.to_siren('81345471700014') // 813454717
Vss.to_siren('FR42813454717')  // 813454717

// Generate SIREN / SIRET / VAT
Vss.generate_siren // 022676134
Vss.generate_siret // 07577658981212
Vss.generate_vat   // FR60087471512

API

Vss.siren?(value)

Evaluate if the value is a SIREN and return a boolean.

Vss.siret?(value)

Evaluate if the value is a SIRET and return a boolean.

Vss.vat?(value)

Evaluate if the value is a french VAT and return a boolean.

Vss.to_vat(value)

Generate the french VAT from a SIREN or a SIRET and return a string
Return nil when value is neither a SIREN, SIRET or VAT.

Vss.to_siren(value)

Generate the SIREN from a VAT or a SIRET and return a string
Return nil when value is neither a SIREN, SIRET or VAT.

Vss.generate_siren

Generate a random SIREN passing the luhn check.

Vss.generate_siret

Generate a random SIRET passing the luhn check.

Vss.generate_vat

Generate a random VAT passing the luhn check.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/MathieuDerelle/vat-siren-siret.

License

The gem is available as open source under the terms of the MIT License.