Skip to main content

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

Project description

Eurovat

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

Features

  • fetch vat-rates from tedb
  • get the proper vat-rate
    • for cn-codes
    • for cpa-codes - 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
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:

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:

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eurovat-0.9.1.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

eurovat-0.9.1-py3-none-any.whl (119.8 kB view details)

Uploaded Python 3

File details

Details for the file eurovat-0.9.1.tar.gz.

File metadata

  • Download URL: eurovat-0.9.1.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for eurovat-0.9.1.tar.gz
Algorithm Hash digest
SHA256 4d15a7118d390fcf34aa595405b8b23d1ca0a893ca8b80385318cfecf1c8bb5f
MD5 cea525dc3bd3b1bab6b77e30cf8db6bc
BLAKE2b-256 65e33410f00b3b66ba9e406679b5d50d3e0ef3897d1dbe30cb1efd4be5787b9e

See more details on using hashes here.

Provenance

File details

Details for the file eurovat-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: eurovat-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 119.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for eurovat-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7c549d88dee5dcfeaa8e80cad858511e0c4e006b3cc1499f5f9a8ce030ebd1e4
MD5 9e9f0120626eb794856ce92671743655
BLAKE2b-256 ffcdeaafe00d1934a5f1a4889b6ac732fc132708ee50da3db8074dd304bbf773

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page