Greek AFM (TIN) Validator and Generator
Project description
Greek TIN/AFM Validator and Generator
Validate and generate Greek TIN (Tax Identification Number) / AFM (Αριθμός Φορολογικού Μητρώου). Generation function can create valid or invalid numbers including parameters for old format, individuals, legal entities and repet tolerance digits control.
Online demo and presentation
https://lytrax.io/blog/projects/greek-tin-validator-generator
Installation
pip install lytrax-afm
Usage
Import functions:
from lytrax_afm import validateAFM, \
generateAFM, \
generateValidAFM, \
generateInvalidAFM
Validate a number:
>>> validate_afm("090000045")
True
>>> validate_afm("123456789")
False
Generate a valid number:
>>> generate_valid_afm()
'731385437'
Generate an invalid number:
>>> generate_invalid_afm()
'853003357'
API
validate_afm
afm: str
- A string to be check if it's a valid AFMextended_result: bool, optional
- Return extended object result if True, single boolean otherwise (default is False)- Returns:
str
ordict
(Dictionary with'valid': boolean
and'error': str ('length' or 'nan' or 'zero' or 'invalid')
)
Example:
>>> validate_afm("ab1234", extended_result=True)
{'valid': False, 'error': 'length'}
generate_afm
force_first_digit: int, optional
- If specified, overrides all pre99, legalEntity and individual (default is None)pre99: bool, optional
- Για ΑΦΜ πριν από 1/1/1999 (ξεκινάει με 0), (if True, overrides both legal_entity and individual) (default is False)individual: bool, optional
- Φυσικά πρόσωπα, (ξεκινάει με 1-4) (default is False)legal_entity: bool, optional
- Νομικές οντότητες (ξεκινάει με 7-9) (default is False)repeat_tolerance : int, optional
- Number for max repeat tolerance (0 for no repeats, unspecified for no check) (default is None)valid: bool, optional
- Generate valid or invalid AFM (default is True)- Returns:
str
- A valid or invalid 9 digit AFM number
Example:
>>> generate_afm(force_first_digit=3, repeat_tolerance=1, valid=True)
'335151580'
generate_valid_afm - Same as generate_afm
with valid
parameter force and override to True
- Returns:
str
- A valid 9 digit AFM number
Example:
>>> generate_valid_afm(pre99=True)
'013583460'
generate_invalid_afm - Same as generate_afm
with valid
parameter force and override to False
- Returns:
str
- An invalid 9 digit AFM number
Example:
>>> generate_invalid_afm(legal_entity=True)
'780300643'
Test
Clone this repository, run test:
git clone https://github.com/clytras/afm-python.git && cd afm-python
python -m unittest discover -s './test' -v
Changelog
See CHANGELOG
License
MIT License - see the LICENSE file for details
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file lytrax_afm-1.0.1.tar.gz
.
File metadata
- Download URL: lytrax_afm-1.0.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 221239e6cf4809a4304e2da0726069fbc42dd6dea170e9c1b61c37c061f6d7e4 |
|
MD5 | f3d5d1012b2199a5ade7220a71dd7ef7 |
|
BLAKE2b-256 | ed8a0c9c7b285ea324656e3dd756c0600fc75c00bb54f9fb3aa5ee0c1bbd8a79 |
File details
Details for the file lytrax_afm-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: lytrax_afm-1.0.1-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 875d022edaacf2ade094837bc69321621a4b8cd4af5abf02ede940f4e49807e1 |
|
MD5 | 33fbd539a60d7d39e5c257011156aea7 |
|
BLAKE2b-256 | 78a6c70cf81eabf61328df00b2fbb76e17863a653c6634d8f60c6d6181e5532b |