Odoo online Version 18, does not yet serve the State of Utah locality. Can anyone verify this Python code is correct?
# Utah State Income Tax Withholding Calculation
# Get basic parameters
gross_income = categories.GROSS
pay_periods = payslip.dict.get('pay_periods', 24) # Default to semi-monthly if not specified
allowances = contract.ut_allowances if hasattr(contract, 'ut_allowances') else 0
filing_status = contract.ut_filing_status if hasattr(contract, 'ut_filing_status') else 'single'
# Calculate annual income estimate
annual_income = gross_income * pay_periods
# Personal exemption and deduction calculation
standard_deduction = 0
if filing_status == 'single' or filing_status == 'married_separate':
standard_deduction = 14600 # 2025 standard deduction for single filers
elif filing_status == 'married_joint' or filing_status == 'head_household':
standard_deduction = 29200 # 2025 standard deduction for married filing jointly
# Calculate taxable income
taxable_income = max(0, annual_income - standard_deduction - (allowances * 4590))
# Utah uses a flat tax rate of 4.65% (as of 2025)
annual_tax = taxable_income * 0.0465
# Convert annual tax to per-paycheck withholding
result = annual_tax / pay_periods
# Ensure the result is not negative
result = max(0, result)