Stanisalv commited on
Commit
d75b1ae
·
1 Parent(s): 0f22295

app ready

Browse files
Files changed (3) hide show
  1. app.py +63 -0
  2. app_logic.py +27 -0
  3. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from app_logic import estimate_net_salary
3
+
4
+ # Create the slider for salary input.
5
+ salary_slider = gr.Slider(minimum=80e3, maximum=200e3, label="Gross annual salary")
6
+
7
+ # Create switch inputs.
8
+ self_employed = gr.Checkbox(label="Self-employed")
9
+
10
+ # Create text to explain the taxes calculation
11
+ explanation = """
12
+ # Salary estimation factors
13
+
14
+ ### Taxes
15
+ - Income tax is 42%. A lump sum of 10600 is deducted after applying the tax rate, which accounts to a tax threshold in the calculation of individual taxes.
16
+ - VAT is 19%. It is only applied to self-employed people.
17
+ - Additional trade tax rate of 3% is to be paid after opening a business.
18
+ - Solidarity 1.6% tax rate. It's a German specific tax to help rebuild Germany after WWII.
19
+
20
+ ### Insurances
21
+ - Health insurance is 14.6% capped at 993 Euro a month, which would amount to 11916 a year.
22
+ - Retirement contribution is 18.6% capped at 1311 Euro a month, which would amount to 15735 a year.
23
+ - Unemployment insurance is 2.4% and capped at 170 Euro a month, 2030 a year.
24
+
25
+ ### Employment/Self-employment
26
+ - For self-employed people, the health insurance and retirement are to be paid in full.
27
+ - For employees the health insurance and retirement are split 50/50 between the employer and the employee.
28
+
29
+
30
+ ### Conclusion
31
+
32
+ - Some minor and complex tax deductions were not taken into account.
33
+ - **Based on the estimations above and my desire to earn around 4000 Euro a month, the projected self-employed salary would be around 160K Euro a year.**
34
+
35
+ ### How do I know the estimation is correct?
36
+
37
+ The estimation for the case of regular employment was tested against a German salary calculator and the results were very close. The calculator can be found [here](https://www.brutto-netto-rechner.info/gehalt/gross_net_calculator_germany.php). The data it was tested with is the following:
38
+
39
+ - Gross salary: 100000 Euro
40
+ - Age of the employee: 35
41
+ - Federal state: Berlin
42
+ - Tax category: 1
43
+ - Church tax: No
44
+ - Compulsory health, pension and care unemployment insurance: Yes
45
+ - Health insurance add on: 4 % (not included in the calculation in the app)
46
+
47
+ """
48
+
49
+ # Create output interfaces.
50
+ net_salary = gr.Textbox(label="Estimated net annual salary")
51
+
52
+ # Define the Gradio interface.
53
+ iface = gr.Interface(
54
+ fn=estimate_net_salary,
55
+ inputs=[salary_slider, self_employed],
56
+ outputs=[net_salary],
57
+ title="Salary Estimator",
58
+ description="Adjust the salary, choose if you are self-employed and see the estimated net salary.",
59
+ article=explanation
60
+ )
61
+
62
+ # Launch the app.
63
+ iface.launch()
app_logic.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Income taxes
2
+ INCOME_TAX = 0.42 # income tax rate for salaries above 66760 Euro/year
3
+ INCOME_THRESHOLD = 10600 # used in the calculation of the income tax
4
+ VAT = 0.19 # value-added tax rate for self-employed
5
+ ADD_SP_TAX = 0.03 # additional trade tax rate for self-employed
6
+ SOL_TAX = 0.05 # solidarity tax rate for self-employed
7
+
8
+ # Social security contributions
9
+ HEALTH_MAX = 993 # max health insurance contribution (capped at 84600 Euro/year)
10
+ RETIRE_MAX = 1311 # max retirement contribution (capped at 84600 Euro/year)
11
+ UNEMP_MAX= 170 # unemployment contribution rate
12
+
13
+
14
+ def estimate_net_salary(salary, self_employed=True):
15
+ if self_employed:
16
+ additional_income_tax_cash = salary * (VAT + ADD_SP_TAX)
17
+ sum_social_security = HEALTH_MAX * 12 + RETIRE_MAX * 12 + UNEMP_MAX * 12
18
+ income_tax_cash = (salary - sum_social_security) * INCOME_TAX - INCOME_THRESHOLD
19
+ sol_tax_cash = income_tax_cash * SOL_TAX
20
+ else:
21
+ additional_income_tax_cash = 0
22
+ sum_social_security = (HEALTH_MAX * 12 + RETIRE_MAX * 12 + UNEMP_MAX * 12) / 2 # half paid by the employer
23
+ income_tax_cash = (salary - sum_social_security) * INCOME_TAX - INCOME_THRESHOLD
24
+ sol_tax_cash = income_tax_cash * SOL_TAX
25
+
26
+ net_salary = salary - income_tax_cash - sol_tax_cash - additional_income_tax_cash - sum_social_security
27
+ return round(net_salary, 0)
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio==4.26.0