Skip to main content

A Python client for the tax table portion of the Norwegian tax authority's API

Project description

NorTax

GitHub License Python PyPI Downloads Codecov code coverage Github Contributors GitHub search hit counter GitHub issues GitHub last commit

Copyright 2023 Lewi Lie Uberg
Released under the MIT license

A Python client for the tax table portion of the Norwegian tax authority's API.

Usage

Using the NorTax package is easy. Just follow the steps below.

Import the Tax class from the nortax package

Python REPL:

from nortax import Tax

Create a Tax object

Python REPL:

tax = Tax(
gross_income=25000,
tax_table="7100",
income_type="Pension",
period="2 weeks",
year=2022,
)

Print the representation of the Tax object

Python REPL:

print(repr(tax))

Output:

Tax(gross_income=25000, tax_table='7100', income_type='Pension', period='2 weeks', year=2022)

Change some attributes of the Tax object

Python REPL:

tax.gross_income = 65625
tax.tax_table = "7107"
tax.income_type = "Wage"
tax.period = "Monthly"
tax.year = 2023

Print the Tax object

Python REPL:

print(tax)

Output:

URL: str = https://api-tabellkort.app.skatteetaten.no/?valgtTabell=7107&valgtInntektType=Lonn&valgtPeriode=PERIODE_1_MAANED&valgtLonn=65625&visHeleTabellen=True&valgtAar=2023&hentHeleTabellen=True
Tax table: valid_tables = 7107
Income type: income_type = Wage
Period: period = Monthly
Year: int = 2023
Gross income: int = 65625
Tax deduction: int = 21078
Net income: int = 44547
Return whole table: {'5600': 0, '5700': 1, '5800': 30}...

Get specific values from the Tax object

Get the URL

Python REPL:

print(f"URL: {tax.url}")

Output:

URL: https://api-tabellkort.app.skatteetaten.no/?valgtTabell=7107&valgtInntektType=Lonn&valgtPeriode=PERIODE_1_MAANED&valgtLonn=65625&visHeleTabellen=True&valgtAar=2023&hentHeleTabellen=True

Get the tax table

It is possible to get specific values from the Tax object. They are all available as attributes. Except for the whole table, which is available as a method.

Python REPL:

print(f"Tax table: {tax.tax_table}")

Output:

Tax table: 7107

Get the income type

Python REPL:

print(f"Income type: {tax.income_type}")

Output:

Income type: Wage

Get the period

Python REPL:

print(f"Period: {tax.period}")

Output:

Period: Monthly

Get the year

Python REPL:

print(f"Year: {tax.year}")

Output:

Year: 2023

Get the gross income

Python REPL:

print(f"Gross income: {tax.gross_income}")

Output:

Gross income: 65625

Get the tax deduction

Python REPL:

print(f"Tax deduction: {tax.deduction}")

Output:

Tax deduction: 21078

Get the net income

Python REPL:

print(f"Net income: {tax.net_income}")

Output:

Net income: 44547

Get the whole table

Python REPL:

print(f"Return whole table: {json.dumps(tax.get_whole_table(), indent=4)}")

Output:

Return whole table: {
    "5600": 0,
    "5700": 1,
    "5800": 30,
    "5900": 59,
    "6000": 88,
    "6100": 116,
    "6200": 145,
    "6300": 174,
    "6400": 203,
    "6500": ...

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

nortax-0.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

nortax-0.1.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file nortax-0.1.0.tar.gz.

File metadata

  • Download URL: nortax-0.1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.2 Darwin/22.3.0

File hashes

Hashes for nortax-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bdf20d9b45a43f7e354739556dd7192d17d7dd7b803ffbf59b06febf062509b0
MD5 177af63c8e577868ceeda5d3da32ceff
BLAKE2b-256 7ae1aa3302754669ce4dd9bfae534df0b49e13b9eaa6c77ee8555d7987a7e993

See more details on using hashes here.

File details

Details for the file nortax-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nortax-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.2 Darwin/22.3.0

File hashes

Hashes for nortax-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 88a7fea9625b1e2c109e30ca06627bbddad5395f2e9fd779e4e1fdfd1ee01bba
MD5 7d092af64eb94ebb14d669313b6b9c7d
BLAKE2b-256 20b3c7a22f87a7658d9066727bf35f27aa7b0043fa51e222bc900368da07f824

See more details on using hashes here.

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