From 6d7ba58f880be618ade07f8ea080fe8c4bf8a896 Mon Sep 17 00:00:00 2001 From: cyfraeviolae Date: Wed, 3 Apr 2024 03:10:44 -0400 Subject: venv --- .../faker/providers/ssn/es_CO/__init__.py | 72 +++++++++++++++++++++ .../ssn/es_CO/__pycache__/__init__.cpython-311.pyc | Bin 0 -> 3718 bytes 2 files changed, 72 insertions(+) create mode 100644 venv/lib/python3.11/site-packages/faker/providers/ssn/es_CO/__init__.py create mode 100644 venv/lib/python3.11/site-packages/faker/providers/ssn/es_CO/__pycache__/__init__.cpython-311.pyc (limited to 'venv/lib/python3.11/site-packages/faker/providers/ssn/es_CO') diff --git a/venv/lib/python3.11/site-packages/faker/providers/ssn/es_CO/__init__.py b/venv/lib/python3.11/site-packages/faker/providers/ssn/es_CO/__init__.py new file mode 100644 index 0000000..c33e628 --- /dev/null +++ b/venv/lib/python3.11/site-packages/faker/providers/ssn/es_CO/__init__.py @@ -0,0 +1,72 @@ +import operator + +from collections import OrderedDict + +from .. import Provider as BaseProvider + + +def nit_check_digit(nit: str) -> str: + """ + Calculate the check digit of a NIT. + + The check digit is calculated by multiplying the reversed digits of a NIT + by (3, 7, 13, 17, 19, 23, 29, 37, 41, 43, 47, 53, 59, 67, 71), respectively, + adding the results and applying MOD 11. If the result is greater than or equal + to 2, the check digit is 11 minus the result. Otherwise, the check digit is the + result. + """ + reversed_nit = nit[::-1] + digits = (int(digit) for digit in reversed_nit) + multipliers = (3, 7, 13, 17, 19, 23, 29, 37, 41, 43, 47, 53, 59, 67, 71) + value = sum(map(operator.mul, digits, multipliers)) % 11 + if value >= 2: + value = 11 - value + return str(value) + + +class Provider(BaseProvider): + nuip_formats = OrderedDict( + [ + ("10########", 0.25), + ("11########", 0.25), + ("12########", 0.1), + ("%!######", 0.4), + ] + ) + + legal_person_nit_formats = [ + "8########", + "9########", + ] + + def nuip(self) -> str: + """ + https://es.wikipedia.org/wiki/C%C3%A9dula_de_Ciudadan%C3%ADa_(Colombia) + :example: '1095312769' + """ + return self.numerify(self.random_element(self.nuip_formats)) + + natural_person_nit = nuip + + def natural_person_nit_with_check_digit(self) -> str: + """ + :example: '1095312769-0' + """ + nit = self.natural_person_nit() + check_digit = nit_check_digit(nit) + return f"{nit}-{check_digit}" + + def legal_person_nit(self) -> str: + """ + https://es.wikipedia.org/wiki/N%C3%BAmero_de_Identificaci%C3%B3n_Tributaria + :example: '967807269' + """ + return self.numerify(self.random_element(self.legal_person_nit_formats)) + + def legal_person_nit_with_check_digit(self) -> str: + """ + :example: '967807269-7' + """ + nit = self.legal_person_nit() + check_digit = nit_check_digit(nit) + return f"{nit}-{check_digit}" diff --git a/venv/lib/python3.11/site-packages/faker/providers/ssn/es_CO/__pycache__/__init__.cpython-311.pyc b/venv/lib/python3.11/site-packages/faker/providers/ssn/es_CO/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..47dcce9 Binary files /dev/null and b/venv/lib/python3.11/site-packages/faker/providers/ssn/es_CO/__pycache__/__init__.cpython-311.pyc differ -- cgit v1.2.3