From 87e5042522e3dfc816f2e2907ff3caa099edcf4d Mon Sep 17 00:00:00 2001 From: Bhoomi Vaishnani Date: Wed, 19 Aug 2020 21:10:21 -0400 Subject: [PATCH] [IMP] l10n_us_hr_payroll: Improved comments, Tax table, filing status and test case for AL Alabama 2020 --- l10n_us_hr_payroll/data/state/al_alabama.xml | 56 ++++++++++++++----- l10n_us_hr_payroll/models/state/al_alabama.py | 5 +- .../models/us_payroll_config.py | 2 +- .../tests/test_us_al_alabama_payslip_2020.py | 2 +- 4 files changed, 48 insertions(+), 17 deletions(-) diff --git a/l10n_us_hr_payroll/data/state/al_alabama.xml b/l10n_us_hr_payroll/data/state/al_alabama.xml index b1a8cfe1..fc3b3af1 100644 --- a/l10n_us_hr_payroll/data/state/al_alabama.xml +++ b/l10n_us_hr_payroll/data/state/al_alabama.xml @@ -46,16 +46,32 @@ { - '0': [(500, 2),( 3000, 4),('inf', 5)], - 'M': [( 1000, 2),( 6000, 4),('inf', 5)], + '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)], + '0' : [ + ( 500, 2), + ( 2500, 4), + ('inf', 5), + ], + 'M': [ + ( 1000, 2), + ( 5000, 4), + ('inf', 5), + ], } @@ -68,6 +84,8 @@ + + [ ( 1000, 20000), @@ -77,6 +95,8 @@ + + [ ( 1000, 20000), @@ -94,24 +114,28 @@ + + { - '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)), } + + { - '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)), } @@ -124,6 +148,8 @@ + + { '0' : 0, @@ -135,6 +161,8 @@ + + { '0' : 0, diff --git a/l10n_us_hr_payroll/models/state/al_alabama.py b/l10n_us_hr_payroll/models/state/al_alabama.py index 15740c91..11638b7f 100644 --- a/l10n_us_hr_payroll/models/state/al_alabama.py +++ b/l10n_us_hr_payroll/models/state/al_alabama.py @@ -18,6 +18,10 @@ def al_alabama_state_income_withholding(payslip, categories, worked_days, inputs if not wage: return 0.0, 0.0 + exemptions = payslip.contract_id.us_payroll_config_value('al_a4_sit_exemptions') + if not exemptions: + 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 @@ -25,7 +29,6 @@ def al_alabama_state_income_withholding(payslip, categories, worked_days, inputs 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) diff --git a/l10n_us_hr_payroll/models/us_payroll_config.py b/l10n_us_hr_payroll/models/us_payroll_config.py index 82ebe623..74bf4915 100644 --- a/l10n_us_hr_payroll/models/us_payroll_config.py +++ b/l10n_us_hr_payroll/models/us_payroll_config.py @@ -52,7 +52,7 @@ class HRContractUSPayrollConfig(models.Model): help='Form W4 (2020+) 4(c)') al_a4_sit_exemptions = fields.Selection([ - ('0', '0'), + ('', '0'), ('S', 'S'), ('MS', 'MS'), ('M', 'M'), 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 index 055c95cb..23865fc7 100644 --- 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 @@ -33,4 +33,4 @@ class TestUsALPayslip(TestUsPayslip): 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) + self._test_sit(5500.0, '', True, 2.0, 150, 'weekly', date(2020, 1, 1), 0.00)