Skip to content

Commit 8931420

Browse files
committed
Greek Salary Calculator CLI
This commit introduces the Greek Salary Calculator CLI, a Python tool designed to calculate the net salary in Greece. Features included: - Calculation of employer and employee insurance contributions based on gross salary and the insurable earnings ceiling. - Calculation of income tax based on graduated tax brackets. - Application of tax credits based on the number of children. - Detailed output of gross and net monthly and annual salaries. - Command-line interface (CLI) implementation using the Click library. Project Structure: - ng_salary_calculator.py: Main script implementing the salary calculation logic and CLI. - requirements.txt: List of dependencies for the project. - README.md: Detailed description of the project, including instructions on how to run the application. - LICENSE: MIT License for the project. This project aims to provide an easy-to-use tool for individuals in Greece to understand their net salary after deductions.
1 parent 9ca9e17 commit 8931420

File tree

4 files changed

+194
-3
lines changed

4 files changed

+194
-3
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

README.md

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,104 @@
1-
# greek-salary-calculator-cli
2-
A Python CLI tool to calculate net salary in Greece. Includes employer and employee insurance contributions, income tax, and tax credits based on number of children. Get detailed monthly and annual breakdowns effortlessly!
1+
# 🇬🇷 Greek Salary Calculator CLI 🇬🇷
2+
3+
### Calculate your net salary in Greece for 2023 effortlessly!
4+
5+
![Salary Calculator](https://img.shields.io/badge/Salary%20Calculator-Python-blue.svg)
6+
![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)
7+
![Contributions Welcome](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)
8+
9+
---
10+
11+
## 🚀 Introduction
12+
13+
Welcome to the **Greek Salary Calculator CLI**! This Python CLI tool helps you calculate your net monthly and annual salary in Greece for the tax year 2023. It takes into account:
14+
- Employer and employee insurance contributions
15+
- Income tax
16+
- Tax credits based on the number of children
17+
18+
---
19+
20+
## 🛠️ Features
21+
22+
- **Employer Contributions**: Automatically calculated based on the gross salary.
23+
- **Employee Insurance Contributions**: Deducted before calculating the taxable income.
24+
- **Income Tax**: Applied on a graduated basis according to Greek tax law.
25+
- **Tax Credits**: Adjusted based on the number of children.
26+
27+
---
28+
29+
## 💻 How to Run
30+
31+
1. **Clone the repository**:
32+
```sh
33+
git clone https://github.com/peterdsp/greek-salary-calculator-cli.git
34+
```
35+
36+
2. **Navigate to the project directory**:
37+
```sh
38+
cd greek-salary-calculator-cli
39+
```
40+
41+
3. **Install the dependencies**:
42+
```sh
43+
pip install -r requirements.txt
44+
```
45+
46+
4. **Run the application**:
47+
```sh
48+
python ng_salary_calculator.py
49+
```
50+
51+
---
52+
53+
## 📋 Example
54+
55+
```sh
56+
$ python salary_calculator.py
57+
Gross Monthly Salary: 2000
58+
Number of Children: 2
59+
Insurance institution: Electronic National Social Security Institution (e-NSSI)
60+
Annual salaries: 14
61+
Gross monthly salary: €2000.00
62+
Gross annual salary: €28000.00
63+
Net monthly salary: €1457.29
64+
Net annual salary: €20401.08
65+
```
66+
67+
---
68+
69+
## 🧮 Explanation of the Calculation
70+
71+
1. **Gross Monthly Salary**: The starting salary provided by the user.
72+
2. **Annual Gross Salary**: Calculated as `gross_monthly_salary * 14` since there are 14 monthly payments in the year.
73+
3. **Employee's Insurance Contribution**: Calculated based on whether the gross salary exceeds the insurable earnings ceiling.
74+
4. **Annual Insurance Contribution**: The monthly insurance contribution multiplied by 14.
75+
5. **Annual Taxable Income**: The gross annual salary minus the annual insurance contribution.
76+
6. **Total Tax**: Calculated based on the taxable income using the given tax brackets and rates.
77+
7. **Tax Credit**: Based on the number of children and reduced by income above €12,000.
78+
8. **Final Tax**: The total tax reduced by the tax credit.
79+
9. **Net Annual Income**: The gross annual salary minus the insurance contributions and final tax.
80+
10. **Net Monthly Income**: The net annual income divided by 14.
81+
82+
---
83+
84+
## 🤝 Contributing
85+
86+
Contributions are welcome! Feel free to open an issue or submit a pull request.
87+
88+
---
89+
90+
## 📜 License
91+
92+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
93+
94+
---
95+
96+
## 🌟 Acknowledgements
97+
98+
Special thanks to the developers and contributors who have made this project possible.
99+
100+
---
101+
102+
## 📧 Contact
103+
104+
For any questions, please contact us at [info@peterdsp.dev](mailto:info@peterdsp.dev).

ng_salary_calculator.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import click
2+
3+
def calculate_net_salary(gross_monthly_salary, num_children):
4+
# Constants
5+
EMPLOYER_CONTRIBUTION_RATE = 0.2229
6+
EMPLOYEE_INSURANCE_CONTRIBUTION_RATE = 0.13867
7+
INSURABLE_EARNINGS_CEILING = 7126.94
8+
TAX_FREE_THRESHOLD = 8636
9+
10+
# Tax brackets and rates
11+
TAX_BRACKETS = [
12+
(10000, 0.09),
13+
(10000, 0.22),
14+
(10000, 0.28),
15+
(10000, 0.36),
16+
(float('inf'), 0.44)
17+
]
18+
19+
# Child tax credits
20+
CHILD_TAX_CREDITS = {
21+
0: 777,
22+
1: 810,
23+
2: 900,
24+
3: 1120,
25+
4: 1340
26+
}
27+
28+
# Calculate annual gross salary based on 14 months
29+
annual_gross_salary = gross_monthly_salary * 14
30+
31+
# Calculate employee's insurance contribution
32+
if gross_monthly_salary > INSURABLE_EARNINGS_CEILING:
33+
insurance_contribution_monthly = INSURABLE_EARNINGS_CEILING * EMPLOYEE_INSURANCE_CONTRIBUTION_RATE
34+
else:
35+
insurance_contribution_monthly = gross_monthly_salary * EMPLOYEE_INSURANCE_CONTRIBUTION_RATE
36+
37+
# Calculate annual insurance contribution
38+
annual_insurance_contribution = insurance_contribution_monthly * 14
39+
40+
# Calculate annual taxable income
41+
annual_taxable_income = annual_gross_salary - annual_insurance_contribution
42+
43+
# Calculate total tax based on taxable income and tax brackets
44+
remaining_income = annual_taxable_income
45+
total_tax = 0
46+
47+
for bracket, rate in TAX_BRACKETS:
48+
if remaining_income > bracket:
49+
total_tax += bracket * rate
50+
remaining_income -= bracket
51+
else:
52+
total_tax += remaining_income * rate
53+
break
54+
55+
# Calculate tax credit based on number of children
56+
if annual_taxable_income <= 12000:
57+
tax_credit = CHILD_TAX_CREDITS.get(num_children, 0)
58+
else:
59+
tax_credit_base = CHILD_TAX_CREDITS.get(num_children, 0)
60+
tax_credit_reduction = ((annual_taxable_income - 12000) // 1000) * 20
61+
tax_credit = max(0, tax_credit_base - tax_credit_reduction)
62+
63+
# Calculate final tax after applying tax credit
64+
final_tax = max(0, total_tax - tax_credit)
65+
66+
# Calculate net annual and monthly income
67+
net_annual_income = annual_gross_salary - annual_insurance_contribution - final_tax
68+
net_monthly_income = net_annual_income / 14
69+
70+
return net_monthly_income, net_annual_income, annual_gross_salary
71+
72+
@click.command()
73+
@click.option('--gross-monthly-salary', prompt='Gross Monthly Salary', type=float)
74+
@click.option('--num-children', prompt='Number of Children', type=int)
75+
def main(gross_monthly_salary, num_children):
76+
"""
77+
CLI command to calculate the net monthly and annual salary based on the provided gross monthly salary and number of children.
78+
"""
79+
net_monthly_salary, net_annual_salary, annual_gross_salary = calculate_net_salary(gross_monthly_salary, num_children)
80+
click.echo(f"Insurance institution: Electronic National Social Security Institution (e-NSSI)")
81+
click.echo(f"Annual salaries: 14")
82+
click.echo(f"Gross monthly salary: €{gross_monthly_salary:.2f}")
83+
click.echo(f"Gross annual salary: €{annual_gross_salary:.2f}")
84+
click.echo(f"Net monthly salary: €{net_monthly_salary:.2f}")
85+
click.echo(f"Net annual salary: €{net_annual_salary:.2f}")
86+
87+
if __name__ == '__main__':
88+
main()

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Click==8.0.3

0 commit comments

Comments
 (0)