<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
    <!-- Wage Base -->
    <record id="rule_parameter_us_wa_suta_wage_base" model="hr.rule.parameter">
        <field name="name">US WA Washington SUTA Wage Base</field>
        <field name="code">us_wa_suta_wage_base</field>
        <field name="country_id" ref="base.us"/>
    </record>
    <record id="rule_parameter_us_wa_suta_wage_base_2020" model="hr.rule.parameter.value">
        <field name="parameter_value">52700.00</field>
        <field name="rule_parameter_id" ref="rule_parameter_us_wa_suta_wage_base"/>
        <field name="date_from" eval="datetime(2020, 1, 1).date()"/>
    </record>

    <record id="rule_parameter_us_wa_fml_wage_base" model="hr.rule.parameter">
        <field name="name">US WA Washington FML Wage Base</field>
        <field name="code">us_wa_fml_wage_base</field>
        <field name="country_id" ref="base.us"/>
    </record>
    <record id="rule_parameter_us_wa_fml_wage_base_2020" model="hr.rule.parameter.value">
        <field name="parameter_value">137700.00</field>
        <field name="rule_parameter_id" ref="rule_parameter_us_wa_fml_wage_base"/>
        <field name="date_from" eval="datetime(2020, 1, 1).date()"/>
    </record>

    <!-- Rate -->
    <record id="rule_parameter_us_wa_suta_rate" model="hr.rule.parameter">
        <field name="name">US WA Washington SUTA Rate</field>
        <field name="code">us_wa_suta_rate</field>
        <field name="country_id" ref="base.us"/>
    </record>
    <data noupdate="1">
        <record id="rule_parameter_us_wa_suta_rate_2020" model="hr.rule.parameter.value">
            <field name="parameter_value">1.0</field>
            <field name="rule_parameter_id" ref="rule_parameter_us_wa_suta_rate"/>
            <field name="date_from" eval="datetime(2020, 1, 1).date()"/>
        </record>
    </data>

    <record id="rule_parameter_us_wa_fml_rate" model="hr.rule.parameter">
        <field name="name">US WA Washington FML Rate (Total)</field>
        <field name="code">us_wa_fml_rate</field>
        <field name="country_id" ref="base.us"/>
    </record>
    <record id="rule_parameter_us_wa_fml_rate_2020" model="hr.rule.parameter.value">
        <field name="parameter_value">0.4</field>
        <field name="rule_parameter_id" ref="rule_parameter_us_wa_fml_rate"/>
        <field name="date_from" eval="datetime(2020, 1, 1).date()"/>
    </record>

    <record id="rule_parameter_us_wa_fml_rate_ee" model="hr.rule.parameter">
        <field name="name">US WA Washington FML Rate (Employee)</field>
        <field name="code">us_wa_fml_rate_ee</field>
        <field name="country_id" ref="base.us"/>
    </record>
    <record id="rule_parameter_us_wa_fml_rate_ee_2020" model="hr.rule.parameter.value">
        <field name="parameter_value">66.33</field>
        <field name="rule_parameter_id" ref="rule_parameter_us_wa_fml_rate_ee"/>
        <field name="date_from" eval="datetime(2020, 1, 1).date()"/>
    </record>

    <record id="rule_parameter_us_wa_fml_rate_er" model="hr.rule.parameter">
        <field name="name">US WA Washington FML Rate (Employer)</field>
        <field name="code">us_wa_fml_rate_er</field>
        <field name="country_id" ref="base.us"/>
    </record>
    <record id="rule_parameter_us_wa_fml_rate_er_2020" model="hr.rule.parameter.value">
        <field name="parameter_value">33.67</field>
        <field name="rule_parameter_id" ref="rule_parameter_us_wa_fml_rate_er"/>
        <field name="date_from" eval="datetime(2020, 1, 1).date()"/>
    </record>

    <record id="rule_parameter_us_wa_cares_rate_ee" model="hr.rule.parameter">
        <field name="name">US WA Washington Cares (Employee)</field>
        <field name="code">us_wa_cares_rate_ee</field>
        <field name="country_id" ref="base.us"/>
    </record>
    <!-- didn't exist but helpful to back date for tests -->
    <record id="rule_parameter_us_wa_cares_rate_ee_2020" model="hr.rule.parameter.value">
        <field name="parameter_value">0.0</field>
        <field name="rule_parameter_id" ref="rule_parameter_us_wa_cares_rate_ee"/>
        <field name="date_from" eval="datetime(2020, 1, 1).date()"/>
    </record>

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

    <record id="res_partner_us_wa_dor_lni" model="res.partner">
        <field name="name">US Washington - Department of Labor &amp; Industries</field>
    </record>

    <record id="res_partner_us_wa_dor_fml" model="res.partner">
        <field name="name">US Washington - Employment Security Department (PFML)</field>
    </record>

    <!-- Categories -->

    <!-- Rules -->
    <record id="hr_payroll_rule_er_us_wa_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 WA Washington State Unemployment (5208A/B)</field>
        <field name="code">ER_US_WA_SUTA</field>
        <field name="condition_select">python</field>
        <field name="condition_python">result, _ = general_state_unemployment(payslip, categories, worked_days, inputs,
            wage_base='us_wa_suta_wage_base', rate='us_wa_suta_rate', state_code='WA')
        </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_wa_suta_wage_base', rate='us_wa_suta_rate', state_code='WA')
        </field>
        <field name="partner_id" ref="res_partner_us_wa_dor"/>
        <field name="appears_on_payslip" eval="False"/>
    </record>

    <record id="hr_payroll_rule_er_us_wa_fml" model="hr.salary.rule">
        <field name="sequence" eval="451"/>
        <field name="struct_id" ref="hr_payroll_structure"/>
        <field name="category_id" ref="hr_payroll.COMP"/>
        <field name="name">ER: US WA Washington State Family Medical Leave</field>
        <field name="code">ER_US_WA_FML</field>
        <field name="condition_select">python</field>
        <field name="condition_python">result, _ = wa_washington_fml_er(payslip, categories, worked_days, inputs)
        </field>
        <field name="amount_select">code</field>
        <field name="amount_python_compute">result, result_rate = wa_washington_fml_er(payslip, categories, worked_days,
            inputs)
        </field>
        <field name="partner_id" ref="res_partner_us_wa_dor_fml"/>
        <field name="appears_on_payslip" eval="False"/>
    </record>

    <record id="hr_payroll_rule_ee_us_wa_fml" model="hr.salary.rule">
        <field name="sequence" eval="196"/>
        <field name="struct_id" ref="hr_payroll_structure"/>
        <field name="category_id" ref="hr_payroll.DED"/>
        <field name="name">EE: US WA Washington State Family Medical Leave</field>
        <field name="code">EE_US_WA_FML</field>
        <field name="condition_select">python</field>
        <field name="condition_python">result, _ = wa_washington_fml_ee(payslip, categories, worked_days, inputs)
        </field>
        <field name="amount_select">code</field>
        <field name="amount_python_compute">result, result_rate = wa_washington_fml_ee(payslip, categories, worked_days,
            inputs)
        </field>
        <field name="partner_id" ref="res_partner_us_wa_dor_fml"/>
        <field name="appears_on_payslip" eval="True"/>
    </record>
    <record id="hr_payroll_rule_ee_us_wa_cares" model="hr.salary.rule">
        <field name="sequence" eval="197"/>
        <field name="struct_id" ref="hr_payroll_structure"/>
        <field name="category_id" ref="hr_payroll.DED"/>
        <field name="name">EE: US WA Washington State Cares</field>
        <field name="code">EE_US_WA_CARES</field>
        <field name="condition_select">python</field>
        <field name="condition_python">result, _ = wa_washington_cares_ee(payslip, categories, worked_days, inputs)
        </field>
        <field name="amount_select">code</field>
        <field name="amount_python_compute">result, result_rate = wa_washington_cares_ee(payslip, categories, worked_days, inputs)
        </field>
        <field name="partner_id" ref="res_partner_us_wa_dor_fml"/>
        <field name="appears_on_payslip" eval="True"/>
    </record>

    <!-- LNI May need to be updated depending on hours worked (or drywall laid) -->
    <record id="hr_payroll_rule_er_us_wa_lni" model="hr.salary.rule">
        <field name="sequence" eval="451"/>
        <field name="struct_id" ref="hr_payroll_structure"/>
        <field name="category_id" ref="hr_payroll.COMP"/>
        <field name="name">ER: US WA Washington State LNI</field>
        <field name="code">ER_US_WA_LNI</field>
        <field name="condition_select">python</field>
        <field name="condition_python">result = is_us_state(payslip, 'WA') and payslip.contract_id.us_payroll_config_value('workers_comp_ee_code') and worked_days.WORK100 and worked_days.WORK100.number_of_hours and payslip.rule_parameter(payslip.contract_id.us_payroll_config_value('workers_comp_er_code')) </field>
        <field name="amount_select">code</field>
        <field name="amount_python_compute">result, result_rate = worked_days.WORK100.number_of_hours, -payslip.rule_parameter(payslip.contract_id.us_payroll_config_value('workers_comp_er_code'))
        </field>
        <field name="partner_id" ref="res_partner_us_wa_dor_lni"/>
        <field name="appears_on_payslip" eval="False"/>
    </record>

    <record id="hr_payroll_rule_ee_us_wa_lni" model="hr.salary.rule">
        <field name="sequence" eval="196"/>
        <field name="struct_id" ref="hr_payroll_structure"/>
        <field name="category_id" ref="hr_payroll.DED"/>
        <field name="name">EE: US WA Washington State LNI</field>
        <field name="code">EE_US_WA_LNI</field>
        <field name="condition_select">python</field>
        <field name="condition_python">result = is_us_state(payslip, 'WA') and payslip.contract_id.us_payroll_config_value('workers_comp_ee_code') and worked_days.WORK100 and worked_days.WORK100.number_of_hours and payslip.rule_parameter(payslip.contract_id.us_payroll_config_value('workers_comp_ee_code'))</field>
        <field name="amount_select">code</field>
        <field name="amount_python_compute">result, result_rate = worked_days.WORK100.number_of_hours, -payslip.rule_parameter(payslip.contract_id.us_payroll_config_value('workers_comp_ee_code'))
        </field>
        <field name="partner_id" ref="res_partner_us_wa_dor_lni"/>
        <field name="appears_on_payslip" eval="True"/>
    </record>

</odoo>