i want you to finsih this code with no elisions import tkinter as tk from tkinter import…
- User
i want you to finsih this code with no elisions import tkinter as tk from tkinter import ttk
Constants and Data Structures
2024 Tax Brackets for different filing statuses
TAX_BRACKETS_2024 = { "Single": [ (0, 10275, 0.10), (10276, 41775, 0.12), (41776, 89075, 0.22), (89076, 170050, 0.24), (170051, 215950, 0.32), (215951, 539900, 0.35), (539901, float('inf'), 0.37) ], "Married Filing Jointly": [ (0, 20550, 0.10), (20551, 83550, 0.12), (83551, 178150, 0.22), (178151, 340100, 0.24), (340101, 431900, 0.32), (431901, 647850, 0.35), (647851, float('inf'), 0.37) ], "Head of Household": [ (0, 14650, 0.10), (14651, 55900, 0.12), (55901, 89050, 0.22), (89051, 170050, 0.24), (170051, 215950, 0.32), (215951, 539900, 0.35), (539901, float('inf'), 0.37) ] # Add more filing statuses and their tax brackets as needed }
STATE_TAX_RATES = { "CA": 0.093, # California "MA": 0.05, # Massachusetts "NY": 0.065, # New York "TX": 0.00, # Texas (No state income tax) "FL": 0.00, # Florida (No state income tax) # Add more states here }
Calculation Functions
def calculate_federal_tax(income, filing_status): """Calculates the federal tax owed based on income and filing status.""" tax_owed = 0 brackets = TAX_BRACKETS_2024.get(filing_status) if not brackets: raise ValueError(f"Invalid filing status: {filing_status}")
codefor lower, upper, rate in brackets: if income > lower: taxable_amount = min(income, upper) - lower tax_owed += taxable_amount * rate return tax_oweddef calculate_state_tax(state, biweekly_gross): """Calculates the state tax owed based on the provided state and biweekly gross income.""" return biweekly_gross * STATE_TAX_RATES.get(state, 0)
def calculate_fica_tax(biweekly_gross): """Calculates the FICA tax owed based on the provided biweekly gross income.""" return biweekly_gross * 0.0765
GUI Update and Calculation Logic
def calculate_pay(): """Calculates and updates the GUI with pay information based on user input.""" global hourly_rate_entry, state_var, filing_status_var
code - Assistantpython
5, column=0, columnspan=2, padx=10, pady=10) # Output Labels weekly_gross_label = ttk.Label(window, text="Weekly Gross: $0.00") weekly_gross_label.grid(row=6, column=0, columnspan=2, padx=10, pady=5) biweekly_gross_label = ttk.Label(window, text="Biweekly Gross: $0.00") biweekly_gross_label.grid(row=7, column=0, columnspan=2, padx=10, pady=5) weekly_tax_label = ttk.Label(window, text="Weekly Taxes: $0.00") weekly_tax_label.grid(row=8, column=0, columnspan=2, padx=10, pady=5) biweekly_tax_label = ttk.Label(window, text="Biweekly Taxes: $0.00") biweekly_tax_label.grid(row=9, column=0, columnspan=2, padx=10, pady=5) weekly_net_label = ttk.Label(window, text="Weekly Net: $0.00") weekly_net_label.grid(row=10, column=0, columnspan=2, padx=10, pady=5) biweekly_net_label = ttk.Label(window, text="Biweekly Net: $0.00") biweekly_net_label.grid(row=11, column=0, columnspan=2, padx=10, pady=5) # Start the GUI event loop window.mainloop()