From 1d8dfdc3b6e0162690a7a8f5be6b3a5c4c047b9b Mon Sep 17 00:00:00 2001 From: David Frick Date: Wed, 10 Jul 2019 17:45:17 -0400 Subject: [PATCH 1/5] NEW `l10n_us_sc_hr_payroll` for 11.0 --- l10n_us_sc_hr_payroll/__init__.py | 1 + l10n_us_sc_hr_payroll/__manifest__.py | 27 ++++ l10n_us_sc_hr_payroll/data/base.xml | 45 ++++++ l10n_us_sc_hr_payroll/data/final.xml | 17 +++ l10n_us_sc_hr_payroll/data/rates.xml | 12 ++ l10n_us_sc_hr_payroll/data/rules.xml | 64 +++++++++ l10n_us_sc_hr_payroll/tests/__init__.py | 1 + .../tests/test_us_sc_payslip_2019.py | 135 ++++++++++++++++++ .../views/hr_payroll_views.xml | 21 +++ 9 files changed, 323 insertions(+) create mode 100644 l10n_us_sc_hr_payroll/__init__.py create mode 100644 l10n_us_sc_hr_payroll/__manifest__.py create mode 100644 l10n_us_sc_hr_payroll/data/base.xml create mode 100644 l10n_us_sc_hr_payroll/data/final.xml create mode 100644 l10n_us_sc_hr_payroll/data/rates.xml create mode 100644 l10n_us_sc_hr_payroll/data/rules.xml create mode 100644 l10n_us_sc_hr_payroll/tests/__init__.py create mode 100644 l10n_us_sc_hr_payroll/tests/test_us_sc_payslip_2019.py create mode 100644 l10n_us_sc_hr_payroll/views/hr_payroll_views.xml diff --git a/l10n_us_sc_hr_payroll/__init__.py b/l10n_us_sc_hr_payroll/__init__.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/l10n_us_sc_hr_payroll/__init__.py @@ -0,0 +1 @@ + diff --git a/l10n_us_sc_hr_payroll/__manifest__.py b/l10n_us_sc_hr_payroll/__manifest__.py new file mode 100644 index 00000000..9babd21d --- /dev/null +++ b/l10n_us_sc_hr_payroll/__manifest__.py @@ -0,0 +1,27 @@ +{ + 'name': 'USA - South Carolina - Payroll', + 'author': 'Hibou Corp. ', + 'license': 'AGPL-3', + 'category': 'Localization', + 'depends': ['l10n_us_hr_payroll'], + 'version': '11.0.2019.0.0', + 'description': """ +USA::South Carolina Payroll Rules. +================================== +* Added Tax Rules, Salary Structure, and other tax related changes for South Carolina +* Contribution register and partner for South Carolina Department of Revenue +* Contribution register and partner for South Carolina Department of Employment and Workforce +* Rate for Unemployment with wage cap + """, + + 'auto_install': False, + 'website': 'https://hibou.io/', + 'data': [ + 'views/hr_payroll_views.xml', + 'data/base.xml', + 'data/rates.xml', + 'data/rules.xml', + 'data/final.xml', + ], + 'installable': True +} diff --git a/l10n_us_sc_hr_payroll/data/base.xml b/l10n_us_sc_hr_payroll/data/base.xml new file mode 100644 index 00000000..484a447a --- /dev/null +++ b/l10n_us_sc_hr_payroll/data/base.xml @@ -0,0 +1,45 @@ + + + + + + South Carolina Department of Employment and Workforce - Unemployment Tax + 1 + + + + South Carolina Department of Revenue - Income Tax Withholding + 1 + + + + South Carolina Unemployment + South Carolina Department of Employment and Workforce - Unemployment + + + + South Carolina Income Tax Withholding + South Carolina Department of Revenue - Income Tax Withholding + + + + + + + Wage: US-SC Unemployment + WAGE_US_SC_UNEMP + + + + ER: US-SC Unemployment + ER_US_SC_UNEMP + + + + + EE: US-SC Income Tax Withholding + EE_US_SC_INC_WITHHOLD + + + + diff --git a/l10n_us_sc_hr_payroll/data/final.xml b/l10n_us_sc_hr_payroll/data/final.xml new file mode 100644 index 00000000..ff8839e3 --- /dev/null +++ b/l10n_us_sc_hr_payroll/data/final.xml @@ -0,0 +1,17 @@ + + + + + + US_SC_EMP + USA South Carolina Employee + + + + + + diff --git a/l10n_us_sc_hr_payroll/data/rates.xml b/l10n_us_sc_hr_payroll/data/rates.xml new file mode 100644 index 00000000..da243541 --- /dev/null +++ b/l10n_us_sc_hr_payroll/data/rates.xml @@ -0,0 +1,12 @@ + + + + + US SS Unemployment + US_SC_UNEMP + 1.09 + 2019-01-01 + + + + diff --git a/l10n_us_sc_hr_payroll/data/rules.xml b/l10n_us_sc_hr_payroll/data/rules.xml new file mode 100644 index 00000000..5a057a92 --- /dev/null +++ b/l10n_us_sc_hr_payroll/data/rules.xml @@ -0,0 +1,64 @@ + + + + + + + + Wage: US-SC Unemployment + WAGE_US_SC_UNEMP + python + result = (contract.futa_type != contract.FUTA_TYPE_BASIC) + code + +rate = payslip.dict.get_rate('US_SC_UNEMP') +year = int(payslip.dict.date_to[:4]) +ytd = payslip.sum('WAGE_US_SC_UNEMP', str(year) + '-01-01', str(year+1) + '-01-01') +ytd += contract.external_wages +remaining = rate.wage_limit_year - ytd +if remaining <= 0.0: + result = 0 +elif remaining < categories.BASIC: + result = remaining +else: + result = categories.BASIC + + + + + + + + ER: US-SC Unemployment + ER_US_SC_UNEMP + python + result = (contract.futa_type != contract.FUTA_TYPE_BASIC) + code + +rate = payslip.dict.get_rate('US_SC_UNEMP') +result_rate = -rate.rate +result = categories.WAGE_US_SC_UNEMP + +# result_rate of 0 implies 100% due to bug +if result_rate == 0.0: + result = 0.0 + + + + + + + + + EE: US-SC Income Tax Withholding + EE_US_SC_INC_WITHHOLD + python + result = True + code + +result = categories.EE_US_FED_INC_WITHHOLD + + + + + diff --git a/l10n_us_sc_hr_payroll/tests/__init__.py b/l10n_us_sc_hr_payroll/tests/__init__.py new file mode 100644 index 00000000..51e630dc --- /dev/null +++ b/l10n_us_sc_hr_payroll/tests/__init__.py @@ -0,0 +1 @@ +from . import test_us_sc_payslip_2019 diff --git a/l10n_us_sc_hr_payroll/tests/test_us_sc_payslip_2019.py b/l10n_us_sc_hr_payroll/tests/test_us_sc_payslip_2019.py new file mode 100644 index 00000000..06874b93 --- /dev/null +++ b/l10n_us_sc_hr_payroll/tests/test_us_sc_payslip_2019.py @@ -0,0 +1,135 @@ +from odoo.addons.l10n_us_hr_payroll.tests.test_us_payslip import TestUsPayslip, process_payslip +from odoo.addons.l10n_us_hr_payroll.models.l10n_us_hr_payroll import USHrContract + + +class TestUsSCPayslip(TestUsPayslip): + ### + # Taxes and Rates + ### + SC_UNEMP_MAX_WAGE = 14000.0 + US_SC_UNEMP = -1.09 / 100 + + def test_2019_taxes(self): + salary = 10000 + exemptions = 2 + + employee = self._createEmployee() + contract = self._createContract(employee, salary, + struct_id=self.ref('l10n_us_sc_hr_payroll.hr_payroll_salary_structure_us_sc_employee')) + contract.w4_allowances = exemptions + + self._log('2019 South Carolina tax first payslip:') + payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31') + payslip.compute_sheet() + cats = self._getCategories(payslip) + + self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], salary) + self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], cats['WAGE_US_SC_UNEMP'] * self.US_SC_UNEMP) + self.assertPayrollEqual(cats['EE_US_SC_INC_WITHHOLD'], cats['EE_US_FED_INC_WITHHOLD']) + + process_payslip(payslip) + + remaining_SC_UNEMP_wages = self.SC_UNEMP_MAX_WAGE - salary if (self.SC_UNEMP_MAX_WAGE - 2*salary < salary) \ + else salary + + # Testing Additional Income Tax Withholding + self._log('2019 South Carolina tax second payslip:') + additional_wh = 40.0 + contract.w4_additional_withholding = additional_wh + original_witholding = cats['EE_US_SC_INC_WITHHOLD'] + payslip = self._createPayslip(employee, '2019-02-01', '2019-02-28') + payslip.compute_sheet() + cats = self._getCategories(payslip) + + self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], remaining_SC_UNEMP_wages) + self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], remaining_SC_UNEMP_wages * self.US_SC_UNEMP) + self.assertPayrollEqual(cats['EE_US_SC_INC_WITHHOLD'], original_witholding - additional_wh) + + def test_2019_taxes_with_external(self): + salary = 5000.0 + external_wages = 30000.0 + + employee = self._createEmployee() + contract = self._createContract(employee, salary, external_wages=external_wages, + struct_id=self.ref('l10n_us_sc_hr_payroll.hr_payroll_salary_structure_us_sc_employee')) + + self._log('2019 South Carolina_external tax first payslip:') + payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31') + payslip.compute_sheet() + cats = self._getCategories(payslip) + + self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], 0) + self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], cats['WAGE_US_SC_UNEMP'] * self.US_SC_UNEMP) + + def test_2019_taxes_filing_status(self): + salary = 4000.0 + w4_filing_status = 'married' + + allowances = 1 + + employee = self._createEmployee() + contract = self._createContract(employee, salary, struct_id=self.ref( + 'l10n_us_sc_hr_payroll.hr_payroll_salary_structure_us_sc_employee')) + contract.w4_allowances = allowances + contract.w4_filing_status = w4_filing_status + + self._log('2019 South Carolina tax first payslip: ') + payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31') + payslip.compute_sheet() + cats = self._getCategories(payslip) + + self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], salary) + self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], cats['WAGE_US_SC_UNEMP'] * self.US_SC_UNEMP) + self.assertPayrollEqual(cats['EE_US_SC_INC_WITHHOLD'], cats['EE_US_FED_INC_WITHHOLD']) + + process_payslip(payslip) + + # Create a 2nd payslip + remaining_SC_UNEMP_wages = self.SC_UNEMP_MAX_WAGE - salary if (self.SC_UNEMP_MAX_WAGE - 2*salary < salary) \ + else salary + + self._log('2019 South Carolina tax second payslip:') + payslip = self._createPayslip(employee, '2019-02-01', '2019-02-28') + payslip.compute_sheet() + cats = self._getCategories(payslip) + + self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], remaining_SC_UNEMP_wages) + self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], remaining_SC_UNEMP_wages * self.US_SC_UNEMP) + + def test_additional_withholding(self): + salary = 4000.0 + additional_wh = 40.0 + allowances = 1 + + employee = self._createEmployee() + contract = self._createContract(employee, + salary, + struct_id=self.ref('l10n_us_sc_hr_payroll.hr_payroll_salary_structure_us_sc_employee') + ) + contract.w4_addition_withholding = additional_wh + contract.w4_allowances = allowances + + + self._log('2019 South Carolina tax first payslip: ') + payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31') + payslip.compute_sheet() + cats = self._getCategories(payslip) + + self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], salary) + self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], cats['WAGE_US_SC_UNEMP'] * self.US_SC_UNEMP) + self.assertPayrollEqual(cats['EE_US_SC_INC_WITHHOLD'], cats['EE_US_FED_INC_WITHHOLD']) + + process_payslip(payslip) + + # Make a new payslip, this one will have maximums + remaining_SC_UNEMP_wages = self.SC_UNEMP_MAX_WAGE - salary if (self.SC_UNEMP_MAX_WAGE - 2 * salary < salary) \ + else salary + + self._log('2019 South Carolina tax second payslip weekly:') + payslip = self._createPayslip(employee, '2019-02-01', '2019-02-28') + + payslip.compute_sheet() + cats = self._getCategories(payslip) + + self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], remaining_SC_UNEMP_wages) + self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], remaining_SC_UNEMP_wages * self.US_SC_UNEMP) diff --git a/l10n_us_sc_hr_payroll/views/hr_payroll_views.xml b/l10n_us_sc_hr_payroll/views/hr_payroll_views.xml new file mode 100644 index 00000000..0f75c3bc --- /dev/null +++ b/l10n_us_sc_hr_payroll/views/hr_payroll_views.xml @@ -0,0 +1,21 @@ + + + + + hr.contract.form.inherit + hr.contract + 151 + + + + + +

No additional fields.

+
+
+
+
+
+ +
+ From b50f9ce39a2dad865559511a9cac233e639570bd Mon Sep 17 00:00:00 2001 From: David Frick Date: Thu, 11 Jul 2019 13:30:11 -0400 Subject: [PATCH 2/5] IMP `l10n_us_sc_hr_payroll` changed register names and partner names to be more readable with state name. --- l10n_us_sc_hr_payroll/data/base.xml | 12 ++++++------ l10n_us_sc_hr_payroll/data/rules.xml | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/l10n_us_sc_hr_payroll/data/base.xml b/l10n_us_sc_hr_payroll/data/base.xml index 484a447a..88e83c59 100644 --- a/l10n_us_sc_hr_payroll/data/base.xml +++ b/l10n_us_sc_hr_payroll/data/base.xml @@ -2,25 +2,25 @@ - + South Carolina Department of Employment and Workforce - Unemployment Tax 1 - + South Carolina Department of Revenue - Income Tax Withholding 1 - + South Carolina Unemployment South Carolina Department of Employment and Workforce - Unemployment - + - + South Carolina Income Tax Withholding South Carolina Department of Revenue - Income Tax Withholding - + diff --git a/l10n_us_sc_hr_payroll/data/rules.xml b/l10n_us_sc_hr_payroll/data/rules.xml index 5a057a92..95a63a90 100644 --- a/l10n_us_sc_hr_payroll/data/rules.xml +++ b/l10n_us_sc_hr_payroll/data/rules.xml @@ -43,7 +43,7 @@ result = categories.WAGE_US_SC_UNEMP if result_rate == 0.0: result = 0.0 - + @@ -58,7 +58,7 @@ if result_rate == 0.0: result = categories.EE_US_FED_INC_WITHHOLD - + From afc7385a398753da0da2aaf38a5f6a235d964760 Mon Sep 17 00:00:00 2001 From: David Frick Date: Thu, 11 Jul 2019 16:50:32 -0400 Subject: [PATCH 3/5] IMP `l10n_us_sc_hr_payroll` spelling check in final lookover. --- l10n_us_sc_hr_payroll/data/rates.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l10n_us_sc_hr_payroll/data/rates.xml b/l10n_us_sc_hr_payroll/data/rates.xml index da243541..61deba54 100644 --- a/l10n_us_sc_hr_payroll/data/rates.xml +++ b/l10n_us_sc_hr_payroll/data/rates.xml @@ -2,7 +2,7 @@ - US SS Unemployment + US SC Unemployment US_SC_UNEMP 1.09 2019-01-01 From 0136ef69cf17462a1ab93e6debee0f20a57b08c0 Mon Sep 17 00:00:00 2001 From: David Frick Date: Wed, 17 Jul 2019 13:21:53 -0400 Subject: [PATCH 4/5] FIX `l10n_us_sc_hr_payroll` income withholding rule and refactored tests for it. --- l10n_us_sc_hr_payroll/data/rules.xml | 48 ++++++- .../tests/test_us_sc_payslip_2019.py | 118 ++++++++---------- 2 files changed, 102 insertions(+), 64 deletions(-) diff --git a/l10n_us_sc_hr_payroll/data/rules.xml b/l10n_us_sc_hr_payroll/data/rules.xml index 95a63a90..eaa9f1f7 100644 --- a/l10n_us_sc_hr_payroll/data/rules.xml +++ b/l10n_us_sc_hr_payroll/data/rules.xml @@ -56,7 +56,53 @@ if result_rate == 0.0: result = True code -result = categories.EE_US_FED_INC_WITHHOLD +wages = categories.GROSS # Must make sure sequence is after the GROSS sequence. +# Step 1 - Convert wages to annual amount +pay_period = 0.0 +pay_periods = { + 'weekly': 52.0, + 'bi-weekly': 26.0, + 'semi-monthly': 24.0, + 'monthly': 12.0 + } +schedule_pay = contract.schedule_pay +pay_period = pay_periods[schedule_pay] +annual_wages = wages * pay_period + +# Step 2 - Deduct the personal exemption amount and standard deduction from the annual wages. +sc_exemption_amount = 2510.00 +personal_exemption_amt = contract.w4_allowances * sc_exemption_amount +standard_deduction = 0.00 +if contract.w4_allowances > 0: + if annual_wages > 3470.00: + standard_deduction = (10.0 / 100.0) * 3470.00 + else: + standard_deduction = (10.0 / 100.0) * annual_wages +taxable_income = annual_wages - personal_exemption_amt - standard_deduction + +# Step 3 - Use the balance (taxable_income) in the tables listed on the state pdf: +# https://dor.sc.gov/forms-site/Forms/WH1603F_2019.pdf +# to calculate the tax. + +tax_table = [ + (2450, 1.1, 0.0), + (4900, 3.0, 26.95), + (7350, 4.0, 100.45), + (9800, 5.0, 198.45), + (12250, 6.0, 320.95), + (float('inf'), 7.0, 467.95) + ] +last = 0.0 +for cap, rate, flat_amt in tax_table: + if cap > taxable_income: + result = ((taxable_income - last) * (rate / 100.0)) + flat_amt + break + last = cap + +# Step 4 - Divide the result by the number of pay periods to get withholding amount per pay period +result = (result / pay_period) + +result = -result diff --git a/l10n_us_sc_hr_payroll/tests/test_us_sc_payslip_2019.py b/l10n_us_sc_hr_payroll/tests/test_us_sc_payslip_2019.py index 06874b93..a7457dd3 100644 --- a/l10n_us_sc_hr_payroll/tests/test_us_sc_payslip_2019.py +++ b/l10n_us_sc_hr_payroll/tests/test_us_sc_payslip_2019.py @@ -3,19 +3,39 @@ from odoo.addons.l10n_us_hr_payroll.models.l10n_us_hr_payroll import USHrContrac class TestUsSCPayslip(TestUsPayslip): - ### + # Taxes and Rates - ### SC_UNEMP_MAX_WAGE = 14000.0 US_SC_UNEMP = -1.09 / 100 + US_SC_exemption_amount = 2510.00 - def test_2019_taxes(self): - salary = 10000 + def test_2019_taxes_weekly(self): + # We will hand calculate the amount to test for state withholding. + schedule_pay = 'weekly' + salary = 50000.00 # Employee is paid 50000 per week to be in top tax bracket exemptions = 2 + # Calculate annual wages + annual = 50000 * 52.0 + # From our annual we deduct personal exemption amounts. + # We deduct 2510.00 per exemption. Since we have two exemptions: + personal_exemption = self.US_SC_exemption_amount * exemptions # 5020.0 + # From annual, we will also deduct a standard_deduction of 10% up to 3470.00 if 1 or more exemptions + standard_deduction = (10.0 / 100.0) * 3470.00 + taxable_income = annual - personal_exemption - standard_deduction # 2594633.0 + # We then calculate the amounts off the SC tax pdf tables. + # 2594633.0 is in the highest bracket + test_amt = ((taxable_income - 12250) * (7.0 / 100.0)) + 467.95 + # test_amt = 181234.76000000004 + # Make it per period then negative + test_amt = (test_amt / 52.0) # Divided by 52 since it is weekly. + # test_amt = 3485.2838461538468 + test_amt = -test_amt employee = self._createEmployee() - contract = self._createContract(employee, salary, - struct_id=self.ref('l10n_us_sc_hr_payroll.hr_payroll_salary_structure_us_sc_employee')) + contract = self._createContract(employee, + salary, + struct_id=self.ref('l10n_us_sc_hr_payroll.hr_payroll_salary_structure_us_sc_employee'), + schedule_pay=schedule_pay) contract.w4_allowances = exemptions self._log('2019 South Carolina tax first payslip:') @@ -23,34 +43,32 @@ class TestUsSCPayslip(TestUsPayslip): payslip.compute_sheet() cats = self._getCategories(payslip) - self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], salary) + self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], self.SC_UNEMP_MAX_WAGE) self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], cats['WAGE_US_SC_UNEMP'] * self.US_SC_UNEMP) - self.assertPayrollEqual(cats['EE_US_SC_INC_WITHHOLD'], cats['EE_US_FED_INC_WITHHOLD']) + self.assertPayrollEqual(cats['EE_US_SC_INC_WITHHOLD'], test_amt) process_payslip(payslip) - remaining_SC_UNEMP_wages = self.SC_UNEMP_MAX_WAGE - salary if (self.SC_UNEMP_MAX_WAGE - 2*salary < salary) \ - else salary + remaining_SC_UNEMP_wages = self.SC_UNEMP_MAX_WAGE - annual if (annual < self.SC_UNEMP_MAX_WAGE) \ + else 0.00 - # Testing Additional Income Tax Withholding self._log('2019 South Carolina tax second payslip:') - additional_wh = 40.0 - contract.w4_additional_withholding = additional_wh - original_witholding = cats['EE_US_SC_INC_WITHHOLD'] + payslip = self._createPayslip(employee, '2019-02-01', '2019-02-28') payslip.compute_sheet() cats = self._getCategories(payslip) - self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], remaining_SC_UNEMP_wages) + self.assertEqual(0.0, remaining_SC_UNEMP_wages) self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], remaining_SC_UNEMP_wages * self.US_SC_UNEMP) - self.assertPayrollEqual(cats['EE_US_SC_INC_WITHHOLD'], original_witholding - additional_wh) def test_2019_taxes_with_external(self): salary = 5000.0 external_wages = 30000.0 employee = self._createEmployee() - contract = self._createContract(employee, salary, external_wages=external_wages, + contract = self._createContract(employee, + salary, + external_wages=external_wages, struct_id=self.ref('l10n_us_sc_hr_payroll.hr_payroll_salary_structure_us_sc_employee')) self._log('2019 South Carolina_external tax first payslip:') @@ -62,14 +80,25 @@ class TestUsSCPayslip(TestUsPayslip): self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], cats['WAGE_US_SC_UNEMP'] * self.US_SC_UNEMP) def test_2019_taxes_filing_status(self): - salary = 4000.0 + salary = 20000.00 # Wages per pay period + schedule_pay = 'monthly' + annual = salary * 12 w4_filing_status = 'married' - allowances = 1 + # Hand Calculations + personal_exemption = 2510.00 + standard_deduction = (10.0 / 100.0) * 3470.00 + taxable = annual - personal_exemption - standard_deduction + # taxable = 237143.0 + test_amt = ((taxable - 12250) * (7.0 / 100.0)) + 467.95 # 16210.460000000003 + test_amt = test_amt / 12.0 # Put it into monthly -> 1350.871666666667 + # Make it negative + test_amt = -test_amt employee = self._createEmployee() - contract = self._createContract(employee, salary, struct_id=self.ref( - 'l10n_us_sc_hr_payroll.hr_payroll_salary_structure_us_sc_employee')) + contract = self._createContract(employee, + salary, + struct_id=self.ref('l10n_us_sc_hr_payroll.hr_payroll_salary_structure_us_sc_employee')) contract.w4_allowances = allowances contract.w4_filing_status = w4_filing_status @@ -78,58 +107,21 @@ class TestUsSCPayslip(TestUsPayslip): payslip.compute_sheet() cats = self._getCategories(payslip) - self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], salary) + self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], self.SC_UNEMP_MAX_WAGE) self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], cats['WAGE_US_SC_UNEMP'] * self.US_SC_UNEMP) - self.assertPayrollEqual(cats['EE_US_SC_INC_WITHHOLD'], cats['EE_US_FED_INC_WITHHOLD']) + self.assertPayrollEqual(cats['EE_US_SC_INC_WITHHOLD'], test_amt) process_payslip(payslip) # Create a 2nd payslip - remaining_SC_UNEMP_wages = self.SC_UNEMP_MAX_WAGE - salary if (self.SC_UNEMP_MAX_WAGE - 2*salary < salary) \ - else salary + remaining_SC_UNEMP_wages = self.SC_UNEMP_MAX_WAGE - salary if (salary < self.SC_UNEMP_MAX_WAGE) \ + else 0.00 self._log('2019 South Carolina tax second payslip:') payslip = self._createPayslip(employee, '2019-02-01', '2019-02-28') payslip.compute_sheet() cats = self._getCategories(payslip) - self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], remaining_SC_UNEMP_wages) + self.assertEqual(0.0, remaining_SC_UNEMP_wages) self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], remaining_SC_UNEMP_wages * self.US_SC_UNEMP) - def test_additional_withholding(self): - salary = 4000.0 - additional_wh = 40.0 - allowances = 1 - - employee = self._createEmployee() - contract = self._createContract(employee, - salary, - struct_id=self.ref('l10n_us_sc_hr_payroll.hr_payroll_salary_structure_us_sc_employee') - ) - contract.w4_addition_withholding = additional_wh - contract.w4_allowances = allowances - - - self._log('2019 South Carolina tax first payslip: ') - payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31') - payslip.compute_sheet() - cats = self._getCategories(payslip) - - self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], salary) - self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], cats['WAGE_US_SC_UNEMP'] * self.US_SC_UNEMP) - self.assertPayrollEqual(cats['EE_US_SC_INC_WITHHOLD'], cats['EE_US_FED_INC_WITHHOLD']) - - process_payslip(payslip) - - # Make a new payslip, this one will have maximums - remaining_SC_UNEMP_wages = self.SC_UNEMP_MAX_WAGE - salary if (self.SC_UNEMP_MAX_WAGE - 2 * salary < salary) \ - else salary - - self._log('2019 South Carolina tax second payslip weekly:') - payslip = self._createPayslip(employee, '2019-02-01', '2019-02-28') - - payslip.compute_sheet() - cats = self._getCategories(payslip) - - self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], remaining_SC_UNEMP_wages) - self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], remaining_SC_UNEMP_wages * self.US_SC_UNEMP) From f10b4011f0c73c3e24fc74106a4aac34a352ed6b Mon Sep 17 00:00:00 2001 From: David Frick Date: Thu, 18 Jul 2019 11:58:23 -0400 Subject: [PATCH 5/5] FIX `l10n_us_sc_hr_payroll` South Carolina standard deduction calculation amount. --- l10n_us_sc_hr_payroll/data/rules.xml | 4 ++-- .../tests/test_us_sc_payslip_2019.py | 21 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/l10n_us_sc_hr_payroll/data/rules.xml b/l10n_us_sc_hr_payroll/data/rules.xml index eaa9f1f7..a2ba63c8 100644 --- a/l10n_us_sc_hr_payroll/data/rules.xml +++ b/l10n_us_sc_hr_payroll/data/rules.xml @@ -74,8 +74,8 @@ sc_exemption_amount = 2510.00 personal_exemption_amt = contract.w4_allowances * sc_exemption_amount standard_deduction = 0.00 if contract.w4_allowances > 0: - if annual_wages > 3470.00: - standard_deduction = (10.0 / 100.0) * 3470.00 + if (annual_wages * .1) > 3470.00: + standard_deduction = 3470.00 else: standard_deduction = (10.0 / 100.0) * annual_wages taxable_income = annual_wages - personal_exemption_amt - standard_deduction diff --git a/l10n_us_sc_hr_payroll/tests/test_us_sc_payslip_2019.py b/l10n_us_sc_hr_payroll/tests/test_us_sc_payslip_2019.py index a7457dd3..f018cdd3 100644 --- a/l10n_us_sc_hr_payroll/tests/test_us_sc_payslip_2019.py +++ b/l10n_us_sc_hr_payroll/tests/test_us_sc_payslip_2019.py @@ -19,16 +19,17 @@ class TestUsSCPayslip(TestUsPayslip): # From our annual we deduct personal exemption amounts. # We deduct 2510.00 per exemption. Since we have two exemptions: personal_exemption = self.US_SC_exemption_amount * exemptions # 5020.0 - # From annual, we will also deduct a standard_deduction of 10% up to 3470.00 if 1 or more exemptions - standard_deduction = (10.0 / 100.0) * 3470.00 - taxable_income = annual - personal_exemption - standard_deduction # 2594633.0 + # From annual, we will also deduct a standard_deduction of 3470.00 or .1 of salary, which ever + # is small -> if 1 or more exemptions, else 0 + standard_deduction = 3470.00 + taxable_income = annual - personal_exemption - standard_deduction # 2591478.0 # We then calculate the amounts off the SC tax pdf tables. - # 2594633.0 is in the highest bracket + # 2591478.0 is in the highest bracket test_amt = ((taxable_income - 12250) * (7.0 / 100.0)) + 467.95 - # test_amt = 181234.76000000004 + # test_amt = 181013.91000000003 # Make it per period then negative test_amt = (test_amt / 52.0) # Divided by 52 since it is weekly. - # test_amt = 3485.2838461538468 + # test_amt = 3481.0367307692313 test_amt = -test_amt employee = self._createEmployee() @@ -87,11 +88,11 @@ class TestUsSCPayslip(TestUsPayslip): allowances = 1 # Hand Calculations personal_exemption = 2510.00 - standard_deduction = (10.0 / 100.0) * 3470.00 + standard_deduction = min(3470.00, .1 * annual) # 3470.0 but min is shown for the process taxable = annual - personal_exemption - standard_deduction - # taxable = 237143.0 - test_amt = ((taxable - 12250) * (7.0 / 100.0)) + 467.95 # 16210.460000000003 - test_amt = test_amt / 12.0 # Put it into monthly -> 1350.871666666667 + # taxable = 234020 + test_amt = ((taxable - 12250) * (7.0 / 100.0)) + 467.95 # 15991.850000000002 + test_amt = test_amt / 12.0 # Put it into monthly -> 1332.654166666667 # Make it negative test_amt = -test_amt