From 7c9158dfd2162a3af6f8b994c0b61dc3f9837364 Mon Sep 17 00:00:00 2001 From: Bhoomi Vaishnani Date: Wed, 1 Apr 2020 14:04:11 -0400 Subject: [PATCH] IMP `l10n_us_hr_payroll` Port `l10n_us_la_hr_payroll` LA Louisiana including migration --- l10n_us_hr_payroll/__manifest__.py | 1 + .../data/state/la_louisiana.xml | 141 ++++++++++++++++++ l10n_us_hr_payroll/models/hr_payslip.py | 2 + .../models/state/la_louisiana.py | 60 ++++++++ .../models/us_payroll_config.py | 8 + l10n_us_hr_payroll/tests/__init__.py | 3 + .../test_us_la_louisiana_payslip_2019.py | 87 +++++++++++ .../test_us_la_louisiana_payslip_2020.py | 34 +++++ .../views/us_payroll_config_views.xml | 6 + 9 files changed, 342 insertions(+) create mode 100644 l10n_us_hr_payroll/data/state/la_louisiana.xml create mode 100644 l10n_us_hr_payroll/models/state/la_louisiana.py create mode 100644 l10n_us_hr_payroll/tests/test_us_la_louisiana_payslip_2019.py create mode 100755 l10n_us_hr_payroll/tests/test_us_la_louisiana_payslip_2020.py diff --git a/l10n_us_hr_payroll/__manifest__.py b/l10n_us_hr_payroll/__manifest__.py index f6aec784..fee61b48 100644 --- a/l10n_us_hr_payroll/__manifest__.py +++ b/l10n_us_hr_payroll/__manifest__.py @@ -40,6 +40,7 @@ United States of America - Payroll Rules. 'data/state/id_idaho.xml', 'data/state/il_illinois.xml', 'data/state/in_indiana.xml', + 'data/state/la_louisiana.xml', 'data/state/mi_michigan.xml', 'data/state/mn_minnesota.xml', 'data/state/mo_missouri.xml', diff --git a/l10n_us_hr_payroll/data/state/la_louisiana.xml b/l10n_us_hr_payroll/data/state/la_louisiana.xml new file mode 100644 index 00000000..5f23bea4 --- /dev/null +++ b/l10n_us_hr_payroll/data/state/la_louisiana.xml @@ -0,0 +1,141 @@ + + + + + US LA Louisiana SUTA Wage Base + us_la_suta_wage_base + + + + + 7700.0 + + + + + 7700.0 + + + + + + + + US LA Louisiana SUTA Rate + us_la_suta_rate + + + + + 6.20 + + + + + 6.20 + + + + + + + US LA Louisiana SIT Tax Rate + us_la_sit_tax_rate + + + + + { + 'single': ((12500.00, 2.10), (50000.00, 1.60), ('inf', 1.35)), + 'married': ((25000.00, 2.10), (100000.00, 1.65), ('inf', 1.35)), + } + + + + + { + 'single': ((12500.00, 2.10), (50000.00, 1.60), ('inf', 1.35)), + 'married': ((25000.00, 2.10), (100000.00, 1.65), ('inf', 1.35)), + } + + + + + + + US LA Louisiana Personal Exemption Rate + us_la_sit_personal_exemption_rate + + + + + 4500 + + + + + 4500 + + + + + + + US LA Louisiana Dependent Rate + us_la_sit_dependent_rate + + + + + 1000.0 + + + + + 1000.0 + + + + + + + + US Louisiana - Workforce Commission (LWC) - Unemployment Tax + + + + US Louisiana - Department of Revenue (LDOR) - Income Tax + + + + + + + + + + ER: US LA Louisiana State Unemployment + ER_US_LA_SUTA + python + result, _ = general_state_unemployment(payslip, categories, worked_days, inputs, wage_base='us_la_suta_wage_base', rate='us_la_suta_rate', state_code='LA') + code + result, result_rate = general_state_unemployment(payslip, categories, worked_days, inputs, wage_base='us_la_suta_wage_base', rate='us_la_suta_rate', state_code='LA') + + + + + + + + + EE: US LA Louisiana State Income Tax Withholding + EE_US_LA_SIT + python + result, _ = la_louisiana_state_income_withholding(payslip, categories, worked_days, inputs) + code + result, result_rate = la_louisiana_state_income_withholding(payslip, categories, worked_days, inputs) + + + + + diff --git a/l10n_us_hr_payroll/models/hr_payslip.py b/l10n_us_hr_payroll/models/hr_payslip.py index 91dc4352..bf663242 100644 --- a/l10n_us_hr_payroll/models/hr_payslip.py +++ b/l10n_us_hr_payroll/models/hr_payslip.py @@ -25,6 +25,7 @@ from .state.ia_iowa import ia_iowa_state_income_withholding from .state.id_idaho import id_idaho_state_income_withholding from .state.il_illinois import il_illinois_state_income_withholding from .state.in_indiana import in_indiana_state_income_withholding +from .state.la_louisiana import la_louisiana_state_income_withholding from .state.mi_michigan import mi_michigan_state_income_withholding from .state.mn_minnesota import mn_minnesota_state_income_withholding from .state.mo_missouri import mo_missouri_state_income_withholding @@ -81,6 +82,7 @@ class HRPayslip(models.Model): 'id_idaho_state_income_withholding': id_idaho_state_income_withholding, 'il_illinois_state_income_withholding': il_illinois_state_income_withholding, 'in_indiana_state_income_withholding': in_indiana_state_income_withholding, + 'la_louisiana_state_income_withholding': la_louisiana_state_income_withholding, 'mi_michigan_state_income_withholding': mi_michigan_state_income_withholding, 'mn_minnesota_state_income_withholding': mn_minnesota_state_income_withholding, 'mo_missouri_state_income_withholding': mo_missouri_state_income_withholding, diff --git a/l10n_us_hr_payroll/models/state/la_louisiana.py b/l10n_us_hr_payroll/models/state/la_louisiana.py new file mode 100644 index 00000000..0697d696 --- /dev/null +++ b/l10n_us_hr_payroll/models/state/la_louisiana.py @@ -0,0 +1,60 @@ +# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details. + +from .general import _state_applies, sit_wage + + +def la_louisiana_state_income_withholding(payslip, categories, worked_days, inputs): + """ + Returns SIT eligible wage and rate. + + :return: result, result_rate (wage, percent) + """ + state_code = 'LA' + 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.contract_id.us_payroll_config_value('la_l4_sit_filing_status') + if not filing_status: + return 0.0, 0.0 + + pay_periods = payslip.dict.get_pay_periods_in_year() + personal_exemptions = payslip.contract_id.us_payroll_config_value('la_l4_sit_exemptions') + dependent_exemptions = payslip.contract_id.us_payroll_config_value('la_l4_sit_dependents') + tax_table = payslip.rule_parameter('us_la_sit_tax_rate')[filing_status] + exemption_rate = payslip.rule_parameter('us_la_sit_personal_exemption_rate') + dependent_rate = payslip.rule_parameter('us_la_sit_dependent_rate') + + annual_wage = wage * pay_periods + + effect_cap = 0.0 + multiplier = 0.0 + if filing_status == 'single': + effect_cap = 12500.00 + multiplier = 1.60 + elif filing_status == 'married': + effect_cap = 25000.00 + multiplier = 1.65 + + after_credits_under = (2.100 / 100) * (((personal_exemptions * exemption_rate) + + (dependent_exemptions * dependent_rate)) / pay_periods) + after_credits_over = 0.00 + if after_credits_under > effect_cap: + after_credits_under = effect_cap + after_credits_over_check = ((personal_exemptions * exemption_rate) + (dependent_exemptions * dependent_rate)) - effect_cap + after_credits_over = (multiplier / 100.00) * (after_credits_over_check / pay_periods) if after_credits_over_check > 0 else 0.00 + withholding = 0.0 + last = 0.0 + for amt, rate in tax_table: + withholding = withholding + ((rate / 100.0) * (wage - (last / pay_periods))) + if annual_wage <= float(amt): + break + last = amt + + withholding = withholding - (after_credits_under + after_credits_over) + withholding = round(withholding, 2) + 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 cf5a7c81..d548e87c 100644 --- a/l10n_us_hr_payroll/models/us_payroll_config.py +++ b/l10n_us_hr_payroll/models/us_payroll_config.py @@ -126,6 +126,14 @@ class HRContractUSPayrollConfig(models.Model): in_w4_sit_personal_exemption = fields.Integer(string='Indiana In-W-4 Number of Personal Exemption', help='IN-W-4 5.') in_w4_sit_dependent_exemption = fields.Integer(string='Indiana In-W-4 Number of Dependent Exemption', help='IN-W-4 6.') + + la_l4_sit_filing_status = fields.Selection([ + ('single', 'Single'), + ('married', 'Married'), + ], string='Louisiana LA L-4 Filing Status', help='LA L-4 3.') + la_l4_sit_exemptions = fields.Integer(string='Louisiana LA L-4 Number of Exemptions', help='LA L-4 6.') + la_l4_sit_dependents = fields.Integer(string='Louisiana LA L-4 Number of Dependents', help='LA L-4 7.') + mi_w4_sit_exemptions = fields.Integer(string='Michigan MI W-4 Exemptions', help='MI-W4 6.') mn_w4mn_sit_filing_status = fields.Selection([ diff --git a/l10n_us_hr_payroll/tests/__init__.py b/l10n_us_hr_payroll/tests/__init__.py index aa4fc5ab..526762c3 100755 --- a/l10n_us_hr_payroll/tests/__init__.py +++ b/l10n_us_hr_payroll/tests/__init__.py @@ -46,6 +46,9 @@ from . import test_us_il_illinois_payslip_2020 from . import test_us_in_indiana_payslip_2020 +from . import test_us_la_louisiana_payslip_2019 +from . import test_us_la_louisiana_payslip_2020 + from . import test_us_mi_michigan_payslip_2019 from . import test_us_mi_michigan_payslip_2020 diff --git a/l10n_us_hr_payroll/tests/test_us_la_louisiana_payslip_2019.py b/l10n_us_hr_payroll/tests/test_us_la_louisiana_payslip_2019.py new file mode 100644 index 00000000..f723744a --- /dev/null +++ b/l10n_us_hr_payroll/tests/test_us_la_louisiana_payslip_2019.py @@ -0,0 +1,87 @@ +# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details. + +from .common import TestUsPayslip, process_payslip + + +class TestUsLAPayslip(TestUsPayslip): + + # TAXES AND RATES + LA_UNEMP_MAX_WAGE = 7700.00 + LA_UNEMP = -(6.20 / 100.0) + + def test_taxes_single_weekly(self): + salary = 700.00 + schedule_pay = 'weekly' + filing_status = 'single' + exemptions = 1 + dependents = 2 + # SEE http://revenue.louisiana.gov/TaxForms/1306(1_12)TF.pdf for example calculations + # wh_to test is 19.42 + # Our algorithm correctly rounds whereas theirs does it prematurely. + wh_to_check = -19.43 + employee = self._createEmployee() + contract = self._createContract(employee, + wage=salary, + state_id=self.get_us_state('LA'), + la_l4_sit_filing_status=filing_status, + la_l4_sit_exemptions=exemptions, + la_l4_sit_dependents=dependents, + schedule_pay=schedule_pay) + + self._log('2019 Louisiana tax first payslip weekly:') + 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.LA_UNEMP) + self.assertPayrollEqual(cats['EE_US_SIT'], wh_to_check) + + process_payslip(payslip) + + remaining_la_unemp_wages = self.LA_UNEMP_MAX_WAGE - salary if (self.LA_UNEMP_MAX_WAGE - 2*salary < salary) \ + else salary + + self._log('2019 Louisiana 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_la_unemp_wages * self.LA_UNEMP) + + def test_taxes_married_biweekly(self): + salary = 4600.00 + schedule_pay = 'bi-weekly' + filing_status = 'married' + exemptions = 2 + dependents = 3 + # SEE http://revenue.louisiana.gov/TaxForms/1306(1_12)TF.pdf for example calculations + # wh_to test is 157.12 + wh_to_check = -157.12 + employee = self._createEmployee() + contract = self._createContract(employee, + wage=salary, + state_id=self.get_us_state('LA'), + la_l4_sit_filing_status=filing_status, + la_l4_sit_exemptions=exemptions, + la_l4_sit_dependents=dependents, + schedule_pay=schedule_pay) + + self._log('2019 Louisiana tax first payslip bi-weekly:') + 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.LA_UNEMP) + self.assertPayrollEqual(cats['EE_US_SIT'], wh_to_check) + + process_payslip(payslip) + + remaining_la_unemp_wages = self.LA_UNEMP_MAX_WAGE - salary if (self.LA_UNEMP_MAX_WAGE - 2*salary < salary) \ + else salary + + self._log('2019 Louisiana tax second payslip bi-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_la_unemp_wages * self.LA_UNEMP) diff --git a/l10n_us_hr_payroll/tests/test_us_la_louisiana_payslip_2020.py b/l10n_us_hr_payroll/tests/test_us_la_louisiana_payslip_2020.py new file mode 100755 index 00000000..14dde5bf --- /dev/null +++ b/l10n_us_hr_payroll/tests/test_us_la_louisiana_payslip_2020.py @@ -0,0 +1,34 @@ +# 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 TestUsLAPayslip(TestUsPayslip): + ### + # 2020 Taxes and Rates + ### + LA_UNEMP_MAX_WAGE = 7700.0 + LA_UNEMP = 6.20 + # Calculation based on http://revenue.louisiana.gov/TaxForms/1306(1_12)TF.pdf + + def _test_sit(self, wage, filing_status, exemptions, dependents, schedule_pay, date_start, expected_withholding): + employee = self._createEmployee() + contract = self._createContract(employee, + wage=wage, + state_id=self.get_us_state('LA'), + la_l4_sit_filing_status=filing_status, + la_l4_sit_exemptions=exemptions, + la_l4_sit_dependents=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('LA', self.LA_UNEMP, date(2020, 1, 1), wage_base=self.LA_UNEMP_MAX_WAGE) + self._test_sit(700.0, 'single', 1.0, 2.0, 'weekly', date(2020, 1, 1), 19.43) + self._test_sit(4600.0, 'married', 2.0, 3.0, 'bi-weekly', date(2020, 1, 1), 157.12) 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 a294fa51..7865d1f8 100644 --- a/l10n_us_hr_payroll/views/us_payroll_config_views.xml +++ b/l10n_us_hr_payroll/views/us_payroll_config_views.xml @@ -125,6 +125,12 @@ + +

Form LA L-4 - State Income Tax

+ + + +

Form MI-W4 - State Income Tax