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..88e83c59 --- /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..61deba54 --- /dev/null +++ b/l10n_us_sc_hr_payroll/data/rates.xml @@ -0,0 +1,12 @@ + + + + + US SC 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..a2ba63c8 --- /dev/null +++ b/l10n_us_sc_hr_payroll/data/rules.xml @@ -0,0 +1,110 @@ + + + + + + + + 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 + +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 * .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 + +# 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/__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..f018cdd3 --- /dev/null +++ b/l10n_us_sc_hr_payroll/tests/test_us_sc_payslip_2019.py @@ -0,0 +1,128 @@ +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 + US_SC_exemption_amount = 2510.00 + + 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 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. + # 2591478.0 is in the highest bracket + test_amt = ((taxable_income - 12250) * (7.0 / 100.0)) + 467.95 + # 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 = 3481.0367307692313 + 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'), + schedule_pay=schedule_pay) + 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'], 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'], test_amt) + + process_payslip(payslip) + + remaining_SC_UNEMP_wages = self.SC_UNEMP_MAX_WAGE - annual if (annual < 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.assertEqual(0.0, remaining_SC_UNEMP_wages) + self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], remaining_SC_UNEMP_wages * self.US_SC_UNEMP) + + 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 = 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 = min(3470.00, .1 * annual) # 3470.0 but min is shown for the process + taxable = annual - personal_exemption - standard_deduction + # 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 + + 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'], 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'], test_amt) + + process_payslip(payslip) + + # Create a 2nd payslip + 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.assertEqual(0.0, 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.

+
+
+
+
+
+ +
+