Basic Pay BASIC 1 none code True result = payslip.paid_amount Overtime Pay OT_PAY 3 python result = (inputs.get('OT_HOURS') and inputs['OT_HOURS'].amount > 0) or (inputs.get('OT') and inputs['OT'].amount > 0) code True if inputs.get('OT_HOURS') and inputs['OT_HOURS'].amount > 0: basic = result_rules.get('BASIC', {}).get('total', 0) hours_per_period = payslip._rule_parameter('ca_standard_hours_per_period') ot_multiplier = payslip._rule_parameter('ca_overtime_multiplier') hourly_rate = basic / hours_per_period if hours_per_period else 0 result = inputs['OT_HOURS'].amount * hourly_rate * ot_multiplier elif inputs.get('OT') and inputs['OT'].amount > 0: result = inputs['OT'].amount else: result = 0 Stat Holiday Pay STAT_PAY 4 python result = inputs.get('STAT_HOURS') and inputs['STAT_HOURS'].amount > 0 code True stat_hours = inputs['STAT_HOURS'].amount if inputs.get('STAT_HOURS') else 0 basic = result_rules.get('BASIC', {}).get('total', 0) hours_per_period = payslip._rule_parameter('ca_standard_hours_per_period') hourly_rate = basic / hours_per_period if hours_per_period else 0 result = stat_hours * hourly_rate Vacation Pay VAC_PAY 5 python result = inputs.get('VAC_PAY') and inputs['VAC_PAY'].amount > 0 code True if inputs.get('VAC_PAY') and inputs['VAC_PAY'].amount > 0: result = round(float(inputs['VAC_PAY'].amount), 2) else: result = 0 Bonus BONUS_PAY 6 python result = 'BONUS' in inputs code True result = inputs['BONUS'].amount if inputs.get('BONUS') else 0 Commission COMMISSION 7 python result = inputs.get('COMMISSION') and inputs['COMMISSION'].amount > 0 code True result = inputs['COMMISSION'].amount if inputs.get('COMMISSION') else 0 Retroactive Pay RETRO_PAY 8 python result = inputs.get('RETRO_PAY') and inputs['RETRO_PAY'].amount > 0 code True result = inputs['RETRO_PAY'].amount if inputs.get('RETRO_PAY') else 0 Shift Premium SHIFT_PREMIUM 9 python result = inputs.get('SHIFT_PREMIUM') and inputs['SHIFT_PREMIUM'].amount > 0 code True result = inputs['SHIFT_PREMIUM'].amount if inputs.get('SHIFT_PREMIUM') else 0 Gross GROSS 10 none code True result = ( result_rules.get('BASIC', {}).get('total', 0) + result_rules.get('OT_PAY', {}).get('total', 0) + result_rules.get('STAT_PAY', {}).get('total', 0) + result_rules.get('VAC_PAY', {}).get('total', 0) + result_rules.get('BONUS_PAY', {}).get('total', 0) + result_rules.get('COMMISSION', {}).get('total', 0) + result_rules.get('RETRO_PAY', {}).get('total', 0) + result_rules.get('SHIFT_PREMIUM', {}).get('total', 0) ) RRSP Deduction RRSP 15 python result = inputs.get('RRSP') and inputs['RRSP'].amount > 0 code True result = -(inputs['RRSP'].amount if inputs.get('RRSP') else 0) Union Dues UNION_DUES 16 python result = inputs.get('UNION') and inputs['UNION'].amount > 0 code True result = -(inputs['UNION'].amount if inputs.get('UNION') else 0) CPP Employee CPP_EE 20 none code True gross_amount = result_rules.get('GROSS', {}).get('total', 0) if employee.exempt_cpp: result = 0 else: cpp_rate = payslip._rule_parameter('ca_cpp_rate') cpp_exemption = payslip._rule_parameter('ca_cpp_exemption') cpp_max = payslip._rule_parameter('ca_cpp_max') ympe = payslip._rule_parameter('ca_ympe') period_exemption = cpp_exemption / 26 period_max = cpp_max / 26 period_ympe = ympe / 26 pensionable = min(gross_amount, period_ympe) pensionable = max(pensionable - period_exemption, 0) result = -min(pensionable * cpp_rate, period_max) CPP Employer CPP_ER 21 none code True result = -result_rules.get('CPP_EE', {}).get('total', 0) CPP2 Employee CPP2_EE 22 none code True gross_amount = result_rules.get('GROSS', {}).get('total', 0) if employee.exempt_cpp: result = 0 else: ympe = payslip._rule_parameter('ca_ympe') cpp2_rate = payslip._rule_parameter('ca_cpp2_rate') yampe = payslip._rule_parameter('ca_yampe') cpp2_max = payslip._rule_parameter('ca_cpp2_max') period_ympe = ympe / 26 period_ceiling = yampe / 26 period_max = cpp2_max / 26 if gross_amount > period_ympe: cpp2_pensionable = min(gross_amount, period_ceiling) - period_ympe result = -min(cpp2_pensionable * cpp2_rate, period_max) else: result = 0 CPP2 Employer CPP2_ER 23 none code True result = -result_rules.get('CPP2_EE', {}).get('total', 0) EI Employee EI_EE 25 none code True gross_amount = result_rules.get('GROSS', {}).get('total', 0) if employee.exempt_ei: result = 0 else: ei_rate = payslip._rule_parameter('ca_ei_rate') ei_max_insurable = payslip._rule_parameter('ca_ei_max_insurable') ei_max = payslip._rule_parameter('ca_ei_max') period_max_insurable = ei_max_insurable / 26 period_max_premium = ei_max / 26 insurable = min(gross_amount, period_max_insurable) result = -min(insurable * ei_rate, period_max_premium) EI Employer EI_ER 26 none code True ei_employer_mult = payslip._rule_parameter('ca_ei_employer_mult') result = -result_rules.get('EI_EE', {}).get('total', 0) * ei_employer_mult Federal Income Tax FED_TAX 30 none code True if hasattr(employee, 'exempt_federal_tax') and employee.exempt_federal_tax: result = 0 else: gross_amount = result_rules.get('GROSS', {}).get('total', 0) rrsp = abs(result_rules.get('RRSP', {}).get('total', 0)) union = abs(result_rules.get('UNION_DUES', {}).get('total', 0)) taxable_per_period = gross_amount - rrsp - union annual_income = taxable_per_period * 26 fed_brackets = [ (payslip._rule_parameter('ca_fed_bracket_1'), payslip._rule_parameter('ca_fed_rate_1')), (payslip._rule_parameter('ca_fed_bracket_2'), payslip._rule_parameter('ca_fed_rate_2')), (payslip._rule_parameter('ca_fed_bracket_3'), payslip._rule_parameter('ca_fed_rate_3')), (payslip._rule_parameter('ca_fed_bracket_4'), payslip._rule_parameter('ca_fed_rate_4')), (float('inf'), payslip._rule_parameter('ca_fed_rate_5')), ] bpa_max = payslip._rule_parameter('ca_fed_bpa') bpa_min = payslip._rule_parameter('ca_fed_bpa_min') cea = payslip._rule_parameter('ca_fed_cea') phase_out_start = payslip._rule_parameter('ca_fed_bracket_3') phase_out_end = payslip._rule_parameter('ca_fed_bracket_4') td1_override = employee.federal_td1_amount if hasattr(employee, 'federal_td1_amount') and employee.federal_td1_amount > 0 else 0 if td1_override: fed_bpa = td1_override elif annual_income <= phase_out_start: fed_bpa = bpa_max elif annual_income >= phase_out_end: fed_bpa = bpa_min else: fed_bpa = bpa_max - (bpa_max - bpa_min) * (annual_income - phase_out_start) / (phase_out_end - phase_out_start) tax = 0 prev_bracket = 0 for bracket, rate in fed_brackets: taxable_in_bracket = min(annual_income, bracket) - prev_bracket if taxable_in_bracket > 0: tax += taxable_in_bracket * rate prev_bracket = bracket if annual_income <= bracket: break credit = fed_bpa * fed_brackets[0][1] cea_credit = cea * fed_brackets[0][1] annual_tax = max(tax - credit - cea_credit, 0) additional = employee.federal_additional_tax or 0 result = -(annual_tax / 26 + additional) Provincial Income Tax PROV_TAX 35 none code True gross_amount = result_rules.get('GROSS', {}).get('total', 0) rrsp = abs(result_rules.get('RRSP', {}).get('total', 0)) union = abs(result_rules.get('UNION_DUES', {}).get('total', 0)) taxable_per_period = gross_amount - rrsp - union annual_income = taxable_per_period * 26 province = employee.home_province or 'ON' if province == 'QC': result = 0 else: PROV = { 'ON': {'b': [[53891, 0.0505], [107785, 0.0915], [150000, 0.1116], [220000, 0.1216], [0, 0.1316]], 'bpa': 12989, 'st': [[5818, 0.20], [7446, 0.36]]}, 'AB': {'b': [[61200, 0.08], [154259, 0.10], [185111, 0.12], [246813, 0.13], [370220, 0.14], [0, 0.15]], 'bpa': 21885, 'st': []}, 'BC': {'b': [[50363, 0.0506], [100728, 0.077], [115648, 0.105], [140430, 0.1229], [190405, 0.147], [265545, 0.168], [0, 0.205]], 'bpa': 12273, 'st': []}, 'SK': {'b': [[54532, 0.105], [155805, 0.125], [0, 0.145]], 'bpa': 18635, 'st': []}, 'MB': {'b': [[47000, 0.108], [100000, 0.1275], [0, 0.174]], 'bpa': 15780, 'st': []}, 'NB': {'b': [[52333, 0.094], [104666, 0.14], [193861, 0.16], [0, 0.195]], 'bpa': 12458, 'st': []}, 'NS': {'b': [[30995, 0.0879], [61991, 0.1495], [97417, 0.1667], [157124, 0.175], [0, 0.21]], 'bpa': 11481, 'st': []}, 'PE': {'b': [[33928, 0.095], [65820, 0.1347], [106890, 0.166], [142250, 0.1762], [0, 0.19]], 'bpa': 12750, 'st': []}, 'NL': {'b': [[44678, 0.087], [89354, 0.145], [159528, 0.158], [223340, 0.178], [285319, 0.198], [570638, 0.208], [1141275, 0.213], [0, 0.218]], 'bpa': 10382, 'st': []}, 'NT': {'b': [[53003, 0.059], [106009, 0.086], [172346, 0.122], [0, 0.1405]], 'bpa': 16442, 'st': []}, 'YT': {'b': [[58523, 0.064], [117045, 0.09], [181440, 0.109], [500000, 0.128], [0, 0.15]], 'bpa': 16729, 'st': []}, 'NU': {'b': [[55801, 0.04], [111602, 0.07], [181439, 0.09], [0, 0.115]], 'bpa': 17091, 'st': []}, } cfg = PROV.get(province, PROV['ON']) prov_brackets = [] for br in cfg['b']: t = br[0] if br[0] != 0 else float('inf') prov_brackets.append((t, br[1])) tax = 0 prev_bracket = 0 for bracket, rate in prov_brackets: taxable_in_bracket = min(annual_income, bracket) - prev_bracket if taxable_in_bracket > 0: tax += taxable_in_bracket * rate prev_bracket = bracket if annual_income <= bracket: break prov_bpa = cfg['bpa'] if employee.provincial_claim_amount and employee.provincial_claim_amount > 0: prov_bpa = employee.provincial_claim_amount prov_credit = prov_bpa * prov_brackets[0][1] basic_provincial_tax = max(tax - prov_credit, 0) surtax = 0 for s in cfg['st']: if basic_provincial_tax > s[0]: surtax += (basic_provincial_tax - s[0]) * s[1] total_provincial_tax = basic_provincial_tax + surtax result = -(total_provincial_tax / 26) Ontario Health Premium OHP 36 python province = employee.home_province or 'ON' result = (province == 'ON') code True gross_amount = result_rules.get('GROSS', {}).get('total', 0) rrsp = abs(result_rules.get('RRSP', {}).get('total', 0)) union = abs(result_rules.get('UNION_DUES', {}).get('total', 0)) taxable_per_period = gross_amount - rrsp - union annual_income = taxable_per_period * 26 ohp = 0 if annual_income <= 20000: ohp = 0 elif annual_income <= 36000: ohp = min((annual_income - 20000) * 0.06, 300) elif annual_income <= 48000: ohp = 300 + min((annual_income - 36000) * 0.06, 150) elif annual_income <= 72000: ohp = 450 + min((annual_income - 48000) * 0.0025, 150) elif annual_income <= 200000: ohp = 600 + min((annual_income - 72000) * 0.0025, 300) else: ohp = 900 result = -(ohp / 26) Net Pay NET 100 none code True result = ( result_rules.get('GROSS', {}).get('total', 0) + result_rules.get('RRSP', {}).get('total', 0) + result_rules.get('UNION_DUES', {}).get('total', 0) + result_rules.get('CPP_EE', {}).get('total', 0) + result_rules.get('CPP2_EE', {}).get('total', 0) + result_rules.get('EI_EE', {}).get('total', 0) + result_rules.get('FED_TAX', {}).get('total', 0) + result_rules.get('PROV_TAX', {}).get('total', 0) + result_rules.get('OHP', {}).get('total', 0) )