Overtime Pay OT_PAY 101 python result = 'OT_HOURS' in inputs code True # Overtime Pay - 1.5x regular hourly rate OT_MULTIPLIER = 1.5 ot_hours = inputs['OT_HOURS'].amount if 'OT_HOURS' in inputs else 0 # Calculate hourly rate from paid amount (assuming semi-monthly ~86.67 hours) hourly_rate = payslip.paid_amount / 86.67 if payslip.paid_amount else 0 result = ot_hours * hourly_rate * OT_MULTIPLIER Stat Holiday Pay STAT_PAY 102 python result = 'STAT_HOURS' in inputs code True # Stat Holiday Pay stat_hours = inputs['STAT_HOURS'].amount if 'STAT_HOURS' in inputs else 0 hourly_rate = payslip.paid_amount / 86.67 if payslip.paid_amount else 0 result = stat_hours * hourly_rate Bonus BONUS_PAY 103 python result = 'BONUS' in inputs code True # Bonus Pay - direct amount from input result = inputs['BONUS'].amount if 'BONUS' in inputs else 0 CPP Employee CPP_EE 150 none code True # CPP Employee Deduction - Using Rule Parameters CPP_RATE = payslip._rule_parameter('ca_cpp_rate') CPP_EXEMPTION = payslip._rule_parameter('ca_cpp_exemption') CPP_MAX = payslip._rule_parameter('ca_cpp_max') PAY_PERIODS = 24 # Semi-monthly exemption_per_period = CPP_EXEMPTION / PAY_PERIODS gross = categories['GROSS'] pensionable = max(0, gross - exemption_per_period) cpp = pensionable * CPP_RATE # YTD check - get year start from datetime import date year_start = date(payslip.date_from.year, 1, 1) ytd = payslip._sum('CPP_EE', year_start, payslip.date_from) or 0 remaining = CPP_MAX + ytd # ytd is negative if remaining <= 0: result = 0 elif cpp > remaining: result = -remaining else: result = -cpp CPP Employer CPP_ER 151 none code True # CPP Employer - 1:1 match with employee result = abs(CPP_EE) if CPP_EE else 0 CPP2 Employee CPP2_EE 152 none code True # CPP2 (Second CPP) - Using Rule Parameters CPP2_RATE = payslip._rule_parameter('ca_cpp2_rate') YMPE = payslip._rule_parameter('ca_ympe') YAMPE = payslip._rule_parameter('ca_yampe') CPP2_MAX = payslip._rule_parameter('ca_cpp2_max') PAY_PERIODS = 24 gross = categories['GROSS'] annual_equiv = gross * PAY_PERIODS result = 0 # CPP2 only on earnings between YMPE and YAMPE if annual_equiv > YMPE: cpp2_base = min(annual_equiv, YAMPE) - YMPE cpp2_per_period = (cpp2_base * CPP2_RATE) / PAY_PERIODS # YTD check from datetime import date year_start = date(payslip.date_from.year, 1, 1) ytd = abs(payslip._sum('CPP2_EE', year_start, payslip.date_from) or 0) remaining = CPP2_MAX - ytd if remaining > 0: result = -min(cpp2_per_period, remaining) CPP2 Employer CPP2_ER 153 none code True # CPP2 Employer - 1:1 match result = abs(CPP2_EE) if CPP2_EE else 0 EI Employee EI_EE 154 none code True # EI Employee - Using Rule Parameters EI_RATE = payslip._rule_parameter('ca_ei_rate') EI_MAX = payslip._rule_parameter('ca_ei_max') gross = categories['GROSS'] ei = gross * EI_RATE # YTD check from datetime import date year_start = date(payslip.date_from.year, 1, 1) ytd = abs(payslip._sum('EI_EE', year_start, payslip.date_from) or 0) remaining = EI_MAX - ytd if remaining <= 0: result = 0 elif ei > remaining: result = -remaining else: result = -ei EI Employer EI_ER 155 none code True # EI Employer - Using Rule Parameter for multiplier EI_ER_MULT = payslip._rule_parameter('ca_ei_employer_mult') result = abs(EI_EE) * EI_ER_MULT if EI_EE else 0 Federal Income Tax FED_TAX 160 none code True # Federal Income Tax - Using Rule Parameters PAY_PERIODS = 24 brackets = payslip._rule_parameter('ca_fed_brackets') BPA = payslip._rule_parameter('ca_fed_bpa') CEA = payslip._rule_parameter('ca_fed_cea') CPP_MAX = payslip._rule_parameter('ca_cpp_max') EI_MAX = payslip._rule_parameter('ca_ei_max') gross = categories['GROSS'] annual = gross * PAY_PERIODS # Calculate tax using brackets tax = 0 prev_threshold = 0 for threshold, rate in brackets: if annual <= threshold: tax += (annual - prev_threshold) * rate break else: tax += (threshold - prev_threshold) * rate prev_threshold = threshold # Basic personal amount credit tax_credit = BPA * brackets[0][1] # Lowest rate # CPP/EI credits cpp_credit = min(abs(CPP_EE) * PAY_PERIODS if CPP_EE else 0, CPP_MAX) * brackets[0][1] ei_credit = min(abs(EI_EE) * PAY_PERIODS if EI_EE else 0, EI_MAX) * brackets[0][1] # Canada Employment Amount credit cea_credit = CEA * brackets[0][1] annual_tax = max(0, tax - tax_credit - cpp_credit - ei_credit - cea_credit) result = -(annual_tax / PAY_PERIODS) Provincial Income Tax PROV_TAX 161 none code True # Ontario Provincial Tax - Using Rule Parameters PAY_PERIODS = 24 brackets = payslip._rule_parameter('ca_on_brackets') BPA_ON = payslip._rule_parameter('ca_on_bpa') CPP_MAX = payslip._rule_parameter('ca_cpp_max') EI_MAX = payslip._rule_parameter('ca_ei_max') gross = categories['GROSS'] annual = gross * PAY_PERIODS # Calculate tax using brackets tax = 0 prev_threshold = 0 for threshold, rate in brackets: if annual <= threshold: tax += (annual - prev_threshold) * rate break else: tax += (threshold - prev_threshold) * rate prev_threshold = threshold # Ontario Basic Personal Amount credit tax_credit = BPA_ON * brackets[0][1] # Lowest rate # CPP/EI credits at lowest rate cpp_credit = min(abs(CPP_EE) * PAY_PERIODS if CPP_EE else 0, CPP_MAX) * brackets[0][1] ei_credit = min(abs(EI_EE) * PAY_PERIODS if EI_EE else 0, EI_MAX) * brackets[0][1] annual_tax = max(0, tax - tax_credit - cpp_credit - ei_credit) result = -(annual_tax / PAY_PERIODS) Vacation Pay VAC_PAY 170 none code True # Vacation Pay - Using Rule Parameter VAC_RATE = payslip._rule_parameter('ca_vacation_rate') result = categories['BASIC'] * VAC_RATE