Files
suite/l10n_us_hr_payroll/models/state/va_virginia.py
Jared Kipe 3ec63381b2 IMP l10n_us_hr_payroll Refactor to simply tax exempt deductions.
Additionally, it is possible (from testing on other databases) to have contracts without an employee, resulting in a failed migration.  Avoid this by filtering for employees on the contract and log if something (maybe a record rule) prevents you from seeing it instead of failing the migration itself.
2020-01-10 06:34:15 -08:00

44 lines
1.9 KiB
Python

# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
from .general import _state_applies
def va_virginia_state_income_withholding(payslip, categories, worked_days, inputs):
"""
Returns SIT eligible wage and rate.
WAGE = GROSS + DED_FIT_EXEMPT
:return: result, result_rate (wage, percent)
"""
state_code = 'VA'
if not _state_applies(payslip, state_code):
return 0.0, 0.0
if payslip.dict.contract_id.us_payroll_config_value('state_income_tax_exempt'):
return 0.0, 0.0
# Determine Wage
wage = categories.GROSS + categories.DED_FIT_EXEMPT
pay_periods = payslip.dict.get_pay_periods_in_year()
additional = payslip.dict.contract_id.us_payroll_config_value('state_income_tax_additional_withholding')
personal_exemptions = payslip.dict.contract_id.us_payroll_config_value('va_va4_sit_exemptions')
other_exemptions = payslip.dict.contract_id.us_payroll_config_value('va_va4_sit_other_exemptions')
personal_exemption_rate = payslip.dict.rule_parameter('us_va_sit_exemption_rate')
other_exemption_rate = payslip.dict.rule_parameter('us_va_sit_other_exemption_rate')
deduction = payslip.dict.rule_parameter('us_va_sit_deduction')
withholding_rate = payslip.dict.rule_parameter('us_va_sit_rate')
if wage == 0.0:
return 0.0, 0.0
taxable_wage = (wage * pay_periods) - (deduction + (personal_exemptions * personal_exemption_rate) + (other_exemptions * other_exemption_rate))
withholding = 0.0
if taxable_wage > 0.0:
for row in withholding_rate:
if taxable_wage > row[0]:
selected_row = row
wage_min, base, rate = selected_row
withholding = base + ((taxable_wage - wage_min) * rate / 100.0)
withholding /= pay_periods
withholding += additional
return wage, -((withholding / wage) * 100.0)