<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
    <!-- Wage Base -->
    <record id="rule_parameter_us_ms_suta_wage_base" model="hr.rule.parameter">
        <field name="name">US MS Mississippi SUTA Wage Base</field>
        <field name="code">us_ms_suta_wage_base</field>
        <field name="country_id" ref="base.us"/>
    </record>
    <record id="rule_parameter_us_ms_suta_wage_base_2020" model="hr.rule.parameter.value">
        <field name="parameter_value">14000.0</field>
        <field name="rule_parameter_id" ref="rule_parameter_us_ms_suta_wage_base"/>
        <field name="date_from" eval="datetime(2020, 1, 1).date()"/>
    </record>

    <!-- Rate -->
    <record id="rule_parameter_us_ms_suta_rate" model="hr.rule.parameter">
        <field name="name">US MS Mississippi SUTA Rate</field>
        <field name="code">us_ms_suta_rate</field>
        <field name="country_id" ref="base.us"/>
    </record>
    <data noupdate="1">
        <record id="rule_parameter_us_ms_suta_rate_2020" model="hr.rule.parameter.value">
            <field name="parameter_value">1.2</field>
            <field name="rule_parameter_id" ref="rule_parameter_us_ms_suta_rate"/>
            <field name="date_from" eval="datetime(2020, 1, 1).date()"/>
        </record>
    </data>

    <record id="rule_parameter_us_ms_sit_rate" model="hr.rule.parameter">
        <field name="name">US MS Mississippi SIT Rate Table</field>
        <field name="code">us_ms_sit_rate</field>
        <field name="country_id" ref="base.us"/>
    </record>
    <record id="rule_parameter_us_ms_sit_rate_2020" model="hr.rule.parameter.value">
        <field name="parameter_value">[
                (  10000.00,  260.0,  0.05),
                (   5000.00,   60.0,  0.04),
                (   3000.00,    0.0,  0.03),
            ]</field>
        <field name="rule_parameter_id" ref="rule_parameter_us_ms_sit_rate"/>
        <field name="date_from" eval="datetime(2020, 1, 1).date()"/>
    </record>

    <record id="rule_parameter_us_ms_sit_deduction" model="hr.rule.parameter">
        <field name="name">US MS Mississippi SIT Deduction</field>
        <field name="code">us_ms_sit_deduction</field>
        <field name="country_id" ref="base.us"/>
    </record>
    <record id="rule_parameter_us_ms_sit_deduction_2020" model="hr.rule.parameter.value">
        <field name="parameter_value">{
            'single':             2300.0,
            'head_of_household':  3400.0,
            'married_dual':       2300.0,
            'married':            4600.0,
        }</field>
        <field name="rule_parameter_id" ref="rule_parameter_us_ms_sit_deduction"/>
        <field name="date_from" eval="datetime(2020, 1, 1).date()"/>
    </record>

    <!-- Partners and Contribution Registers -->
    <record id="res_partner_us_ms_dor" model="res.partner">
        <field name="name">US Mississippi - Department of Employment Security (Unemployment)</field>
    </record>

    <record id="res_partner_us_ms_dor_sit" model="res.partner">
        <field name="name">US Mississippi - Mississippi Department of Revenue (Income Tax)</field>
    </record>

    <!-- Categories -->

    <!-- Rules -->
    <record id="hr_payroll_rule_er_us_ms_suta" model="hr.salary.rule">
        <field name="sequence" eval="450"/>
        <field name="struct_id" ref="hr_payroll_structure"/>
        <field name="category_id" ref="hr_payroll_category_er_us_suta"/>
        <field name="name">ER: US MS Mississippi State Unemployment</field>
        <field name="code">ER_US_MS_SUTA</field>
        <field name="condition_select">python</field>
        <field name="condition_python">result, _ = general_state_unemployment(payslip, categories, worked_days, inputs, wage_base='us_ms_suta_wage_base', rate='us_ms_suta_rate', state_code='MS')</field>
        <field name="amount_select">code</field>
        <field name="amount_python_compute">result, result_rate = general_state_unemployment(payslip, categories, worked_days, inputs, wage_base='us_ms_suta_wage_base', rate='us_ms_suta_rate', state_code='MS')</field>
        <field name="partner_id" ref="res_partner_us_ms_dor"/>
        <field name="appears_on_payslip" eval="False"/>
    </record>

    <record id="hr_payroll_rule_ee_us_ms_sit" model="hr.salary.rule">
        <field name="sequence" eval="195"/>
        <field name="struct_id" ref="hr_payroll_structure"/>
        <field name="category_id" ref="hr_payroll_category_ee_us_sit"/>
        <field name="name">EE: US MS Mississippi State Income Tax Withholding</field>
        <field name="code">EE_US_MS_SIT</field>
        <field name="condition_select">python</field>
        <field name="condition_python">result, _ = ms_mississippi_state_income_withholding(payslip, categories, worked_days, inputs)</field>
        <field name="amount_select">code</field>
        <field name="amount_python_compute">result, result_rate = ms_mississippi_state_income_withholding(payslip, categories, worked_days, inputs)</field>
        <field name="partner_id" ref="res_partner_us_ms_dor_sit"/>
        <field name="appears_on_payslip" eval="True"/>
    </record>

</odoo>