mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
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.
This commit is contained in:
@@ -20,4 +20,29 @@
|
||||
<field name="parent_id" ref="hr_payroll.DED"/>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Tax Exempt Deductions -->
|
||||
|
||||
<!-- Deductions that reduce the wage for Federal Income Tax (e.g. 401k) -->
|
||||
<record id="hr_payroll_category_ded_fit_exempt" model="hr.salary.rule.category">
|
||||
<field name="name">Deduction: Federal Income Tax Exempt</field>
|
||||
<field name="code">DED_US_FIT_EXEMPT</field>
|
||||
|
||||
</record>
|
||||
|
||||
<!-- Generally speaking, deductions to FICA and FUTA should probably reduce GROSS itself, there may be special or rare cases -->
|
||||
<!-- Deductions that reduce the wage for FICA -->
|
||||
<record id="hr_payroll_category_ded_fica_exempt" model="hr.salary.rule.category">
|
||||
<field name="name">Deduction: FICA Exempt</field>
|
||||
<field name="code">DED_FICA_EXEMPT</field>
|
||||
<field name="parent_id" ref="hr_payroll.DED"/>
|
||||
</record>
|
||||
|
||||
<!-- Deductions that reduce the wage for Unemployment Insurance/Tax -->
|
||||
<record id="hr_payroll_category_ded_futa_exempt" model="hr.salary.rule.category">
|
||||
<field name="name">Deduction: FUTA Exempt</field>
|
||||
<field name="code">DED_FUTA_EXEMPT</field>
|
||||
<field name="parent_id" ref="hr_payroll.DED"/>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -17,12 +17,6 @@
|
||||
<field name="parent_id" ref="hr_payroll.COMP"/>
|
||||
</record>
|
||||
|
||||
<!-- Category to increase when reducing wage for Unemployment Insurance/Tax -->
|
||||
<record id="hr_payroll_category_wage_fed_940_futa_exempt" model="hr.salary.rule.category">
|
||||
<field name="name">WAGE: Federal 940 FUTA Exempt</field>
|
||||
<field name="code">WAGE_US_940_FUTA_EXEMPT</field>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_rule_er_fed_940" model="hr.salary.rule">
|
||||
<field name="sequence" eval="440"/>
|
||||
<field name="category_id" ref="hr_payroll_category_er_fed_940"/>
|
||||
|
||||
@@ -23,12 +23,6 @@
|
||||
<field name="parent_id" ref="hr_payroll.COMP"/>
|
||||
</record>
|
||||
|
||||
<!-- Category to increase when reducing wage for FICA -->
|
||||
<record id="hr_payroll_category_wage_fed_941_fica_exempt" model="hr.salary.rule.category">
|
||||
<field name="name">WAGE: Federal 941 FICA Exempt</field>
|
||||
<field name="code">WAGE_US_941_FICA_EXEMPT</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Social Security -->
|
||||
<record id="hr_payroll_rule_ee_fed_941_ss" model="hr.salary.rule">
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<!-- Category to increase when reducing wage for Federal Income Tax (e.g. 401k) -->
|
||||
<record id="hr_payroll_category_wage_fed_941_fit_exempt" model="hr.salary.rule.category">
|
||||
<field name="name">WAGE: Federal 941 Income Tax Exempt</field>
|
||||
<field name="code">WAGE_US_941_FIT_EXEMPT</field>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_category_ee_fed_941_fit" model="hr.salary.rule.category">
|
||||
<field name="name">EE: Federal 941 Income Tax Withholding</field>
|
||||
|
||||
@@ -41,6 +41,7 @@ def migrate(cr, installed_version):
|
||||
|
||||
# We will assume all contracts without a struct (because we deleted it), or with one like US_xx_EMP, need config
|
||||
contracts = env['hr.contract'].search([
|
||||
('employee_id', '!=', False),
|
||||
'|',
|
||||
('struct_id', '=', False),
|
||||
('struct_id.code', '=like', 'US_%'),
|
||||
@@ -48,6 +49,9 @@ def migrate(cr, installed_version):
|
||||
_logger.warn('Migrating Contracts: ' + str(contracts))
|
||||
for contract in contracts:
|
||||
_logger.warn('Migrating contract: ' + str(contract) + ' for employee: ' + str(contract.employee_id))
|
||||
if not contract.employee_id.id:
|
||||
_logger.warn(' unable to migrate for missing employee id')
|
||||
continue
|
||||
# Could we somehow detect the state off of the current/orphaned salary structure?
|
||||
state_code = False
|
||||
old_struct_code = contract.struct_id.code
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
def er_us_940_futa(payslip, categories, worked_days, inputs):
|
||||
"""
|
||||
Returns FUTA eligible wage and rate.
|
||||
WAGE = GROSS - WAGE_US_940_FUTA_EXEMPT
|
||||
WAGE = GROSS + DED_FUTA_EXEMPT
|
||||
:return: result, result_rate (wage, percent)
|
||||
"""
|
||||
|
||||
@@ -19,13 +19,13 @@ def er_us_940_futa(payslip, categories, worked_days, inputs):
|
||||
# Determine Wage
|
||||
year = payslip.dict.get_year()
|
||||
ytd_wage = payslip.sum_category('GROSS', str(year) + '-01-01', str(year+1) + '-01-01')
|
||||
ytd_wage -= payslip.sum_category('WAGE_US_940_FUTA_EXEMPT', str(year) + '-01-01', str(year+1) + '-01-01')
|
||||
ytd_wage += payslip.sum_category('DED_FUTA_EXEMPT', str(year) + '-01-01', str(year+1) + '-01-01')
|
||||
ytd_wage += payslip.dict.contract_id.external_wages
|
||||
|
||||
wage_base = payslip.dict.rule_parameter('fed_940_futa_wage_base')
|
||||
remaining = wage_base - ytd_wage
|
||||
|
||||
wage = categories.GROSS - categories.WAGE_US_940_FUTA_EXEMPT
|
||||
wage = categories.GROSS + categories.DED_FUTA_EXEMPT
|
||||
|
||||
if remaining < 0.0:
|
||||
result = 0.0
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
def ee_us_941_fica_ss(payslip, categories, worked_days, inputs):
|
||||
"""
|
||||
Returns FICA Social Security eligible wage and rate.
|
||||
WAGE = GROSS - WAGE_US_941_FICA_EXEMPT
|
||||
WAGE = GROSS + DED_FICA_EXEMPT
|
||||
:return: result, result_rate (wage, percent)
|
||||
"""
|
||||
exempt = payslip.dict.contract_id.us_payroll_config_value('fed_941_fica_exempt')
|
||||
@@ -20,13 +20,13 @@ def ee_us_941_fica_ss(payslip, categories, worked_days, inputs):
|
||||
# Determine Wage
|
||||
year = payslip.dict.get_year()
|
||||
ytd_wage = payslip.sum_category('GROSS', str(year) + '-01-01', str(year+1) + '-01-01')
|
||||
ytd_wage -= payslip.sum_category('WAGE_US_941_FICA_EXEMPT', str(year) + '-01-01', str(year+1) + '-01-01')
|
||||
ytd_wage += payslip.sum_category('DED_FICA_EXEMPT', str(year) + '-01-01', str(year+1) + '-01-01')
|
||||
ytd_wage += payslip.dict.contract_id.external_wages
|
||||
|
||||
wage_base = payslip.dict.rule_parameter('fed_941_fica_ss_wage_base')
|
||||
remaining = wage_base - ytd_wage
|
||||
|
||||
wage = categories.GROSS - categories.WAGE_US_941_FICA_EXEMPT
|
||||
wage = categories.GROSS + categories.DED_FICA_EXEMPT
|
||||
|
||||
if remaining < 0.0:
|
||||
result = 0.0
|
||||
@@ -44,7 +44,7 @@ er_us_941_fica_ss = ee_us_941_fica_ss
|
||||
def ee_us_941_fica_m(payslip, categories, worked_days, inputs):
|
||||
"""
|
||||
Returns FICA Medicare eligible wage and rate.
|
||||
WAGE = GROSS - WAGE_US_941_FICA_EXEMPT
|
||||
WAGE = GROSS + DED_FICA_EXEMPT
|
||||
:return: result, result_rate (wage, percent)
|
||||
"""
|
||||
exempt = payslip.dict.contract_id.us_payroll_config_value('fed_941_fica_exempt')
|
||||
@@ -57,13 +57,13 @@ def ee_us_941_fica_m(payslip, categories, worked_days, inputs):
|
||||
# Determine Wage
|
||||
year = payslip.dict.get_year()
|
||||
ytd_wage = payslip.sum_category('GROSS', str(year) + '-01-01', str(year+1) + '-01-01')
|
||||
ytd_wage -= payslip.sum_category('WAGE_US_941_FICA_EXEMPT', str(year) + '-01-01', str(year+1) + '-01-01')
|
||||
ytd_wage += payslip.sum_category('DED_FICA_EXEMPT', str(year) + '-01-01', str(year+1) + '-01-01')
|
||||
ytd_wage += payslip.dict.contract_id.external_wages
|
||||
|
||||
wage_base = float(payslip.dict.rule_parameter('fed_941_fica_m_wage_base')) # inf
|
||||
remaining = wage_base - ytd_wage
|
||||
|
||||
wage = categories.GROSS - categories.WAGE_US_941_FICA_EXEMPT
|
||||
wage = categories.GROSS + categories.DED_FICA_EXEMPT
|
||||
|
||||
if remaining < 0.0:
|
||||
result = 0.0
|
||||
@@ -95,13 +95,13 @@ def ee_us_941_fica_m_add(payslip, categories, worked_days, inputs):
|
||||
# Determine Wage
|
||||
year = payslip.dict.get_year()
|
||||
ytd_wage = payslip.sum_category('GROSS', str(year) + '-01-01', str(year+1) + '-01-01')
|
||||
ytd_wage -= payslip.sum_category('WAGE_US_941_FICA_EXEMPT', str(year) + '-01-01', str(year+1) + '-01-01')
|
||||
ytd_wage += payslip.sum_category('DED_FICA_EXEMPT', str(year) + '-01-01', str(year+1) + '-01-01')
|
||||
ytd_wage += payslip.dict.contract_id.external_wages
|
||||
|
||||
wage_start = payslip.dict.rule_parameter('fed_941_fica_m_add_wage_start')
|
||||
existing_wage = ytd_wage - wage_start
|
||||
|
||||
wage = categories.GROSS - categories.WAGE_US_941_FICA_EXEMPT
|
||||
wage = categories.GROSS + categories.DED_FICA_EXEMPT
|
||||
|
||||
if existing_wage >= 0.0:
|
||||
result = wage
|
||||
@@ -117,7 +117,7 @@ def ee_us_941_fica_m_add(payslip, categories, worked_days, inputs):
|
||||
def ee_us_941_fit(payslip, categories, worked_days, inputs):
|
||||
"""
|
||||
Returns Wage and rate that is computed given the amount to withhold.
|
||||
WAGE = GROSS - WAGE_US_941_FIT_EXEMPT
|
||||
WAGE = GROSS + DED_FIT_EXEMPT
|
||||
:return: result, result_rate (wage, percent)
|
||||
"""
|
||||
filing_status = payslip.dict.contract_id.us_payroll_config_value('fed_941_fit_w4_filing_status')
|
||||
@@ -125,7 +125,7 @@ def ee_us_941_fit(payslip, categories, worked_days, inputs):
|
||||
return 0.0, 0.0
|
||||
|
||||
schedule_pay = payslip.dict.contract_id.schedule_pay
|
||||
wage = categories.GROSS - categories.WAGE_US_941_FIT_EXEMPT
|
||||
wage = categories.GROSS + categories.DED_FIT_EXEMPT
|
||||
#_logger.warn('initial gross wage: ' + str(wage))
|
||||
year = payslip.dict.get_year()
|
||||
if year >= 2020:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from odoo import api, fields, models
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.tools.safe_eval import safe_eval
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from .general import _state_applies
|
||||
def ga_georgia_state_income_withholding(payslip, categories, worked_days, inputs):
|
||||
"""
|
||||
Returns SIT eligible wage and rate.
|
||||
WAGE = GROSS - WAGE_US_941_FIT_EXEMPT
|
||||
WAGE = GROSS + DED_FIT_EXEMPT
|
||||
|
||||
:return: result, result_rate (wage, percent)
|
||||
"""
|
||||
@@ -18,7 +18,7 @@ def ga_georgia_state_income_withholding(payslip, categories, worked_days, inputs
|
||||
return 0.0, 0.0
|
||||
|
||||
# Determine Wage
|
||||
wage = categories.GROSS - categories.WAGE_US_941_FIT_EXEMPT
|
||||
wage = categories.GROSS + categories.DED_FIT_EXEMPT
|
||||
schedule_pay = payslip.dict.contract_id.schedule_pay
|
||||
additional = payslip.dict.contract_id.us_payroll_config_value('state_income_tax_additional_withholding')
|
||||
dependent_allowances = payslip.dict.contract_id.us_payroll_config_value('ga_g4_sit_dependent_allowances')
|
||||
|
||||
@@ -74,7 +74,7 @@ def _general_rate(payslip, wage, ytd_wage, wage_base=None, wage_start=None, rate
|
||||
def general_state_unemployment(payslip, categories, worked_days, inputs, wage_base=None, wage_start=None, rate=None, state_code=None):
|
||||
"""
|
||||
Returns SUTA eligible wage and rate.
|
||||
WAGE = GROSS - WAGE_US_940_FUTA_EXEMPT
|
||||
WAGE = GROSS + DED_FUTA_EXEMPT
|
||||
|
||||
The contract's `futa_type` determines if SUTA should be collected.
|
||||
|
||||
@@ -91,17 +91,17 @@ def general_state_unemployment(payslip, categories, worked_days, inputs, wage_ba
|
||||
# Determine Wage
|
||||
year = payslip.dict.get_year()
|
||||
ytd_wage = payslip.sum_category('GROSS', str(year) + '-01-01', str(year + 1) + '-01-01')
|
||||
ytd_wage -= payslip.sum_category('WAGE_US_940_FUTA_EXEMPT', str(year) + '-01-01', str(year + 1) + '-01-01')
|
||||
ytd_wage += payslip.sum_category('DED_FUTA_EXEMPT', str(year) + '-01-01', str(year + 1) + '-01-01')
|
||||
ytd_wage += payslip.dict.contract_id.external_wages
|
||||
|
||||
wage = categories.GROSS - categories.WAGE_US_940_FUTA_EXEMPT
|
||||
wage = categories.GROSS + categories.DED_FUTA_EXEMPT
|
||||
return _general_rate(payslip, wage, ytd_wage, wage_base=wage_base, wage_start=wage_start, rate=rate)
|
||||
|
||||
|
||||
def general_state_income_withholding(payslip, categories, worked_days, inputs, wage_base=None, wage_start=None, rate=None, state_code=None):
|
||||
"""
|
||||
Returns SIT eligible wage and rate.
|
||||
WAGE = GROSS - WAGE_US_941_FIT_EXEMPT
|
||||
WAGE = GROSS + DED_FIT_EXEMPT
|
||||
|
||||
:return: result, result_rate (wage, percent)
|
||||
"""
|
||||
@@ -114,10 +114,10 @@ def general_state_income_withholding(payslip, categories, worked_days, inputs, w
|
||||
# Determine Wage
|
||||
year = payslip.dict.get_year()
|
||||
ytd_wage = payslip.sum_category('GROSS', str(year) + '-01-01', str(year + 1) + '-01-01')
|
||||
ytd_wage -= payslip.sum_category('WAGE_US_941_FIT_EXEMPT', str(year) + '-01-01', str(year + 1) + '-01-01')
|
||||
ytd_wage += payslip.sum_category('DED_FIT_EXEMPT', str(year) + '-01-01', str(year + 1) + '-01-01')
|
||||
ytd_wage += payslip.dict.contract_id.external_wages
|
||||
|
||||
wage = categories.GROSS - categories.WAGE_US_941_FIT_EXEMPT
|
||||
wage = categories.GROSS + categories.DED_FIT_EXEMPT
|
||||
result, result_rate = _general_rate(payslip, wage, ytd_wage, wage_base=wage_base, wage_start=wage_start, rate=rate)
|
||||
additional = payslip.dict.contract_id.us_payroll_config_value('state_income_tax_additional_withholding')
|
||||
if additional:
|
||||
|
||||
@@ -6,7 +6,7 @@ from .general import _state_applies
|
||||
def ms_mississippi_state_income_withholding(payslip, categories, worked_days, inputs):
|
||||
"""
|
||||
Returns SIT eligible wage and rate.
|
||||
WAGE = GROSS - WAGE_US_941_FIT_EXEMPT
|
||||
WAGE = GROSS + DED_FIT_EXEMPT
|
||||
|
||||
:return: result, result_rate (wage, percent)
|
||||
"""
|
||||
@@ -19,7 +19,7 @@ def ms_mississippi_state_income_withholding(payslip, categories, worked_days, in
|
||||
return 0.0, 0.0
|
||||
|
||||
# Determine Wage
|
||||
wage = categories.GROSS - categories.WAGE_US_941_FIT_EXEMPT
|
||||
wage = categories.GROSS + categories.DED_FIT_EXEMPT
|
||||
if wage == 0.0:
|
||||
return 0.0, 0.0
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from .general import _state_applies
|
||||
def mt_montana_state_income_withholding(payslip, categories, worked_days, inputs):
|
||||
"""
|
||||
Returns SIT eligible wage and rate.
|
||||
WAGE = GROSS - WAGE_US_941_FIT_EXEMPT
|
||||
WAGE = GROSS + DED_FIT_EXEMPT
|
||||
|
||||
:return: result, result_rate (wage, percent)
|
||||
"""
|
||||
@@ -18,7 +18,7 @@ def mt_montana_state_income_withholding(payslip, categories, worked_days, inputs
|
||||
return 0.0, 0.0
|
||||
|
||||
# Determine Wage
|
||||
wage = categories.GROSS - categories.WAGE_US_941_FIT_EXEMPT
|
||||
wage = categories.GROSS + categories.DED_FIT_EXEMPT
|
||||
schedule_pay = payslip.dict.contract_id.schedule_pay
|
||||
additional = payslip.dict.contract_id.us_payroll_config_value('state_income_tax_additional_withholding')
|
||||
exemptions = payslip.dict.contract_id.us_payroll_config_value('mt_mw4_sit_exemptions')
|
||||
|
||||
@@ -6,7 +6,7 @@ from .general import _state_applies
|
||||
def oh_ohio_state_income_withholding(payslip, categories, worked_days, inputs):
|
||||
"""
|
||||
Returns SIT eligible wage and rate.
|
||||
WAGE = GROSS - WAGE_US_941_FIT_EXEMPT
|
||||
WAGE = GROSS + DED_FIT_EXEMPT
|
||||
|
||||
:return: result, result_rate (wage, percent)
|
||||
"""
|
||||
@@ -18,7 +18,7 @@ def oh_ohio_state_income_withholding(payslip, categories, worked_days, inputs):
|
||||
return 0.0, 0.0
|
||||
|
||||
# Determine Wage
|
||||
wage = categories.GROSS - categories.WAGE_US_941_FIT_EXEMPT
|
||||
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')
|
||||
exemptions = payslip.dict.contract_id.us_payroll_config_value('oh_it4_sit_exemptions')
|
||||
|
||||
@@ -6,7 +6,7 @@ from .general import _state_applies
|
||||
def va_virginia_state_income_withholding(payslip, categories, worked_days, inputs):
|
||||
"""
|
||||
Returns SIT eligible wage and rate.
|
||||
WAGE = GROSS - WAGE_US_941_FIT_EXEMPT
|
||||
WAGE = GROSS + DED_FIT_EXEMPT
|
||||
|
||||
:return: result, result_rate (wage, percent)
|
||||
"""
|
||||
@@ -18,7 +18,7 @@ def va_virginia_state_income_withholding(payslip, categories, worked_days, input
|
||||
return 0.0, 0.0
|
||||
|
||||
# Determine Wage
|
||||
wage = categories.GROSS - categories.WAGE_US_941_FIT_EXEMPT
|
||||
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')
|
||||
|
||||
Reference in New Issue
Block a user