From c53ce9ead7e0b757dfb19082eb64280bdfda98e0 Mon Sep 17 00:00:00 2001 From: Bhoomi Vaishnani Date: Tue, 18 Aug 2020 15:15:37 -0400 Subject: [PATCH] [IMP] l10n_us_hr_payroll: Refactored Tax table and Improved test case for ME Maine 2020. --- l10n_us_hr_payroll/data/state/me_maine.xml | 24 ++++++++++++------- l10n_us_hr_payroll/models/state/me_maine.py | 4 +--- .../models/us_payroll_config.py | 2 +- .../tests/test_us_me_maine_payslip_2020.py | 9 +++---- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/l10n_us_hr_payroll/data/state/me_maine.xml b/l10n_us_hr_payroll/data/state/me_maine.xml index 290781f9..2c1aaf71 100644 --- a/l10n_us_hr_payroll/data/state/me_maine.xml +++ b/l10n_us_hr_payroll/data/state/me_maine.xml @@ -27,7 +27,7 @@ - + US ME Maine SIT Tax Rate us_me_sit_tax_rate @@ -37,14 +37,14 @@ { 'single': ( - ( 22200, 0, 5.80), - ( 52600, 1288, 6.75), - ( 'inf', 3340, 7.15), + ( 22200, 0, 5.80), + ( 52600, 1288, 6.75), + ( 'inf', 3340, 7.15), ), 'married': ( - ( 44450, 0, 0.00), - ( 105200, 2578, 6.75), - ( 'inf', 6679, 7.15), + ( 44450, 0, 5.80), + ( 105200, 2578, 6.75), + ( 'inf', 6679, 7.15), ), } @@ -60,8 +60,14 @@ { - 'single': (( 82900, 9550), (157900, 75000)), - 'married': ((165800, 21950), (315800, 150000)), + 'single': { + ( 82900, 9550), + (157900, 75000), + }, + 'married': { + (165800, 21950), + (315800, 150000), + }, } diff --git a/l10n_us_hr_payroll/models/state/me_maine.py b/l10n_us_hr_payroll/models/state/me_maine.py index d2f4d36b..0accc6ff 100644 --- a/l10n_us_hr_payroll/models/state/me_maine.py +++ b/l10n_us_hr_payroll/models/state/me_maine.py @@ -47,7 +47,6 @@ def me_maine_state_income_withholding(payslip, categories, worked_days, inputs): standard_deduction_amt = last * (amt - taxable_income) / flat_amt break last = flat_amt - annual_income = taxable_income - (exemption_amt + standard_deduction_amt) withholding = 0.0 for row in tax_rate: @@ -57,8 +56,7 @@ def me_maine_state_income_withholding(payslip, categories, worked_days, inputs): break last = amt - if withholding < 0.0: - withholding = 0.0 + withholding = max(withholding, 0.0) withholding = round(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 37fe2602..eb84ce65 100644 --- a/l10n_us_hr_payroll/models/us_payroll_config.py +++ b/l10n_us_hr_payroll/models/us_payroll_config.py @@ -143,7 +143,7 @@ class HRContractUSPayrollConfig(models.Model): me_w4me_sit_filing_status = fields.Selection([ ('', 'Exempt'), - ('single', 'Single'), + ('single', 'Single or Head of Household'), ('married', 'Married'), ], string='Maine W-4ME Filing Status', help='ME W-4ME 3.') me_w4me_sit_allowances = fields.Integer(string='Maine Allowances', help='W-4ME 4.') diff --git a/l10n_us_hr_payroll/tests/test_us_me_maine_payslip_2020.py b/l10n_us_hr_payroll/tests/test_us_me_maine_payslip_2020.py index b5f0ca87..165455ce 100644 --- a/l10n_us_hr_payroll/tests/test_us_me_maine_payslip_2020.py +++ b/l10n_us_hr_payroll/tests/test_us_me_maine_payslip_2020.py @@ -27,12 +27,13 @@ class TestUsMEPayslip(TestUsPayslip): cats = self._getCategories(payslip) self._log('Computed period tax: ' + str(expected_withholding)) - self.assertPayrollEqual(cats.get('EE_US_SIT', 0.0), -expected_withholding) + self.assertPayrollAlmostEqual(cats.get('EE_US_SIT', 0.0), -expected_withholding) def test_2020_taxes_example(self): self._test_er_suta('ME', self.ME_UNEMP, date(2020, 1, 1), wage_base=self.ME_UNEMP_MAX_WAGE) self._test_sit(300.0, 'single', 0.0, False, 2, 'weekly', date(2020, 1, 1), 0.0) - self._test_sit(800.0, 'single', 0.0, False, 2, 'weekly', date(2020, 1, 1), 26.00) - self._test_sit(4500.0, 'married', 0.0, False, 2, 'weekly', date(2020, 1, 1), 277.00) - self._test_sit(4500.0, 'married', 0.0, True, 2, 'weekly', date(2020, 1, 1), 0.00) + self._test_sit(800.0, 'single', 0.0, False, 2, 'bi-weekly', date(2020, 1, 1), 6.00) + self._test_sit(4500.0, 'married', 0.0, True, 0, 'weekly', date(2020, 1, 1), 0.00) + self._test_sit(4500.0, 'married', 0.0, False, 2, 'monthly', date(2020, 1, 1), 113.00) self._test_sit(4500.0, 'married', 10.0, False, 2, 'weekly', date(2020, 1, 1), 287.00) + self._test_sit(7000.0, '', 10.0, False, 2, 'weekly', date(2020, 1, 1), 0.00)