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 Port l10n_us_al_hr_payroll AL Alabama including migration
This commit is contained in:
@@ -26,6 +26,7 @@ United States of America - Payroll Rules.
|
||||
'data/federal/fed_941_fit_parameters.xml',
|
||||
'data/federal/fed_941_fit_rules.xml',
|
||||
'data/state/ak_alaska.xml',
|
||||
'data/state/al_alabama.xml',
|
||||
'data/state/ar_arkansas.xml',
|
||||
'data/state/az_arizona.xml',
|
||||
'data/state/fl_florida.xml',
|
||||
|
||||
191
l10n_us_hr_payroll/data/state/al_alabama.xml
Normal file
191
l10n_us_hr_payroll/data/state/al_alabama.xml
Normal file
@@ -0,0 +1,191 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<!-- Wage Base -->
|
||||
<record id="rule_parameter_us_al_suta_wage_base" model="hr.rule.parameter">
|
||||
<field name="name">US AL Alabama SUTA Wage Base</field>
|
||||
<field name="code">us_al_suta_wage_base</field>
|
||||
<field name="country_id" ref="base.us"/>
|
||||
</record>
|
||||
<data noupdate="1">
|
||||
<record id="rule_parameter_us_al_suta_wage_base_2019" model="hr.rule.parameter.value">
|
||||
<field name="parameter_value">8000.0</field>
|
||||
<field name="rule_parameter_id" ref="rule_parameter_us_al_suta_wage_base"/>
|
||||
<field name="date_from" eval="datetime(2019, 1, 1).date()"/>
|
||||
</record>
|
||||
<record id="rule_parameter_us_al_suta_wage_base_2020" model="hr.rule.parameter.value">
|
||||
<field name="parameter_value">8000.0</field>
|
||||
<field name="rule_parameter_id" ref="rule_parameter_us_al_suta_wage_base"/>
|
||||
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
|
||||
</record>
|
||||
</data>
|
||||
|
||||
<!-- Rate -->
|
||||
<record id="rule_parameter_us_al_suta_rate" model="hr.rule.parameter">
|
||||
<field name="name">US AL Alabama SUTA Rate</field>
|
||||
<field name="code">us_al_suta_rate</field>
|
||||
<field name="country_id" ref="base.us"/>
|
||||
</record>
|
||||
<data noupdate="1">
|
||||
<record id="rule_parameter_us_al_suta_rate_2019" model="hr.rule.parameter.value">
|
||||
<field name="parameter_value">2.7</field>
|
||||
<field name="rule_parameter_id" ref="rule_parameter_us_al_suta_rate"/>
|
||||
<field name="date_from" eval="datetime(2019, 1, 1).date()"/>
|
||||
</record>
|
||||
<record id="rule_parameter_us_al_suta_rate_2020" model="hr.rule.parameter.value">
|
||||
<field name="parameter_value">2.7</field>
|
||||
<field name="rule_parameter_id" ref="rule_parameter_us_al_suta_rate"/>
|
||||
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
|
||||
</record>
|
||||
</data>
|
||||
|
||||
<record id="rule_parameter_us_al_sit_tax_rate" model="hr.rule.parameter">
|
||||
<field name="name">US AL Alabama SIT Tax Rate</field>
|
||||
<field name="code">us_al_sit_tax_rate</field>
|
||||
<field name="country_id" ref="base.us"/>
|
||||
</record>
|
||||
<data noupdate="1">
|
||||
<record id="rule_parameter_us_al_sit_tax_rate_2019" model="hr.rule.parameter.value">
|
||||
<field name="parameter_value">{
|
||||
'0': [(500, 2),( 3000, 4),('inf', 5)],
|
||||
'M': [( 1000, 2),( 6000, 4),('inf', 5)],
|
||||
}</field>
|
||||
<field name="rule_parameter_id" ref="rule_parameter_us_al_sit_tax_rate"/>
|
||||
<field name="date_from" eval="datetime(2019, 1, 1).date()"/>
|
||||
</record>
|
||||
<record id="rule_parameter_us_al_sit_tax_rate_2020" model="hr.rule.parameter.value">
|
||||
<field name="parameter_value">{
|
||||
'0' : [(500, 2),(2500, 4),('inf', 5)],
|
||||
'M': [(1000, 2),(5000, 4),('inf', 5)],
|
||||
}</field>
|
||||
<field name="rule_parameter_id" ref="rule_parameter_us_al_sit_tax_rate"/>
|
||||
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
|
||||
</record>
|
||||
</data>
|
||||
|
||||
<record id="rule_parameter_us_al_sit_dependent_rate" model="hr.rule.parameter">
|
||||
<field name="name">US AL Alabama Dependent Rate</field>
|
||||
<field name="code">us_al_sit_dependent_rate</field>
|
||||
<field name="country_id" ref="base.us"/>
|
||||
</record>
|
||||
<data noupdate="1">
|
||||
<record id="rule_parameter_us_al_sit_dependent_rate_2019" model="hr.rule.parameter.value">
|
||||
<field name="parameter_value">[
|
||||
( 1000, 20000),
|
||||
( 500, 100000),
|
||||
( 300, 'inf'),
|
||||
]</field>
|
||||
<field name="rule_parameter_id" ref="rule_parameter_us_al_sit_dependent_rate"/>
|
||||
<field name="date_from" eval="datetime(2019, 1, 1).date()"/>
|
||||
</record>
|
||||
<record id="rule_parameter_us_al_sit_dependent_rate_2020" model="hr.rule.parameter.value">
|
||||
<field name="parameter_value">[
|
||||
( 1000, 20000),
|
||||
( 500, 100000),
|
||||
( 300, 'inf'),
|
||||
]</field>
|
||||
<field name="rule_parameter_id" ref="rule_parameter_us_al_sit_dependent_rate"/>
|
||||
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
|
||||
</record>
|
||||
</data>
|
||||
|
||||
<record id="rule_parameter_us_al_sit_standard_deduction_rate" model="hr.rule.parameter">
|
||||
<field name="name">US AL Alabama Standard Deduction Rate</field>
|
||||
<field name="code">us_al_sit_standard_deduction_rate</field>
|
||||
<field name="country_id" ref="base.us"/>
|
||||
</record>
|
||||
<data noupdate="1">
|
||||
<record id="rule_parameter_us_al_sit_standard_deduction_rate_2019" model="hr.rule.parameter.value">
|
||||
<field name="parameter_value">{
|
||||
'0': ((23499.0, 2500.0), (33000.0, 2500.0, 25.0, 500.0), ('inf', 2000.0)),
|
||||
'S': ((23499.0, 2500.0), (33000.0, 2500.0, 25.0, 500.0), ('inf', 2000.0)),
|
||||
'MS': ((10749.0, 3750.0), (15500.0, 3750.0, 88.0, 250.0), ('inf', 2000.0)),
|
||||
'M': ((23499.0, 7500.0), (33000.0, 7500.0, 175.0, 500.0), ('inf', 4000.0)),
|
||||
'H': ((23499.0, 4700.0), (33000.0, 7500.0, 175.0, 500.0), ('inf', 4000.0)),
|
||||
}</field>
|
||||
<field name="rule_parameter_id" ref="rule_parameter_us_al_sit_standard_deduction_rate"/>
|
||||
<field name="date_from" eval="datetime(2019, 1, 1).date()"/>
|
||||
</record>
|
||||
<record id="rule_parameter_us_al_sit_standard_deduction_rate_2020" model="hr.rule.parameter.value">
|
||||
<field name="parameter_value">{
|
||||
'0': ((23499.0, 2500.0), (33000.0, 2500.0, 25.0, 500.0), ('inf', 2000.0)),
|
||||
'S': ((23499.0, 2500.0), (33000.0, 2500.0, 25.0, 500.0), ('inf', 2000.0)),
|
||||
'MS': ((10749.0, 3750.0), (15500.0, 3750.0, 88.0, 250.0), ('inf', 2000.0)),
|
||||
'M': ((23499.0, 7500.0), (33000.0, 7500.0, 175.0, 500.0), ('inf', 4000.0)),
|
||||
'H': ((23499.0, 4700.0), (33000.0, 7500.0, 175.0, 500.0), ('inf', 4000.0)),
|
||||
}</field>
|
||||
<field name="rule_parameter_id" ref="rule_parameter_us_al_sit_standard_deduction_rate"/>
|
||||
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
|
||||
</record>
|
||||
</data>
|
||||
|
||||
<record id="rule_parameter_us_al_sit_personal_exemption_rate" model="hr.rule.parameter">
|
||||
<field name="name">US AL Alabama Personal Exemption Rate</field>
|
||||
<field name="code">us_al_sit_personal_exemption_rate</field>
|
||||
<field name="country_id" ref="base.us"/>
|
||||
</record>
|
||||
<data noupdate="1">
|
||||
<record id="rule_parameter_us_al_sit_personal_exemption_rate_2019" model="hr.rule.parameter.value">
|
||||
<field name="parameter_value">{
|
||||
'0' : 0,
|
||||
'S' : 1500,
|
||||
'MS': 1500,
|
||||
'M' : 3000,
|
||||
'H' : 3000,
|
||||
}</field>
|
||||
<field name="rule_parameter_id" ref="rule_parameter_us_al_sit_personal_exemption_rate"/>
|
||||
<field name="date_from" eval="datetime(2019, 1, 1).date()"/>
|
||||
</record>
|
||||
<record id="rule_parameter_us_al_sit_personal_exemption_rate_2020" model="hr.rule.parameter.value">
|
||||
<field name="parameter_value">{
|
||||
'0' : 0,
|
||||
'S' : 1500,
|
||||
'MS': 1500,
|
||||
'M' : 3000,
|
||||
'H' : 3000,
|
||||
}</field>
|
||||
<field name="rule_parameter_id" ref="rule_parameter_us_al_sit_personal_exemption_rate"/>
|
||||
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
|
||||
</record>
|
||||
</data>
|
||||
|
||||
<!-- Partners and Contribution Registers -->
|
||||
<record id="res_partner_us_al_dor" model="res.partner">
|
||||
<field name="name">US Alabama - Department of Economic Security (IDES) - Unemployment Tax</field>
|
||||
</record>
|
||||
|
||||
<record id="res_partner_us_al_dor_sit" model="res.partner">
|
||||
<field name="name">US Alabama - Department of Revenue (IDOR) - Income Tax</field>
|
||||
</record>
|
||||
|
||||
<!-- Categories -->
|
||||
|
||||
<!-- Rules -->
|
||||
<record id="hr_payroll_rule_er_us_al_suta" model="hr.salary.rule">
|
||||
<field name="sequence" eval="450"/>
|
||||
<field name="struct_id" ref="hr_payroll_structure"/>
|
||||
<field name="category_id" ref="hr_payroll_category_er_us_suta"/>
|
||||
<field name="name">ER: US AL Alabama State Unemployment</field>
|
||||
<field name="code">ER_US_AL_SUTA</field>
|
||||
<field name="condition_select">python</field>
|
||||
<field name="condition_python">result, _ = general_state_unemployment(payslip, categories, worked_days, inputs, wage_base='us_al_suta_wage_base', rate='us_al_suta_rate', state_code='AL')</field>
|
||||
<field name="amount_select">code</field>
|
||||
<field name="amount_python_compute">result, result_rate = general_state_unemployment(payslip, categories, worked_days, inputs, wage_base='us_al_suta_wage_base', rate='us_al_suta_rate', state_code='AL')</field>
|
||||
<field name="partner_id" ref="res_partner_us_al_dor"/>
|
||||
<field name="appears_on_payslip" eval="False"/>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_rule_ee_us_al_sit" model="hr.salary.rule">
|
||||
<field name="sequence" eval="195"/>
|
||||
<field name="struct_id" ref="hr_payroll_structure"/>
|
||||
<field name="category_id" ref="hr_payroll_category_ee_us_sit"/>
|
||||
<field name="name">EE: US AL Alabama State Income Tax Withholding</field>
|
||||
<field name="code">EE_US_AL_SIT</field>
|
||||
<field name="condition_select">python</field>
|
||||
<field name="condition_python">result, _ = al_alabama_state_income_withholding(payslip, categories, worked_days, inputs)</field>
|
||||
<field name="amount_select">code</field>
|
||||
<field name="amount_python_compute">result, result_rate = al_alabama_state_income_withholding(payslip, categories, worked_days, inputs)</field>
|
||||
<field name="partner_id" ref="res_partner_us_al_dor_sit"/>
|
||||
<field name="appears_on_payslip" eval="True"/>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -12,6 +12,7 @@ from .federal.fed_941 import ee_us_941_fica_ss, \
|
||||
from .state.general import general_state_unemployment, \
|
||||
general_state_income_withholding, \
|
||||
is_us_state
|
||||
from .state.al_alabama import al_alabama_state_income_withholding
|
||||
from .state.ar_arkansas import ar_arkansas_state_income_withholding
|
||||
from .state.az_arizona import az_arizona_state_income_withholding
|
||||
from .state.ga_georgia import ga_georgia_state_income_withholding
|
||||
@@ -58,6 +59,7 @@ class HRPayslip(models.Model):
|
||||
'general_state_unemployment': general_state_unemployment,
|
||||
'general_state_income_withholding': general_state_income_withholding,
|
||||
'is_us_state': is_us_state,
|
||||
'al_alabama_state_income_withholding': al_alabama_state_income_withholding,
|
||||
'ar_arkansas_state_income_withholding': ar_arkansas_state_income_withholding,
|
||||
'az_arizona_state_income_withholding': az_arizona_state_income_withholding,
|
||||
'ga_georgia_state_income_withholding': ga_georgia_state_income_withholding,
|
||||
|
||||
77
l10n_us_hr_payroll/models/state/al_alabama.py
Normal file
77
l10n_us_hr_payroll/models/state/al_alabama.py
Normal file
@@ -0,0 +1,77 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
from .general import _state_applies, sit_wage
|
||||
|
||||
|
||||
def al_alabama_state_income_withholding(payslip, categories, worked_days, inputs):
|
||||
"""
|
||||
Returns SIT eligible wage and rate.
|
||||
|
||||
:return: result, result_rate (wage, percent)
|
||||
"""
|
||||
state_code = 'AL'
|
||||
if not _state_applies(payslip, state_code):
|
||||
return 0.0, 0.0
|
||||
|
||||
# Determine Wage
|
||||
wage = sit_wage(payslip, categories)
|
||||
if not wage:
|
||||
return 0.0, 0.0
|
||||
|
||||
personal_exempt = payslip.contract_id.us_payroll_config_value('state_income_tax_exempt')
|
||||
if personal_exempt:
|
||||
return 0.0, 0.0
|
||||
|
||||
pay_periods = payslip.dict.get_pay_periods_in_year()
|
||||
additional = payslip.contract_id.us_payroll_config_value('state_income_tax_additional_withholding')
|
||||
tax_table = payslip.rule_parameter('us_al_sit_tax_rate')
|
||||
exemptions = payslip.contract_id.us_payroll_config_value('al_a4_sit_exemptions')
|
||||
dependent_rate = payslip.rule_parameter('us_al_sit_dependent_rate')
|
||||
standard_deduction = payslip.rule_parameter('us_al_sit_standard_deduction_rate').get(exemptions, 0.0)
|
||||
personal_exemption = payslip.rule_parameter('us_al_sit_personal_exemption_rate').get(exemptions, 0.0)
|
||||
dependent = payslip.contract_id.us_payroll_config_value('al_a4_sit_dependents')
|
||||
fed_withholding = categories.EE_US_941_FIT
|
||||
|
||||
annual_wage = wage * pay_periods
|
||||
standard_deduction_amt = 0.0
|
||||
personal_exemption_amt = 0.0
|
||||
dependent_amt = 0.0
|
||||
withholding = 0.0
|
||||
|
||||
if standard_deduction:
|
||||
row = standard_deduction
|
||||
last_amt = 0.0
|
||||
for data in row:
|
||||
if annual_wage < float(data[0]):
|
||||
if len(data) > 3:
|
||||
increment_count = (- (wage - last_amt) // data[3])
|
||||
standard_deduction_amt = data[1] - (increment_count * data[2])
|
||||
else:
|
||||
standard_deduction_amt = data[1]
|
||||
else:
|
||||
last_amt = data[0]
|
||||
after_deduction = annual_wage - standard_deduction_amt
|
||||
after_fed_withholding = (fed_withholding * pay_periods) + after_deduction
|
||||
if not personal_exempt:
|
||||
personal_exemption_amt = personal_exemption
|
||||
after_personal_exemption = after_fed_withholding - personal_exemption_amt
|
||||
for row in dependent_rate:
|
||||
if annual_wage < float(row[1]):
|
||||
dependent_amt = row[0] * dependent
|
||||
break
|
||||
|
||||
taxable_amount = after_personal_exemption - dependent_amt
|
||||
last = 0.0
|
||||
tax_table = tax_table['M'] if exemptions == 'M' else tax_table['0']
|
||||
for row in tax_table:
|
||||
if taxable_amount < float(row[0]):
|
||||
withholding = withholding + ((taxable_amount - last) * (row[1] / 100))
|
||||
break
|
||||
withholding = withholding + ((row[0] - last) * (row[1] / 100))
|
||||
last = row[0]
|
||||
|
||||
if withholding < 0.0:
|
||||
withholding = 0.0
|
||||
withholding /= pay_periods
|
||||
withholding += additional
|
||||
return wage, -((withholding / wage) * 100.0)
|
||||
@@ -51,6 +51,15 @@ class HRContractUSPayrollConfig(models.Model):
|
||||
fed_941_fit_w4_additional_withholding = fields.Float(string='Federal W4 Additional Withholding [4(c)]',
|
||||
help='Form W4 (2020+) 4(c)')
|
||||
|
||||
al_a4_sit_exemptions = fields.Selection([
|
||||
('0', '0'),
|
||||
('S', 'S'),
|
||||
('MS', 'MS'),
|
||||
('M', 'M'),
|
||||
('H', 'H'),
|
||||
], string='Alabama A4 Withholding Exemptions', help='A4 1. 2. 3.')
|
||||
al_a4_sit_dependents = fields.Integer(string='Alabama A4 Dependents', help='A4 4.')
|
||||
|
||||
ar_ar4ec_sit_allowances = fields.Integer(string='Arkansas AR4EC allowances', help='AR4EC 3.')
|
||||
|
||||
az_a4_sit_withholding_percentage = fields.Float(
|
||||
|
||||
@@ -7,6 +7,9 @@ from . import test_us_payslip_2020
|
||||
from . import test_us_ak_alaska_payslip_2019
|
||||
from . import test_us_ak_alaska_payslip_2020
|
||||
|
||||
from . import test_us_al_alabama_payslip_2019
|
||||
from . import test_us_al_alabama_payslip_2020
|
||||
|
||||
from . import test_us_ar_arkansas_payslip_2019
|
||||
from . import test_us_ar_arkansas_payslip_2020
|
||||
|
||||
|
||||
264
l10n_us_hr_payroll/tests/test_us_al_alabama_payslip_2019.py
Normal file
264
l10n_us_hr_payroll/tests/test_us_al_alabama_payslip_2019.py
Normal file
@@ -0,0 +1,264 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
from .common import TestUsPayslip, process_payslip
|
||||
|
||||
|
||||
class TestUsALPayslip(TestUsPayslip):
|
||||
# TAXES AND RATES
|
||||
AL_UNEMP_MAX_WAGE = 8000.00
|
||||
AL_UNEMP = -2.70 / 100.0
|
||||
|
||||
def test_taxes_weekly(self):
|
||||
salary = 10000.00
|
||||
schedule_pay = 'weekly'
|
||||
dependents = 1
|
||||
filing_status = 'S'
|
||||
# see https://revenue.alabama.gov/wp-content/uploads/2019/01/whbooklet_0119.pdf for reference
|
||||
# Hand Calculated Amount to Test
|
||||
# Step 1 -> 10000.00 for wages per period , 52.0 for weekly -> 10000 * 52 -> 520000.0
|
||||
# Step 2A -> standard deduction for highest wage bracket -> 2000. Subtract from yearly income
|
||||
# 520000 - 2000 = 518000.0
|
||||
# Step 2B -> Subtract Federal Income Tax in yearly form -> Our Fed withholding is -2999.66 * 52 = -155982.32
|
||||
# -> 518000.0 - 155982.32 = 362017.68
|
||||
# Step 2C -> Subtract the personal exemption -> 1500 for single filing_status
|
||||
# -> 362017.68 - 1500 = 360517.68
|
||||
# Step 2D -> Since income is so high, only 300$ per dependent -> 300$. Subtract
|
||||
# -> 360517.68 - 300 = 360217.68
|
||||
#
|
||||
# Step 5 (after adding previous lines) -> Compute marginal taxes.
|
||||
# (500 * (2.00 / 100)) + (2500 * (4.00 / 100)) + ((360217.68 - 500 - 2500) * (5.00 / 100)) -> 17970.884000000002
|
||||
# Convert back to pay period
|
||||
# wh = round(17970.884000000002, 2) -> 17970.88 / 52.0 -> 345.59
|
||||
wh = -345.59
|
||||
|
||||
employee = self._createEmployee()
|
||||
contract = self._createContract(employee,
|
||||
wage=salary,
|
||||
state_id=self.get_us_state('AL'),
|
||||
al_a4_sit_exemptions=filing_status,
|
||||
state_income_tax_additional_withholding=0.0,
|
||||
state_income_tax_exempt=False,
|
||||
al_a4_sit_dependents=dependents,
|
||||
schedule_pay=schedule_pay)
|
||||
|
||||
self._log('2019 Alabama tax first payslip weekly:')
|
||||
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
|
||||
payslip.compute_sheet()
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
self.assertPayrollEqual(cats['EE_US_941_FIT'], -2999.66) # Hand Calculated.
|
||||
self.assertPayrollEqual(cats['ER_US_SUTA'], self.AL_UNEMP_MAX_WAGE * self.AL_UNEMP)
|
||||
self.assertPayrollEqual(cats['EE_US_SIT'], wh)
|
||||
|
||||
process_payslip(payslip)
|
||||
|
||||
remaining_AL_UNEMP_wages = 0.00 # We already reached the maximum wage for unemployment insurance.
|
||||
|
||||
self._log('2019 Alabama tax second payslip weekly:')
|
||||
payslip = self._createPayslip(employee, '2019-02-01', '2019-02-28')
|
||||
payslip.compute_sheet()
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
self.assertPayrollEqual(cats['ER_US_SUTA'], remaining_AL_UNEMP_wages * self.AL_UNEMP) # 0
|
||||
|
||||
def test_taxes_married_jointly(self):
|
||||
salary = 10000.00
|
||||
schedule_pay = 'weekly'
|
||||
dependents = 1
|
||||
filing_status = 'M'
|
||||
|
||||
# see https://revenue.alabama.gov/wp-content/uploads/2019/01/whbooklet_0119.pdf for reference
|
||||
# Hand Calculated Amount to Test
|
||||
# Step 1 -> 10000.00 for wages per period , 52.0 for weekly -> 10000 * 52 -> 520000.0
|
||||
# Step 2A -> standard deduction for highest wage bracket -> 4000. Subtract from yearly income
|
||||
# 520000 - 4000 = 516000.0
|
||||
# Step 2B -> Subtract Federal Income Tax in yearly form -> Our Fed withholding is -2999.66 * 52 = -155982.32
|
||||
# -> 516000.0 - 155982.32 = 360017.68
|
||||
# Step 2C -> Subtract the personal exemption -> 3000 for married filing jointly.
|
||||
# -> 360017.68 - 3000 = 357017.68
|
||||
# Step 2D -> Since income is so high, only 300$ per dependent -> 300$. Subtract
|
||||
# -> 357017.68 - 300 = 356717.68
|
||||
#
|
||||
# Step 5 (after adding previous lines) -> Compute marginal taxes.
|
||||
# (1000 * (2.00 / 100)) + (5000 * (4.00 / 100)) + ((356717.68 - 1000 - 50000) * (5.00 / 100))
|
||||
# -> 17755.884000000002
|
||||
# Convert back to pay period
|
||||
# wh = round(17755.884000000002, 2) -> 15505.88 / 52.0 -> 341.45923076923077
|
||||
wh = -341.46
|
||||
|
||||
employee = self._createEmployee()
|
||||
contract = self._createContract(employee,
|
||||
wage=salary,
|
||||
state_id=self.get_us_state('AL'),
|
||||
al_a4_sit_exemptions=filing_status,
|
||||
state_income_tax_additional_withholding=0.0,
|
||||
state_income_tax_exempt=False,
|
||||
al_a4_sit_dependents=dependents,
|
||||
schedule_pay=schedule_pay)
|
||||
|
||||
self._log('2019 Alabama tax first payslip weekly:')
|
||||
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
|
||||
payslip.compute_sheet()
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
self.assertPayrollEqual(cats['EE_US_941_FIT'], -2999.66) # Hand Calculated.
|
||||
self.assertPayrollEqual(cats['ER_US_SUTA'], self.AL_UNEMP_MAX_WAGE * self.AL_UNEMP)
|
||||
self.assertPayrollEqual(cats['EE_US_SIT'], wh)
|
||||
|
||||
process_payslip(payslip)
|
||||
|
||||
|
||||
def test_taxes_semimonthly_filing_seperate(self):
|
||||
salary = 20000.00
|
||||
schedule_pay = 'monthly'
|
||||
filing_status = 'MS'
|
||||
dependents = 2
|
||||
|
||||
# see https://revenue.alabama.gov/wp-content/uploads/2019/01/whbooklet_0119.pdf for reference
|
||||
# Hand Calculated Amount to Test
|
||||
# Step 1 -> 10000.00 for wages per period , 12.0 for monthly -> 20000 * 12 -> 240000.00
|
||||
# Step 2A -> standard deduction for highest wage bracket -> 2000. Subtract from yearly income
|
||||
# 240000.00 - 2000 = 238000.00
|
||||
# Step 2B -> Subtract Federal Income Tax in yearly form -> Our Fed withholding is -4821.99 * 12 = -57863.88
|
||||
# -> 238000.00 - 57863.88 = 180136.12
|
||||
# Step 2C -> Subtract the personal exemption -> 1500 for married filing separately
|
||||
# -> 180136.12 - 1500 = 178636.12
|
||||
# Step 2D -> Since income is so high, only 300$ per dependent -> 600. Subtract
|
||||
# -> 178636.12 - 600 = 178036.12
|
||||
#
|
||||
# Step 5 (after adding previous lines) -> Compute marginal taxes.
|
||||
# (500 * (2.00 / 100)) + (2500 * (4.00 / 100)) + ((178036.12 - 500 - 2500) * (5.00 / 100)) -> 8861.806
|
||||
# Convert back to pay period
|
||||
# wh = 8861.806 / 12.0 rounded -> 738.48
|
||||
wh = -738.48
|
||||
|
||||
employee = self._createEmployee()
|
||||
contract = self._createContract(employee,
|
||||
wage=salary,
|
||||
state_id=self.get_us_state('AL'),
|
||||
al_a4_sit_exemptions=filing_status,
|
||||
state_income_tax_additional_withholding=0.0,
|
||||
state_income_tax_exempt=False,
|
||||
al_a4_sit_dependents=dependents,
|
||||
schedule_pay=schedule_pay)
|
||||
|
||||
self._log('2019 Alabama tax first payslip monthly:')
|
||||
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
|
||||
payslip.compute_sheet()
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
self.assertPayrollEqual(cats['EE_US_941_FIT'], -4822.00) # Hand Calculated.
|
||||
self.assertPayrollEqual(cats['ER_US_SUTA'], self.AL_UNEMP_MAX_WAGE * self.AL_UNEMP)
|
||||
self.assertPayrollEqual(cats['EE_US_SIT'], wh)
|
||||
|
||||
process_payslip(payslip)
|
||||
|
||||
def test_tax_exempt(self):
|
||||
salary = 5500.00
|
||||
wh = 0
|
||||
schedule_pay = 'weekly'
|
||||
dependents = 2
|
||||
|
||||
employee = self._createEmployee()
|
||||
contract = self._createContract(employee,
|
||||
wage=salary,
|
||||
state_id=self.get_us_state('AL'),
|
||||
al_a4_sit_exemptions='0',
|
||||
state_income_tax_additional_withholding=0.0,
|
||||
state_income_tax_exempt=True,
|
||||
al_a4_sit_dependents=dependents,
|
||||
schedule_pay=schedule_pay)
|
||||
|
||||
self._log('2019 Alabama tax first payslip exempt:')
|
||||
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
|
||||
payslip.compute_sheet()
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
self.assertPayrollEqual(cats['ER_US_SUTA'], salary * self.AL_UNEMP)
|
||||
self.assertPayrollEqual(cats.get('EE_US_SIT', 0.0), wh)
|
||||
|
||||
def test_additional_withholding(self):
|
||||
salary = 5500.0
|
||||
schedule_pay = 'weekly'
|
||||
additional_wh = 40.0
|
||||
dependents = 2
|
||||
# filing status default is single
|
||||
|
||||
# see https://revenue.alabama.gov/wp-content/uploads/2019/01/whbooklet_0119.pdf for reference
|
||||
# Hand Calculated Amount to Test
|
||||
# Step 1 -> 5500.00 for wages per period , 52.0 for monthly -> 5500 * 52.0 -> 286000.0
|
||||
# Step 2A -> standard deduction for highest wage bracket -> 2000. Subtract from yearly income
|
||||
# 286000.0 - 2000 = 284000.0
|
||||
# Step 2B -> Subtract Federal Income Tax in yearly form -> Our Fed withholding is -1422.4 * 52.0 = -73964.8
|
||||
# -> 284000.0 - 73964.8 = 210035.2
|
||||
# Step 2C -> Subtract the personal exemption -> 1500 for single
|
||||
# -> 210035.2 - 1500 = 208535.2
|
||||
# Step 2D -> Since income is so high, only 300$ per dependent -> 600. Subtract
|
||||
# -> 208535.2 - 600 = 207935.2
|
||||
#
|
||||
# Step 5 (after adding previous lines) -> Compute marginal taxes.
|
||||
# (500 * (2.00 / 100)) + (2500 * (4.00 / 100)) + ((207935.2 - 500 - 2500) * (5.00 / 100)) -> 10356.76
|
||||
# Convert back to pay period
|
||||
# wh = 10356.76 / 52.0 rounded -> 199.17
|
||||
wh = -199.17
|
||||
|
||||
employee = self._createEmployee()
|
||||
contract = self._createContract(employee,
|
||||
wage=salary,
|
||||
state_id=self.get_us_state('AL'),
|
||||
al_a4_sit_exemptions='S',
|
||||
state_income_tax_additional_withholding=40.0,
|
||||
state_income_tax_exempt=False,
|
||||
al_a4_sit_dependents=dependents,
|
||||
schedule_pay=schedule_pay)
|
||||
|
||||
self._log('2019 Alabama tax first payslip additional withholding:')
|
||||
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
|
||||
payslip.compute_sheet()
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
self.assertPayrollEqual(cats['EE_US_941_FIT'], -1422.4) # Hand Calculated.
|
||||
self.assertPayrollEqual(cats['ER_US_SUTA'], salary * self.AL_UNEMP)
|
||||
self.assertPayrollEqual(cats['EE_US_SIT'], wh - additional_wh)
|
||||
|
||||
def test_personal_exemption(self):
|
||||
salary = 5500.0
|
||||
schedule_pay = 'weekly'
|
||||
# filing status default is single
|
||||
|
||||
# see https://revenue.alabama.gov/wp-content/uploads/2019/01/whbooklet_0119.pdf for reference
|
||||
# Hand Calculated Amount to Test
|
||||
# Step 1 -> 5500.00 for wages per period , 52.0 for monthly -> 5500 * 52.0 -> 286000.0
|
||||
# Step 2A -> standard deduction for highest wage bracket -> 2000. Subtract from yearly income
|
||||
# 286000.0 - 2000 = 284000.0
|
||||
# Step 2B -> Subtract Federal Income Tax in yearly form -> Our Fed withholding is -1422.4 * 52.0 = -73964.8
|
||||
# -> 284000.0 - 73964.8 = 210035.2
|
||||
# Step 2C -> Subtract the personal exemption -> 0 for personal exemptioon
|
||||
# -> 210035.2 - 0 = 210035.2
|
||||
# Step 2D -> Subtract per dependent. No dependents so 0
|
||||
# -> 210035.2 - 0 = 210035.2
|
||||
#
|
||||
# Step 5 (after adding previous lines) -> Compute marginal taxes.
|
||||
# (500 * (2.00 / 100)) + (2500 * (4.00 / 100)) + ((210035.2 - 500 - 2500) * (5.00 / 100)) -> 10461.76
|
||||
# Convert back to pay period
|
||||
# wh = 10461.76 / 52.0 rounded -> 201.19
|
||||
wh = -199.74
|
||||
|
||||
employee = self._createEmployee()
|
||||
contract = self._createContract(employee,
|
||||
wage=salary,
|
||||
state_id=self.get_us_state('AL'),
|
||||
al_a4_sit_exemptions='S',
|
||||
state_income_tax_additional_withholding=0.0,
|
||||
state_income_tax_exempt=False,
|
||||
al_a4_sit_dependents=0.0,
|
||||
schedule_pay=schedule_pay)
|
||||
|
||||
self._log('2019 Alabama tax first payslip additional withholding:')
|
||||
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
|
||||
payslip.compute_sheet()
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
self.assertPayrollEqual(cats['EE_US_941_FIT'], -1422.4) # Hand Calculated.
|
||||
self.assertPayrollEqual(cats['ER_US_SUTA'], salary * self.AL_UNEMP)
|
||||
self.assertPayrollEqual(cats['EE_US_SIT'], wh)
|
||||
36
l10n_us_hr_payroll/tests/test_us_al_alabama_payslip_2020.py
Normal file
36
l10n_us_hr_payroll/tests/test_us_al_alabama_payslip_2020.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
from datetime import date, timedelta
|
||||
from .common import TestUsPayslip
|
||||
|
||||
|
||||
class TestUsALPayslip(TestUsPayslip):
|
||||
# Taxes and Rates
|
||||
AL_UNEMP_MAX_WAGE = 8000.00
|
||||
AL_UNEMP = 2.70
|
||||
|
||||
def _test_sit(self, wage, exempt, exemptions, additional_withholding, dependent, schedule_pay, date_start, expected_withholding):
|
||||
|
||||
employee = self._createEmployee()
|
||||
contract = self._createContract(employee,
|
||||
wage=wage,
|
||||
state_id=self.get_us_state('AL'),
|
||||
al_a4_sit_exemptions=exempt,
|
||||
state_income_tax_exempt=exemptions,
|
||||
state_income_tax_additional_withholding=additional_withholding,
|
||||
al_a4_sit_dependents=dependent,
|
||||
schedule_pay=schedule_pay)
|
||||
payslip = self._createPayslip(employee, date_start, date_start + timedelta(days=7))
|
||||
payslip.compute_sheet()
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
self._log('Computed period tax: ' + str(expected_withholding))
|
||||
self.assertPayrollEqual(cats.get('EE_US_SIT', 0.0), -expected_withholding)
|
||||
|
||||
def test_2020_taxes_example(self):
|
||||
self._test_er_suta('AL', self.AL_UNEMP, date(2020, 1, 1), wage_base=self.AL_UNEMP_MAX_WAGE)
|
||||
self._test_sit(10000.0, 'S', False, 0.0, 1.0, 'weekly', date(2020, 1, 1), 349.08)
|
||||
self._test_sit(850.0, 'M', False, 0.0, 2.0, 'weekly', date(2020, 1, 1), 29.98)
|
||||
self._test_sit(5000.0, 'H', False, 0.0, 2.0, 'bi-weekly', date(2020, 1, 1), 191.15)
|
||||
self._test_sit(20000.0, 'MS', False, 2.0, 0, 'monthly', date(2020, 1, 1), 757.6)
|
||||
self._test_sit(5500.0, '0', True, 2.0, 150, 'weekly', date(2020, 1, 1), 0)
|
||||
@@ -44,6 +44,13 @@
|
||||
<field name="workers_comp_er_code"/>
|
||||
</group>
|
||||
|
||||
<group name="state_al_alabama" string="AL Alabama" attrs="{'invisible':[('state_id', '!=', %(base.state_us_1)s)]}">
|
||||
<p colspan="2"><h3>Form A4 - State Income Tax</h3></p>
|
||||
<field name="al_a4_sit_exemptions" string="Withholding Exemptions 1. 2. 3."/>
|
||||
<field name="al_a4_sit_dependents" string="Dependents 4."/>
|
||||
<field name="state_income_tax_additional_withholding" string="Additional Withholding 5."/>
|
||||
<field name="state_income_tax_exempt" string="Exempt 6."/>
|
||||
</group>
|
||||
<group name="state_ar_arkansas" string="AR Arkansas" attrs="{'invisible':[('state_id', '!=', %(base.state_us_4)s)]}">
|
||||
<p colspan="2"><h3>Form AR4EC - State Income Tax</h3></p>
|
||||
<field name="ar_ar4ec_sit_allowances" string="Allowances 3."/>
|
||||
|
||||
Reference in New Issue
Block a user