Skip to content

Commit

Permalink
Added company_vat faker (#1120)
Browse files Browse the repository at this point in the history
* Added company_vat faker

* ISSUE-1123 handle leap day year shifts (#1124)

When Faker attempts to generate a date_of_birth on 29th of February on the leap year it fails  if it tries to return a year that is not also a leap year.

This patch fixes the issue by extracting the year adjust to its own function that catches the ValueError and if the starting date is YYYY-02-29 it will adjust the date to YYYY-03-01.

* Add generating random french licence plates (#1122)

* Add initial failing test

* Add french car licence plates

* Fixed flake8 issue

* Removed one source to pass flake8 tests

Co-authored-by: Simon Persson <simon@akep.se>

* Add HTTP methods random generator (#1119)

* Add HTTP methods generator

* Add tests for HTTP methods generator

* Fix years in CHANGELOG.rst (#1127)

* locale pt-BR fixed official cellphone_formats and PhoneNumberProvider without DDD (#1121)

* 📝 Update CHANGELOG

* Bump version: 4.0.1 → 4.0.2

* MSISDN is mobile number only (#1132)

* Add dga by date (#1136)

* Add Domain Generator Algorithm (DGA) by date

* Add Domain Generator Algorithm (DGA) by date test

* #1131 Fixes issue where pydict provider was not returing the correct number of elements. (#1137)

* Adds support for Indian Aadhaar numbers (#1138)

* Adds support for Indian Aadhaar numbers

This change also introduces the en_IN locale.

As we needed to use a Luhn  check - moved an existing implementation
to utils along with additional tests

* Sort imports and changes for flake8 rules

Co-authored-by: Dinu Nair <dinunair@gmail.com>
Co-authored-by: Dinu Nair <dinu@esthenos.com>

* Removing spaces

* Added company_vat faker

* Removing spaces

* Use checkum calculator from commont utils

* standardizing imports

Co-authored-by: Marco <marco@esplores.com>
Co-authored-by: Matt McMahon <matt.mcmahon@gmail.com>
Co-authored-by: clarissedescamps <clarisse.descamps96@yahoo.fr>
Co-authored-by: Simon Persson <simon@akep.se>
Co-authored-by: Roman Pishchalnikov <roman.pishchalnikov@gmail.com>
Co-authored-by: Laurent Bristiel <laurent@bristiel.com>
Co-authored-by: Flavio Curella <89607+fcurella@users.noreply.github.com>
Co-authored-by: fcurella <flavio.curella@gmail.com>
Co-authored-by: Rodrigo Castro <rodrigondec@gmail.com>
Co-authored-by: mstellon <39681459+mstellon@users.noreply.github.com>
Co-authored-by: curiousElf <dinunair+github@gmail.com>
Co-authored-by: Dinu Nair <dinunair@gmail.com>
Co-authored-by: Dinu Nair <dinu@esthenos.com>
  • Loading branch information
14 people authored Mar 27, 2020
1 parent b0a34d6 commit 0b92232
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions faker/providers/company/it_IT/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from faker.utils.checksums import calculate_luhn

from .. import Provider as CompanyProvider


Expand Down Expand Up @@ -349,3 +351,11 @@ def bs(self):
result.append(self.random_element(word_list))

return " ".join(result)

def company_vat(self):
"""
Returns Italian VAT identification number (Partita IVA).
"""
code = "0" + self.bothify('######') + str(self.generator.random.randrange(1, 121)).zfill(3)
luhn_checksum = str(calculate_luhn(code))
return 'IT{}{}'.format(code, luhn_checksum)

0 comments on commit 0b92232

Please sign in to comment.