Skip to content

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

License

Notifications You must be signed in to change notification settings

lewiuberg/nortax

Repository files navigation

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": ...

Raycast Script Commands

This package is also available as a Raycast script command. Just add the raycast_scripts folder to your Raycast script commands folder and you are good to go.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages