changes
This commit is contained in:
@@ -358,38 +358,40 @@ class PayrollCheque(models.Model):
|
||||
get_ytd_amount('GROSS') or 0)
|
||||
|
||||
# Get vacation pay
|
||||
vacation_pay_current = get_line_amount('VAC') or get_line_amount('VACATION') or 0
|
||||
vacation_pay_ytd = get_ytd_amount('VAC') or get_ytd_amount('VACATION') or 0
|
||||
vacation_pay_current = get_line_amount('VAC_PAY') or 0
|
||||
vacation_pay_ytd = get_ytd_amount('VAC_PAY') or 0
|
||||
|
||||
# Get stat holiday pay
|
||||
stat_pay_current = get_line_amount('STAT') or get_line_amount('STATHOLIDAY') or 0
|
||||
stat_pay_ytd = get_ytd_amount('STAT') or get_ytd_amount('STATHOLIDAY') or 0
|
||||
stat_pay_current = get_line_amount('STAT_PAY') or 0
|
||||
stat_pay_ytd = get_ytd_amount('STAT_PAY') or 0
|
||||
|
||||
# Get taxes - these are negative in payslip, so use abs()
|
||||
# First try to get from payslip lines
|
||||
income_tax_current = abs(get_line_amount('FIT') or get_line_amount('INCOMETAX') or 0)
|
||||
ei_current = abs(get_line_amount('EI_EMP') or get_line_amount('EI') or 0)
|
||||
cpp_current = abs(get_line_amount('CPP_EMP') or get_line_amount('CPP') or 0)
|
||||
cpp2_current = abs(get_line_amount('CPP2_EMP') or get_line_amount('CPP2') or 0)
|
||||
fed_tax_current = abs(get_line_amount('FED_TAX') or 0)
|
||||
prov_tax_current = abs(get_line_amount('PROV_TAX') or 0)
|
||||
ohp_current = abs(get_line_amount('OHP') or 0)
|
||||
income_tax_current = fed_tax_current + prov_tax_current + ohp_current
|
||||
ei_current = abs(get_line_amount('EI_EE') or 0)
|
||||
cpp_current = abs(get_line_amount('CPP_EE') or 0)
|
||||
cpp2_current = abs(get_line_amount('CPP2_EE') or 0)
|
||||
|
||||
# If individual line values are 0, calculate from payslip totals
|
||||
total_taxes_from_lines = income_tax_current + ei_current + cpp_current + cpp2_current
|
||||
if total_taxes_from_lines == 0 and payslip.basic_wage > 0 and payslip.net_wage > 0:
|
||||
# Calculate total taxes as difference between basic and net
|
||||
total_taxes_calculated = payslip.basic_wage - payslip.net_wage
|
||||
if total_taxes_calculated > 0:
|
||||
# Approximate breakdown based on typical Canadian tax rates
|
||||
# CPP ~5.95%, EI ~1.63%, Income Tax = remainder
|
||||
gross = payslip.basic_wage
|
||||
cpp_current = min(gross * 0.0595, 3867.50) # 2025 CPP max
|
||||
ei_current = min(gross * 0.0163, 1049.12) # 2025 EI max
|
||||
cpp_current = min(gross * 0.0595, 4230.45 / 26)
|
||||
ei_current = min(gross * 0.0163, 1123.07 / 26)
|
||||
income_tax_current = max(0, total_taxes_calculated - cpp_current - ei_current)
|
||||
cpp2_current = 0 # Usually 0 unless over threshold
|
||||
cpp2_current = 0
|
||||
|
||||
income_tax_ytd = abs(get_ytd_amount('FIT') or get_ytd_amount('INCOMETAX') or 0)
|
||||
ei_ytd = abs(get_ytd_amount('EI_EMP') or get_ytd_amount('EI') or 0)
|
||||
cpp_ytd = abs(get_ytd_amount('CPP_EMP') or get_ytd_amount('CPP') or 0)
|
||||
cpp2_ytd = abs(get_ytd_amount('CPP2_EMP') or get_ytd_amount('CPP2') or 0)
|
||||
fed_tax_ytd = abs(get_ytd_amount('FED_TAX') or 0)
|
||||
prov_tax_ytd = abs(get_ytd_amount('PROV_TAX') or 0)
|
||||
ohp_ytd = abs(get_ytd_amount('OHP') or 0)
|
||||
income_tax_ytd = fed_tax_ytd + prov_tax_ytd + ohp_ytd
|
||||
ei_ytd = abs(get_ytd_amount('EI_EE') or 0)
|
||||
cpp_ytd = abs(get_ytd_amount('CPP_EE') or 0)
|
||||
cpp2_ytd = abs(get_ytd_amount('CPP2_EE') or 0)
|
||||
|
||||
# Calculate totals
|
||||
total_taxes_current = income_tax_current + ei_current + cpp_current + cpp2_current
|
||||
|
||||
Reference in New Issue
Block a user