# Fusion Payroll - Canada
## Reverse Engineered from: pragmatic_odoo_canada_payroll

**Extraction Date**: 2024-12-31  
**Target Base**: Odoo Enterprise hr_payroll  
**Original Module**: pragmatic_odoo_canada_payroll (90 external identifiers)

---

## Module Summary

### What Was Extracted

| Component | Count | Status |
|-----------|-------|--------|
| New Models | 2 | ✅ Complete |
| Extended Models | 2 | ✅ Complete |
| Views | 4 | ✅ Complete |
| Salary Structure | 1 | ✅ Complete |
| Salary Rule Category | 1 | ✅ Complete |
| Salary Rules | 14 | ✅ Complete |
| Tax Data Records | 14 | ✅ Complete |
| Security Rules | 2 | ✅ Complete |

---

## Models

### New Models Created

#### 1. tax.yearly.rates
Configuration for yearly tax rates (Federal, Provincial, CPP, EI)

| Field | Type | Description |
|-------|------|-------------|
| fiscal_year | Many2one | Link to account.fiscal.year |
| tax_type | Selection | federal / provincial |
| ded_type | Selection | cpp / ei |
| tax_yearly_rate_ids | One2many | Tax bracket lines |
| fed_tax_credit | Float | Federal tax credit |
| provincial_tax_credit | Float | Provincial tax credit |
| canada_emp_amount | Float | Canada Employment Amount |
| exemption | Float | CPP exemption amount |
| max_cpp | Float | Maximum CPP contribution |
| emp_contribution_rate | Float | Employee CPP rate |
| employer_contribution_rate | Float | Employer CPP rate |
| ei_date | Date | EI effective date |
| ei_rate | Float | EI rate |
| ei_earnings | Float | Maximum EI earnings |
| emp_ei_amount | Float | Employee EI amount |
| employer_ei_amount | Float | Employer EI amount |

#### 2. tax.yearly.rate.line
Tax bracket lines for federal/provincial taxes

| Field | Type | Description |
|-------|------|-------------|
| tax_id | Many2one | Parent tax.yearly.rates |
| tax_bracket | Float | Income threshold |
| tax_rate | Float | Tax rate percentage |
| tax_constant | Float | Tax constant |

### Extended Models

#### 1. hr.contract
Added fields for employee tax credits:
- `fed_tax_credit` - Federal Tax Credit
- `provincial_tax_credit` - Provincial Tax Credit

#### 2. hr.salary.rule.category
Added fields to link Canadian payroll configuration:
- `cpp_deduction_id` - Link to CPP yearly rates
- `ei_deduction_id` - Link to EI yearly rates
- `fed_tax_id` - Link to Federal tax rates
- `provincial_tax_id` - Link to Provincial tax rates
- Related fields for CPP/EI values

---

## Salary Structure

**Name**: Canada salary structure  
**Code**: Canada  
**Parent**: Base for new structures

### Salary Rules in Structure

| Sequence | Name | Code | Category | Type |
|----------|------|------|----------|------|
| 1 | Basic Salary | BASIC | Basic | Base |
| 5 | House Rent Allowance | HRA | Allowance | Base |
| 6 | Dearness Allowance | DA | Allowance | Base |
| 7 | Travel Allowance | Travel | Allowance | Base |
| 8 | Meal Allowance | Meal | Allowance | Base |
| 9 | Medical Allowance | Medical | Allowance | Base |
| 100 | Gross | GROSS | Gross | Computed |
| 103 | CPP_Employee | CPP_EMPLOYEE | Deduction | Python |
| 104 | CPP_Employer | CPP_EMPLOYER | Company Contribution | Python |
| 105 | EI_Employee | EI_EMPLOYEE | Deduction | Python |
| 106 | EI_Employer | EI_EMPLOYER | Company Contribution | Python |
| 107 | Federal Income Tax | FED | Deduction | Python |
| 108 | Province Income Tax | PR | Deduction | Python |
| 200 | Net Salary | NET | Net | Computed |

---

## Tax Data (2025)

### Federal Tax Brackets (Canada)
| Bracket | Rate | Constant |
|---------|------|----------|
| $55,867 | 15.00% | $0 |
| $111,733 | 20.50% | $0 |
| $173,205 | 26.00% | $0 |
| $246,752 | 29.00% | $0 |
| $246,752+ | 33.00% | $0 |

**Canada Employment Amount**: $1,433.00

### Provincial Tax Brackets (Ontario)
| Bracket | Rate | Constant |
|---------|------|----------|
| $52,886 | 5.05% | $0 |
| $105,775 | 9.15% | $0 |
| $150,000 | 11.16% | $0 |
| $220,000 | 12.16% | $0 |
| $220,000+ | 13.16% | $0 |

### CPP (Canada Pension Plan)
- Employee Contribution Rate: 5.95%
- Employer Contribution Rate: 5.95%
- Exemption Amount: $134.61 (per pay period)
- Maximum CPP: $4,034.10

### EI (Employment Insurance)
- EI Rate: 1.64%
- Maximum EI Earnings: $65,700.00
- Employee EI Amount: $1,077.48
- Employer EI Amount: $1,508.47

---

## Calculation Logic

### Pay Period
The module assumes **semi-monthly** pay periods (24 per year).  
All annual amounts are divided by 24.

### CPP Calculation
```
CPP = (GROSS - Exemption/24) * Rate / 100
```
Capped at annual maximum with year-to-date tracking.

### EI Calculation
```
EI = GROSS * Rate / 100
```
Capped at annual maximum with year-to-date tracking.
Employer pays 1.4x employee portion.

### Tax Calculation
Uses progressive tax brackets:
1. Determine bracket based on semi-monthly wage
2. Apply rate and constant
3. Subtract tax credits (personal credits, CPP, EI, Canada Employment)

---

## Installation

1. Copy module to Odoo addons directory
2. Update Apps List
3. Install "Fusion Payroll - Canada"
4. Configure:
   - Create Fiscal Year if needed
   - Go to Payroll → Configuration → Yearly Rates
   - Link CPP, EI, Federal, Provincial records to Salary Rule Category
   - Assign Canada structure to employee contracts

---

## Notes

- Year-to-date calculations use hardcoded date ranges (update for each year)
- Tax brackets should be updated annually per CRA guidelines
- Employer EI is 1.4x employee portion
- Module designed for Ontario - add other provinces as needed
