From 072fa1aa6d4f801c7d63c0a583e49a6b15c78fdb Mon Sep 17 00:00:00 2001 From: Bhoomi Vaishnani Date: Tue, 10 Mar 2020 10:37:05 -0400 Subject: [PATCH] IMP `l10n_us_hr_payroll` for Delaware 12.0 --- l10n_us_hr_payroll/__manifest__.py | 1 + l10n_us_hr_payroll/data/final.xml | 3 + l10n_us_hr_payroll/data/state/de_delaware.xml | 107 ++++++++++++++++++ l10n_us_hr_payroll/models/hr_payslip.py | 2 + .../models/state/de_delaware.py | 49 ++++++++ .../models/us_payroll_config.py | 6 + l10n_us_hr_payroll/tests/__init__.py | 2 + .../tests/test_us_de_delaware_payslip_2020.py | 36 ++++++ .../views/us_payroll_config_views.xml | 6 + 9 files changed, 212 insertions(+) create mode 100644 l10n_us_hr_payroll/data/state/de_delaware.xml create mode 100644 l10n_us_hr_payroll/models/state/de_delaware.py create mode 100755 l10n_us_hr_payroll/tests/test_us_de_delaware_payslip_2020.py diff --git a/l10n_us_hr_payroll/__manifest__.py b/l10n_us_hr_payroll/__manifest__.py index 89a3ea57..da18209f 100755 --- a/l10n_us_hr_payroll/__manifest__.py +++ b/l10n_us_hr_payroll/__manifest__.py @@ -34,6 +34,7 @@ USA Payroll Rules. 'data/state/az_arizona.xml', 'data/state/ca_california.xml', 'data/state/ct_connecticut.xml', + 'data/state/de_delaware.xml', 'data/state/fl_florida.xml', 'data/state/ga_georgia.xml', 'data/state/hi_hawaii.xml', diff --git a/l10n_us_hr_payroll/data/final.xml b/l10n_us_hr_payroll/data/final.xml index 61ac2e09..94f80383 100644 --- a/l10n_us_hr_payroll/data/final.xml +++ b/l10n_us_hr_payroll/data/final.xml @@ -36,6 +36,9 @@ ref('hr_payroll_rule_er_us_ct_suta'), ref('hr_payroll_rule_ee_us_ct_sit'), + ref('hr_payroll_rule_er_us_de_suta'), + ref('hr_payroll_rule_ee_us_de_sit'), + ref('hr_payroll_rule_er_us_fl_suta'), ref('hr_payroll_rule_er_us_ga_suta'), diff --git a/l10n_us_hr_payroll/data/state/de_delaware.xml b/l10n_us_hr_payroll/data/state/de_delaware.xml new file mode 100644 index 00000000..c37a2df5 --- /dev/null +++ b/l10n_us_hr_payroll/data/state/de_delaware.xml @@ -0,0 +1,107 @@ + + + + + + US DE Delaware SUTA Wage Base + us_de_suta_wage_base + 16500.0 + + + + + + + + US DE Delaware SUTA Rate + us_de_suta_rate + 1.50 + + + + + + + US DE Delaware SIT Tax Rate + us_de_sit_tax_rate + [ + ( 2000, 0.0, 0.00), + ( 5000, 0.0, 2.20), + (10000, 66.0, 3.90), + (20000, 261.0, 4.80), + (25000, 741.0, 5.20), + (60000, 1001.0, 5.55), + ('inf', 2943.0, 6.60), + + ] + + + + + + + US DE Delaware Standard Deduction Rate + us_de_sit_standard_deduction_rate + 3250 + + + + + + + US DE Delaware Personal Exemption Rate + us_de_sit_personal_exemption_rate + 110 + + + + + + + US Delaware - Division of Unemployment Insurance - Unemployment Tax + 1 + + + US Delaware - Division of Unemployment Insurance - Unemployment Tax + + + + + US Delaware - Division of Revenue - Income Tax + 1 + + + US Delaware - Division of Revenue - Unemployment Tax + + + + + + + + + + ER: US DE Delaware State Unemployment + ER_US_DE_SUTA + python + result, _ = general_state_unemployment(payslip, categories, worked_days, inputs, wage_base='us_de_suta_wage_base', rate='us_de_suta_rate', state_code='DE') + code + result, result_rate = general_state_unemployment(payslip, categories, worked_days, inputs, wage_base='us_de_suta_wage_base', rate='us_de_suta_rate', state_code='DE') + + + + + + + + EE: US DE Delaware State Income Tax Withholding + EE_US_DE_SIT + python + result, _ = de_delaware_state_income_withholding(payslip, categories, worked_days, inputs) + code + result, result_rate = de_delaware_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 555447b9..97bf1e3c 100644 --- a/l10n_us_hr_payroll/models/hr_payslip.py +++ b/l10n_us_hr_payroll/models/hr_payslip.py @@ -19,6 +19,7 @@ from .state.ar_arkansas import ar_arkansas_state_income_withholding from .state.az_arizona import az_arizona_state_income_withholding from .state.ca_california import ca_california_state_income_withholding from .state.ct_connecticut import ct_connecticut_state_income_withholding +from .state.de_delaware import de_delaware_state_income_withholding from .state.ga_georgia import ga_georgia_state_income_withholding from .state.hi_hawaii import hi_hawaii_state_income_withholding from .state.id_idaho import id_idaho_state_income_withholding @@ -71,6 +72,7 @@ class HRPayslip(models.Model): 'az_arizona_state_income_withholding': az_arizona_state_income_withholding, 'ca_california_state_income_withholding': ca_california_state_income_withholding, 'ct_connecticut_state_income_withholding': ct_connecticut_state_income_withholding, + 'de_delaware_state_income_withholding': de_delaware_state_income_withholding, 'ga_georgia_state_income_withholding': ga_georgia_state_income_withholding, 'hi_hawaii_state_income_withholding': hi_hawaii_state_income_withholding, 'id_idaho_state_income_withholding': id_idaho_state_income_withholding, diff --git a/l10n_us_hr_payroll/models/state/de_delaware.py b/l10n_us_hr_payroll/models/state/de_delaware.py new file mode 100644 index 00000000..cb24edf5 --- /dev/null +++ b/l10n_us_hr_payroll/models/state/de_delaware.py @@ -0,0 +1,49 @@ +# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details. + +from .general import _state_applies, sit_wage + + +def de_delaware_state_income_withholding(payslip, categories, worked_days, inputs): + """ + Returns SIT eligible wage and rate. + + :return: result, result_rate (wage, percent) + """ + state_code = 'DE' + 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 + + filing_status = payslip.dict.contract_id.us_payroll_config_value('de_w4_sit_filing_status') + if not filing_status: + return 0.0, 0.0 + + pay_periods = payslip.dict.get_pay_periods_in_year() + additional = payslip.dict.contract_id.us_payroll_config_value('state_income_tax_additional_withholding') + tax_table = payslip.dict.rule_parameter('us_de_sit_tax_rate') + personal_exemption = payslip.dict.rule_parameter('us_de_sit_personal_exemption_rate') + allowances = payslip.dict.contract_id.us_payroll_config_value('de_w4_sit_dependent') + standard_deduction = payslip.dict.rule_parameter('us_de_sit_standard_deduction_rate') + + taxable_income = wage * pay_periods + if filing_status == 'single': + taxable_income -= standard_deduction + else: + taxable_income -= standard_deduction * 2 + + withholding = 0.0 + last = 0.0 + for row in tax_table: + if taxable_income <= float(row[0]): + withholding = (row[1] + ((row[2] / 100.0) * (taxable_income - last)) - (allowances * personal_exemption)) + break + last = row[0] + + withholding = max(withholding, 0.0) + withholding = 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 f971bf4d..7f11e696 100644 --- a/l10n_us_hr_payroll/models/us_payroll_config.py +++ b/l10n_us_hr_payroll/models/us_payroll_config.py @@ -85,6 +85,12 @@ class HRContractUSPayrollConfig(models.Model): ('f', 'F'), ], string='Connecticut CT-W4 Withholding Code', help='CT-W4 1.') + de_w4_sit_filing_status = fields.Selection([ + ('single', 'Single or Married filing separately'), + ('married', 'Married filing jointly'), + ], string='Delaware W-4 Marital Status', help='DE W-4 3.') + de_w4_sit_dependent = fields.Integer(string='Delaware W-4 Dependents', help='DE W-4 4.') + ga_g4_sit_filing_status = fields.Selection([ ('exempt', 'Exempt'), ('single', 'Single'), diff --git a/l10n_us_hr_payroll/tests/__init__.py b/l10n_us_hr_payroll/tests/__init__.py index d6e43e9e..ed39aac5 100755 --- a/l10n_us_hr_payroll/tests/__init__.py +++ b/l10n_us_hr_payroll/tests/__init__.py @@ -22,6 +22,8 @@ from . import test_us_ca_california_payslip_2020 from . import test_us_ct_connecticut_payslip_2019 from . import test_us_ct_connecticut_payslip_2020 +from . import test_us_de_delaware_payslip_2020 + from . import test_us_fl_florida_payslip_2019 from . import test_us_fl_florida_payslip_2020 diff --git a/l10n_us_hr_payroll/tests/test_us_de_delaware_payslip_2020.py b/l10n_us_hr_payroll/tests/test_us_de_delaware_payslip_2020.py new file mode 100755 index 00000000..ed285368 --- /dev/null +++ b/l10n_us_hr_payroll/tests/test_us_de_delaware_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 TestUsDEPayslip(TestUsPayslip): + ### + # 2020 Taxes and Rates + ### + DE_UNEMP_MAX_WAGE = 16500.0 + DE_UNEMP = 1.50 + # Calculation based on section 17. https://revenue.delaware.gov/employers-guide-withholding-regulations-employers-duties/ + + def _test_sit(self, wage, filing_status, additional_withholding, dependents, schedule_pay, date_start, expected_withholding): + employee = self._createEmployee() + contract = self._createContract(employee, + wage=wage, + state_id=self.get_us_state('DE'), + de_w4_sit_filing_status=filing_status, + state_income_tax_additional_withholding=additional_withholding, + de_w4_sit_dependent=dependents, + 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('DE', self.DE_UNEMP, date(2020, 1, 1), wage_base=self.DE_UNEMP_MAX_WAGE) + self._test_sit(480.77, 'single', 0.0, 1.0, 'weekly', date(2020, 1, 1), 13.88) + self._test_sit(5000.0, 'single', 0.0, 2.0, 'monthly', date(2020, 1, 1), 211.93) + self._test_sit(5000.0, 'single', 10.0, 1.0, 'monthly', date(2020, 1, 1), 231.1) + self._test_sit(20000.0, 'married', 0.0, 3.0, 'quarterly', date(2020, 1, 1), 876.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 40b7a9ce..dc976594 100644 --- a/l10n_us_hr_payroll/views/us_payroll_config_views.xml +++ b/l10n_us_hr_payroll/views/us_payroll_config_views.xml @@ -69,6 +69,12 @@ + +

Form DE W-4 - State Income Tax

+ + + +

Form CT-W4 - State Income Tax