From 5068a883e36204523d4cf32b2e5c1c9c16f83bec Mon Sep 17 00:00:00 2001
From: Bhoomi Vaishnani
Date: Mon, 17 Feb 2020 13:05:15 -0500
Subject: [PATCH] IMP `l10n_us_hr_payroll` Port `l10n_us_al_hr_payroll` AL
Alabama including migration
---
l10n_us_hr_payroll/__manifest__.py | 1 +
l10n_us_hr_payroll/data/state/al_alabama.xml | 191 +++++++++++++
l10n_us_hr_payroll/models/hr_payslip.py | 2 +
l10n_us_hr_payroll/models/state/al_alabama.py | 77 +++++
.../models/us_payroll_config.py | 9 +
l10n_us_hr_payroll/tests/__init__.py | 3 +
.../tests/test_us_al_alabama_payslip_2019.py | 264 ++++++++++++++++++
.../tests/test_us_al_alabama_payslip_2020.py | 36 +++
.../views/us_payroll_config_views.xml | 7 +
9 files changed, 590 insertions(+)
create mode 100644 l10n_us_hr_payroll/data/state/al_alabama.xml
create mode 100644 l10n_us_hr_payroll/models/state/al_alabama.py
create mode 100644 l10n_us_hr_payroll/tests/test_us_al_alabama_payslip_2019.py
create mode 100644 l10n_us_hr_payroll/tests/test_us_al_alabama_payslip_2020.py
diff --git a/l10n_us_hr_payroll/__manifest__.py b/l10n_us_hr_payroll/__manifest__.py
index 77b506fd..3f26f989 100644
--- a/l10n_us_hr_payroll/__manifest__.py
+++ b/l10n_us_hr_payroll/__manifest__.py
@@ -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',
diff --git a/l10n_us_hr_payroll/data/state/al_alabama.xml b/l10n_us_hr_payroll/data/state/al_alabama.xml
new file mode 100644
index 00000000..b1a8cfe1
--- /dev/null
+++ b/l10n_us_hr_payroll/data/state/al_alabama.xml
@@ -0,0 +1,191 @@
+
+
+
+
+ US AL Alabama SUTA Wage Base
+ us_al_suta_wage_base
+
+
+
+
+ 8000.0
+
+
+
+
+ 8000.0
+
+
+
+
+
+
+
+ US AL Alabama SUTA Rate
+ us_al_suta_rate
+
+
+
+
+ 2.7
+
+
+
+
+ 2.7
+
+
+
+
+
+
+ US AL Alabama SIT Tax Rate
+ us_al_sit_tax_rate
+
+
+
+
+ {
+ '0': [(500, 2),( 3000, 4),('inf', 5)],
+ 'M': [( 1000, 2),( 6000, 4),('inf', 5)],
+ }
+
+
+
+
+ {
+ '0' : [(500, 2),(2500, 4),('inf', 5)],
+ 'M': [(1000, 2),(5000, 4),('inf', 5)],
+ }
+
+
+
+
+
+
+ US AL Alabama Dependent Rate
+ us_al_sit_dependent_rate
+
+
+
+
+ [
+ ( 1000, 20000),
+ ( 500, 100000),
+ ( 300, 'inf'),
+ ]
+
+
+
+
+ [
+ ( 1000, 20000),
+ ( 500, 100000),
+ ( 300, 'inf'),
+ ]
+
+
+
+
+
+
+ US AL Alabama Standard Deduction Rate
+ us_al_sit_standard_deduction_rate
+
+
+
+
+ {
+ '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)),
+ }
+
+
+
+
+ {
+ '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)),
+ }
+
+
+
+
+
+
+ US AL Alabama Personal Exemption Rate
+ us_al_sit_personal_exemption_rate
+
+
+
+
+ {
+ '0' : 0,
+ 'S' : 1500,
+ 'MS': 1500,
+ 'M' : 3000,
+ 'H' : 3000,
+ }
+
+
+
+
+ {
+ '0' : 0,
+ 'S' : 1500,
+ 'MS': 1500,
+ 'M' : 3000,
+ 'H' : 3000,
+ }
+
+
+
+
+
+
+
+ US Alabama - Department of Economic Security (IDES) - Unemployment Tax
+
+
+
+ US Alabama - Department of Revenue (IDOR) - Income Tax
+
+
+
+
+
+
+
+
+
+ ER: US AL Alabama State Unemployment
+ ER_US_AL_SUTA
+ 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')
+ code
+ 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')
+
+
+
+
+
+
+
+
+ EE: US AL Alabama State Income Tax Withholding
+ EE_US_AL_SIT
+ python
+ result, _ = al_alabama_state_income_withholding(payslip, categories, worked_days, inputs)
+ code
+ result, result_rate = al_alabama_state_income_withholding(payslip, categories, worked_days, inputs)
+
+
+
+
+
\ No newline at end of file
diff --git a/l10n_us_hr_payroll/models/hr_payslip.py b/l10n_us_hr_payroll/models/hr_payslip.py
index 4141a0f5..3d52d04c 100644
--- a/l10n_us_hr_payroll/models/hr_payslip.py
+++ b/l10n_us_hr_payroll/models/hr_payslip.py
@@ -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,
diff --git a/l10n_us_hr_payroll/models/state/al_alabama.py b/l10n_us_hr_payroll/models/state/al_alabama.py
new file mode 100644
index 00000000..15740c91
--- /dev/null
+++ b/l10n_us_hr_payroll/models/state/al_alabama.py
@@ -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)
diff --git a/l10n_us_hr_payroll/models/us_payroll_config.py b/l10n_us_hr_payroll/models/us_payroll_config.py
index bc76715a..69dc69c2 100644
--- a/l10n_us_hr_payroll/models/us_payroll_config.py
+++ b/l10n_us_hr_payroll/models/us_payroll_config.py
@@ -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(
diff --git a/l10n_us_hr_payroll/tests/__init__.py b/l10n_us_hr_payroll/tests/__init__.py
index e5b8fa04..1ded7fb4 100755
--- a/l10n_us_hr_payroll/tests/__init__.py
+++ b/l10n_us_hr_payroll/tests/__init__.py
@@ -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
diff --git a/l10n_us_hr_payroll/tests/test_us_al_alabama_payslip_2019.py b/l10n_us_hr_payroll/tests/test_us_al_alabama_payslip_2019.py
new file mode 100644
index 00000000..61290314
--- /dev/null
+++ b/l10n_us_hr_payroll/tests/test_us_al_alabama_payslip_2019.py
@@ -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)
diff --git a/l10n_us_hr_payroll/tests/test_us_al_alabama_payslip_2020.py b/l10n_us_hr_payroll/tests/test_us_al_alabama_payslip_2020.py
new file mode 100644
index 00000000..055c95cb
--- /dev/null
+++ b/l10n_us_hr_payroll/tests/test_us_al_alabama_payslip_2020.py
@@ -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)
diff --git a/l10n_us_hr_payroll/views/us_payroll_config_views.xml b/l10n_us_hr_payroll/views/us_payroll_config_views.xml
index dafaf285..082aedcb 100644
--- a/l10n_us_hr_payroll/views/us_payroll_config_views.xml
+++ b/l10n_us_hr_payroll/views/us_payroll_config_views.xml
@@ -44,6 +44,13 @@
+
+ Form A4 - State Income Tax
+
+
+
+
+
Form AR4EC - State Income Tax