Skip to content

Instantly share code, notes, and snippets.

@wvolkov
Created February 22, 2024 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wvolkov/5f0da21eebaf30bba4ac06a0d89c10bc to your computer and use it in GitHub Desktop.
Save wvolkov/5f0da21eebaf30bba4ac06a0d89c10bc to your computer and use it in GitHub Desktop.
Slovenia Income NET Salary Calculator for a wage worker
import pandas as pd
import numpy as np
ranges = [
    (0, 8755, 0.16),
    (8755, 25750, 0.26),
    (25750, 51500, 0.33),
    (51500, 74160, 0.39),
    (74160, np.inf, 0.5)
]
# preparing tax schedule for monthly salary
tax_schedule = pd.DataFrame(ranges, columns=['from', 'to', 'rate'])
tax_schedule['from'] = np.round(tax_schedule['from'] / 12.0, 2)
tax_schedule['to'] = np.round(tax_schedule['to'] / 12.0, 2)
tax_schedule['amt'] = np.round((tax_schedule['to'] - tax_schedule['from'] )* tax_schedule['rate'], 2)
def get_si_social(monthly_gross: float):
    medical = np.round(monthly_gross * 0.0636, 2)
    pension = np.round(monthly_gross * 0.155, 2)
    work = np.round(monthly_gross * 0.0014, 2)
    parental = np.round(monthly_gross * 0.001, 2)
    return medical + pension + work + parental
# tax_social = 0.221
employer_obligatory = 150 # monthly supplment for food around 150€ or 7.96€ per work day in a month
def get_si_net(monthly_gross: float, residency_discount: float = 0):
    monthly_social_tax = get_si_social(monthly_gross)
    employer_social_tax = monthly_gross * 0.161
    monthly_base_salary = monthly_gross - monthly_social_tax - residency_discount
    tmp = 0
    x = 0
    for _, row in tax_schedule.iterrows():
        if monthly_base_salary < row['from']:
            continue
        if monthly_base_salary >= row['to']:
            x = (row['to'] - row['from']) * row['rate']
        else:
            x = (monthly_base_salary - row['from']) * row['rate']
        tmp += np.round(x, 2)
        # print('x: %.2f, tmp: %.2f' % (x, tmp))
    return monthly_gross - monthly_social_tax - tmp + employer_obligatory, tmp, monthly_social_tax,employer_social_tax, monthly_base_salary
monthly_gross = 5000 # your monthly gross
allowance_general =  0 # 5000 # uncomment it to check what will you get if become tax resident
allowance_dependant =  0 # 2698 # + uncomment if to check if you got a dependant family member residing together with you at slovenia
allowance_total_monthly = (allowance_general + allowance_dependant)/12
monthly_net, monthly_salary_tax, monthly_social_tax, employer_social_tax, monthly_base_salary = get_si_net(monthly_gross, allowance_total_monthly)
print(tax_schedule)
print('Brutto: €%.2f' % monthly_gross)
print('Social: €%.2f (%.2f%%)' % (monthly_social_tax, monthly_social_tax/monthly_gross * 100))
print('Social (Employer): €%.2f' % employer_social_tax)
print('Allowance:')
print('\tGeneral:\t€%.2f (monthly: %.2f)' % (allowance_general, allowance_general/12))
print('\tDependent:\t€%.2f (monthly: %.2f)'  % (allowance_dependant, allowance_dependant/12))
print('\tTotal monthly:\t€%.2f' % allowance_total_monthly)
print('PIT tax base: €%.2f (Brutto - Social - Allowance)' % (monthly_gross - monthly_social_tax - allowance_total_monthly))
print('PIT tax: €%.2f' % (monthly_salary_tax))
print('='*10)
print('Gross: €%.2f' % monthly_gross)
print('NET: €%.2f' % monthly_net)
print('Employer TAX: € %.2f' % (employer_social_tax))
print('Employer TAX + Food: € %.2f' % (employer_social_tax + employer_obligatory))
print('Employer total for worker: € %.2f' % (monthly_gross + employer_social_tax + employer_obligatory))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment