eurovat


Nameeurovat JSON
Version 0.10.1 PyPI version JSON
download
home_pagehttps://github.com/airgproducts/eurovat
SummaryA python library to get the vat right in the EU.
upload_time2024-04-15 13:24:02
maintainerNone
docs_urlNone
authorairG products
requires_pythonNone
licenseMIT License
keywords vat eu tax
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Eurovat

A python library to get the vat right in the EU.

## Features

* fetch vat-rates from [tedb](https://ec.europa.eu/taxation_customs/tedb/vatSearchForm.html)
* get the proper vat-rate
    - for [cn-codes](https://ec.europa.eu/taxation_customs/business/calculation-customs-duties/customs-tariff/combined-nomenclature_en)
    - for [cpa-codes](https://ec.europa.eu/eurostat/web/cpa/cpa-2008) - UNTESTED/PARTIAL SUPPORT
    - for a given datetime (temporary vat-rates)
* VIES validation
* cn-code helpers

## Planned features

* fetch newest rates daily with gh-actions and submit automated PR's

## Installation

just use pip:

```
pip install eurovat
```

## Vat rates

you can query the vat-registry with the following arguments:

* country
    - iso-code or `eurovat.EUState` object
* cn-code
    - optional
    - get reduced rates for certain cn-codes
* cpa-code
    - optional
    - get reduced rates for certain cpa-codes
* date
    - optional
    - get temporary reduced rates for the given date

``` python
import eurovat
import datetime

registry = eurovat.VatRuleRegistry()
registry.date_begin = datetime.datetime(1970, 1, 1)

# This will try to write to vat_rules.json in the package directory
registry.update()

# This will update the in-memory database, all changes will be lost
registry.fetch()

# get a historic vat-rate

rate1 = registry.get_vat_rate("AT", "49020000", date=datetime.datetime(year=2019, month=10, day=5))
# rate1 = 10

rate2 = registry.get_vat_rate("AT", "49020000", date=datetime.datetime(year=2016, month=10, day=5))
# rate2 = 20
```

## Update the registry

keep the registry up-to-date from time to time:

``` python
registry.update()
```

this will require write access to the package-file `vat_rules.json`. There are alternative storage locations available:

### Filesystem cache

when writing to package data is not an option, you can use a custom cache-file:

``` python
import eurovat
import datetime

class Registry(eurovat.VatRuleRegistry):
    cache = eurovat.FilesystemCache("/tmp/vat_rules.json")
    date_begin = datetime.datetime(1970, 1, 1)


registry = Registry()
registry.update()

```

### Django cache

This will use Django's cache backend to store vat-rules

``` python
import eurovat
import datetime

from eurovat.cache.django import DjangoCache


class Registry(eurovat.VatRuleRegistry):
    cache = DjangoCache("eurovat_rates")
    date_begin = datetime.datetime(1970, 1, 1)


registry = Registry()
registry.update()

```

### Custom cache


You can use a custom cache too.
Find an example in [eurovat.cache.django](eurovat/cache/django.py)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/airgproducts/eurovat",
    "name": "eurovat",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "vat, eu, tax",
    "author": "airG products",
    "author_email": "hello@airgproducts.com",
    "download_url": "https://files.pythonhosted.org/packages/66/91/9eb1e195ab5303ca64f4c2cf386f98fa56142ef45681e5f35e96066fa310/eurovat-0.10.1.tar.gz",
    "platform": null,
    "description": "# Eurovat\n\nA python library to get the vat right in the EU.\n\n## Features\n\n* fetch vat-rates from [tedb](https://ec.europa.eu/taxation_customs/tedb/vatSearchForm.html)\n* get the proper vat-rate\n    - for [cn-codes](https://ec.europa.eu/taxation_customs/business/calculation-customs-duties/customs-tariff/combined-nomenclature_en)\n    - for [cpa-codes](https://ec.europa.eu/eurostat/web/cpa/cpa-2008) - UNTESTED/PARTIAL SUPPORT\n    - for a given datetime (temporary vat-rates)\n* VIES validation\n* cn-code helpers\n\n## Planned features\n\n* fetch newest rates daily with gh-actions and submit automated PR's\n\n## Installation\n\njust use pip:\n\n```\npip install eurovat\n```\n\n## Vat rates\n\nyou can query the vat-registry with the following arguments:\n\n* country\n    - iso-code or `eurovat.EUState` object\n* cn-code\n    - optional\n    - get reduced rates for certain cn-codes\n* cpa-code\n    - optional\n    - get reduced rates for certain cpa-codes\n* date\n    - optional\n    - get temporary reduced rates for the given date\n\n``` python\nimport eurovat\nimport datetime\n\nregistry = eurovat.VatRuleRegistry()\nregistry.date_begin = datetime.datetime(1970, 1, 1)\n\n# This will try to write to vat_rules.json in the package directory\nregistry.update()\n\n# This will update the in-memory database, all changes will be lost\nregistry.fetch()\n\n# get a historic vat-rate\n\nrate1 = registry.get_vat_rate(\"AT\", \"49020000\", date=datetime.datetime(year=2019, month=10, day=5))\n# rate1 = 10\n\nrate2 = registry.get_vat_rate(\"AT\", \"49020000\", date=datetime.datetime(year=2016, month=10, day=5))\n# rate2 = 20\n```\n\n## Update the registry\n\nkeep the registry up-to-date from time to time:\n\n``` python\nregistry.update()\n```\n\nthis will require write access to the package-file `vat_rules.json`. There are alternative storage locations available:\n\n### Filesystem cache\n\nwhen writing to package data is not an option, you can use a custom cache-file:\n\n``` python\nimport eurovat\nimport datetime\n\nclass Registry(eurovat.VatRuleRegistry):\n    cache = eurovat.FilesystemCache(\"/tmp/vat_rules.json\")\n    date_begin = datetime.datetime(1970, 1, 1)\n\n\nregistry = Registry()\nregistry.update()\n\n```\n\n### Django cache\n\nThis will use Django's cache backend to store vat-rules\n\n``` python\nimport eurovat\nimport datetime\n\nfrom eurovat.cache.django import DjangoCache\n\n\nclass Registry(eurovat.VatRuleRegistry):\n    cache = DjangoCache(\"eurovat_rates\")\n    date_begin = datetime.datetime(1970, 1, 1)\n\n\nregistry = Registry()\nregistry.update()\n\n```\n\n### Custom cache\n\n\nYou can use a custom cache too.\nFind an example in [eurovat.cache.django](eurovat/cache/django.py)\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "A python library to get the vat right in the EU.",
    "version": "0.10.1",
    "project_urls": {
        "Homepage": "https://github.com/airgproducts/eurovat"
    },
    "split_keywords": [
        "vat",
        " eu",
        " tax"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "31703d7be2908e3f6374d0f935b2eb753ead3de9ca0062216972c88f50c9a36a",
                "md5": "07a1b4624e8020e53d58108922fe663c",
                "sha256": "3e4f374c77fc7b7632a862736a6f10677335bd5478a52d72bfbf3505ea219890"
            },
            "downloads": -1,
            "filename": "eurovat-0.10.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "07a1b4624e8020e53d58108922fe663c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 119967,
            "upload_time": "2024-04-15T13:24:00",
            "upload_time_iso_8601": "2024-04-15T13:24:00.632091Z",
            "url": "https://files.pythonhosted.org/packages/31/70/3d7be2908e3f6374d0f935b2eb753ead3de9ca0062216972c88f50c9a36a/eurovat-0.10.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "66919eb1e195ab5303ca64f4c2cf386f98fa56142ef45681e5f35e96066fa310",
                "md5": "54ba39388780fee7a55a897d331a77b0",
                "sha256": "5370eba9b4cbb7ad27ea168e8763e0d8fee7fa18a3c37f986a85611a3d28ce47"
            },
            "downloads": -1,
            "filename": "eurovat-0.10.1.tar.gz",
            "has_sig": false,
            "md5_digest": "54ba39388780fee7a55a897d331a77b0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 115651,
            "upload_time": "2024-04-15T13:24:02",
            "upload_time_iso_8601": "2024-04-15T13:24:02.413525Z",
            "url": "https://files.pythonhosted.org/packages/66/91/9eb1e195ab5303ca64f4c2cf386f98fa56142ef45681e5f35e96066fa310/eurovat-0.10.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-15 13:24:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "airgproducts",
    "github_project": "eurovat",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "eurovat"
}
        
Elapsed time: 0.23572s