<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data noupdate="1">

        <!-- ============================================================ -->
        <!-- CANADA SALARY STRUCTURE                                       -->
        <!-- ============================================================ -->
        
        <!-- Salary Structure Type (if needed) -->
        <record id="structure_type_canada" model="hr.payroll.structure.type">
            <field name="name">Canada</field>
            <field name="country_id" ref="base.ca"/>
        </record>

        <!-- Canada Salary Structure -->
        <record id="hr_payroll_structure_canada" model="hr.payroll.structure">
            <field name="name">Canada salary structure</field>
            <field name="code">Canada</field>
            <field name="type_id" ref="structure_type_canada"/>
        </record>

        <!-- ============================================================ -->
        <!-- SALARY RULE CATEGORY - CANADA (Deduction)                     -->
        <!-- This category links to CPP, EI, Federal and Provincial Tax   -->
        <!-- ============================================================ -->
        <record id="hr_payroll_category_canada" model="hr.salary.rule.category">
            <field name="name">Deduction</field>
            <field name="code">CANADA</field>
            <field name="parent_id" ref="hr_payroll.DED"/>
            <!-- These links are set via the UI after tax rates are created -->
            <!-- cpp_deduction_id, ei_deduction_id, fed_tax_id, provincial_tax_id -->
        </record>

        <!-- ============================================================ -->
        <!-- LINK SALARY RULES TO CANADA STRUCTURE                         -->
        <!-- ============================================================ -->
        
        <!-- Basic Salary -->
        <record id="hr_rule_basic" model="hr.salary.rule">
            <field name="name">Basic Salary</field>
            <field name="code">BASIC</field>
            <field name="sequence">1</field>
            <field name="category_id" ref="hr_payroll.BASIC"/>
            <field name="struct_id" ref="hr_payroll_structure_canada"/>
            <field name="condition_select">none</field>
            <field name="amount_select">code</field>
            <field name="amount_python_compute">result = payslip.paid_amount</field>
        </record>

        <!-- House Rent Allowance -->
        <record id="hr_rule_hra" model="hr.salary.rule">
            <field name="name">House Rent Allowance</field>
            <field name="code">HRA</field>
            <field name="sequence">5</field>
            <field name="category_id" ref="hr_payroll.ALW"/>
            <field name="struct_id" ref="hr_payroll_structure_canada"/>
            <field name="condition_select">none</field>
            <field name="amount_select">fix</field>
            <field name="amount_fix">0.0</field>
        </record>

        <!-- Dearness Allowance -->
        <record id="hr_rule_da" model="hr.salary.rule">
            <field name="name">Dearness Allowance</field>
            <field name="code">DA</field>
            <field name="sequence">6</field>
            <field name="category_id" ref="hr_payroll.ALW"/>
            <field name="struct_id" ref="hr_payroll_structure_canada"/>
            <field name="condition_select">none</field>
            <field name="amount_select">fix</field>
            <field name="amount_fix">0.0</field>
        </record>

        <!-- Travel Allowance -->
        <record id="hr_rule_travel" model="hr.salary.rule">
            <field name="name">Travel Allowance</field>
            <field name="code">Travel</field>
            <field name="sequence">7</field>
            <field name="category_id" ref="hr_payroll.ALW"/>
            <field name="struct_id" ref="hr_payroll_structure_canada"/>
            <field name="condition_select">none</field>
            <field name="amount_select">fix</field>
            <field name="amount_fix">0.0</field>
        </record>

        <!-- Meal Allowance -->
        <record id="hr_rule_meal" model="hr.salary.rule">
            <field name="name">Meal Allowance</field>
            <field name="code">Meal</field>
            <field name="sequence">8</field>
            <field name="category_id" ref="hr_payroll.ALW"/>
            <field name="struct_id" ref="hr_payroll_structure_canada"/>
            <field name="condition_select">none</field>
            <field name="amount_select">fix</field>
            <field name="amount_fix">0.0</field>
        </record>

        <!-- Medical Allowance -->
        <record id="hr_rule_medical" model="hr.salary.rule">
            <field name="name">Medical Allowance</field>
            <field name="code">Medical</field>
            <field name="sequence">9</field>
            <field name="category_id" ref="hr_payroll.ALW"/>
            <field name="struct_id" ref="hr_payroll_structure_canada"/>
            <field name="condition_select">none</field>
            <field name="amount_select">fix</field>
            <field name="amount_fix">0.0</field>
        </record>

        <!-- Gross Salary -->
        <record id="hr_rule_gross" model="hr.salary.rule">
            <field name="name">Gross</field>
            <field name="code">GROSS</field>
            <field name="sequence">100</field>
            <field name="category_id" ref="hr_payroll.GROSS"/>
            <field name="struct_id" ref="hr_payroll_structure_canada"/>
            <field name="condition_select">none</field>
            <field name="amount_select">code</field>
            <field name="amount_python_compute">result = categories.BASIC + categories.ALW</field>
        </record>

        <!-- Net Salary -->
        <record id="hr_rule_net" model="hr.salary.rule">
            <field name="name">Net Salary</field>
            <field name="code">NET</field>
            <field name="sequence">200</field>
            <field name="category_id" ref="hr_payroll.NET"/>
            <field name="struct_id" ref="hr_payroll_structure_canada"/>
            <field name="condition_select">none</field>
            <field name="amount_select">code</field>
            <field name="amount_python_compute">result = categories.GROSS + categories.DED</field>
        </record>

    </data>
</odoo>
