# -*- coding: utf-8 -*-

from odoo import models, fields, api


class HrSalaryRuleCategory(models.Model):
    _inherit = 'hr.salary.rule.category'

    # === Canadian Pension Plan (CPP) Configuration ===
    cpp_deduction_id = fields.Many2one(
        'tax.yearly.rates',
        string='Canadian Configuration Values',
        domain="[('ded_type', '=', 'cpp')]",
        help='Link to CPP yearly rates configuration',
    )
    cpp_date = fields.Date(
        string='CPP Date',
        related='cpp_deduction_id.cpp_date',
        readonly=True,
    )
    max_cpp = fields.Float(
        string='Maximum CPP',
        related='cpp_deduction_id.max_cpp',
        readonly=True,
    )
    emp_contribution_rate = fields.Float(
        string='Employee Contribution Rate',
        related='cpp_deduction_id.emp_contribution_rate',
        readonly=True,
    )
    employer_contribution_rate = fields.Float(
        string='Employer Contribution Rate',
        related='cpp_deduction_id.employer_contribution_rate',
        readonly=True,
    )
    exemption = fields.Float(
        string='Exemption Amount',
        related='cpp_deduction_id.exemption',
        readonly=True,
    )

    # === Employment Insurance (EI) Configuration ===
    ei_deduction_id = fields.Many2one(
        'tax.yearly.rates',
        string='Employment Insurance',
        domain="[('ded_type', '=', 'ei')]",
        help='Link to EI yearly rates configuration',
    )
    ei_date = fields.Date(
        string='EI Date',
        related='ei_deduction_id.ei_date',
        readonly=True,
    )
    ei_rate = fields.Float(
        string='EI Rate',
        related='ei_deduction_id.ei_rate',
        readonly=True,
    )
    ei_earnings = fields.Float(
        string='Maximum EI Earnings',
        related='ei_deduction_id.ei_earnings',
        readonly=True,
    )
    emp_ei_amount = fields.Float(
        string='Employee EI Amount',
        related='ei_deduction_id.emp_ei_amount',
        readonly=True,
    )
    employer_ei_amount = fields.Float(
        string='Employer EI Amount',
        related='ei_deduction_id.employer_ei_amount',
        readonly=True,
    )

    # === Federal Tax Configuration ===
    fed_tax_id = fields.Many2one(
        'tax.yearly.rates',
        string='Federal Tax',
        domain="[('tax_type', '=', 'federal')]",
        help='Link to Federal tax yearly rates configuration',
    )

    # === Provincial Tax Configuration ===
    provincial_tax_id = fields.Many2one(
        'tax.yearly.rates',
        string='Provincial Tax',
        domain="[('tax_type', '=', 'provincial')]",
        help='Link to Provincial tax yearly rates configuration',
    )
