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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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