Update unit price + tax rules

In Spain there’s a special tax for freelancers in agriculture, it works as follows:

  • If I’m the customer of a freelancer in agriculture instead of receiving an invoice with the 4% VAT, I will just have to create the invoice myself for the freelancer.
  • In the supplier invoice created, we must put a 12% VAT + 2% IRPF. The 12% VAT must be added to the unit price when the 2% IRPF is applied.

A good explanation of how it works can be found here:

http://jurisdependencia-asesoriayabogados.com/agricultura-iva-ganaderia/

The 12+2 taxes can be put manually in the supplier invoice (that is selecting both taxes manually in the m2m widget) and the computation works as expected as long as IRPF sequence is greater than the VAT sequence. So far, so good.

However, as the 12%+2% is only applied when the party is a freelancer it would be great to create a rule tax so when the product has a 4% is converted to 12%+2% for theses suppliers.

However, as I understand that is not possible because rule taxes only allow one target tax and because the “update unit price” cannot be used on child taxes. See:

Here’s the tax computation that only

http://hg.tryton.org/modules/account/file/default/tax.py#l884

Here’s the code to the constraint that only allows update unit price on parent taxes:

http://hg.tryton.org/modules/account/file/default/tax.py#l505

Does anybody have a good alternative to create those taxes so that they can be used in tax rules?

I don’t see a reason for not permiting “update unit price” in child taxes, although that price would only be applied to sibling taxes, but it would be an acceptable behaviour I think.

More thoughts?

Such behavior will make the reverse computation very complex.

Nothing prevents a tax rule to be customized to return more than one substituted taxes.

We check “update unit price” in tax (from database or xml) and it works as expected. Indeed it’s not the best solution …

I agree with you.

Here is the xml definition that we use to manage this case:

        <record model="account.tax.template" id="iva_reagp_purchase_12">
            <field name="name">IVA 12% Regimen Especial Agricultura y Pesca</field>
            <field name="description">IVA 12% Regimen Especial Agricultura y Pesca</field>
            <field name="account" ref="account_es.pgc_0"/>
            <field name="group" ref="account_es.tax_group_purchase"/>
            <field name="type">percentage</field>
            <field name="rate" eval="Decimal('0.12')"/>
            <field name="invoice_account" ref="account_es.pgc_472"/>
            <field name="credit_note_account" ref="account_es.pgc_472"/>
            <field name="sequence" eval="2420"/>
            <field name="update_unit_price" eval="True"/>
        </record>
        <record model="account.tax.code.line.template" id="vat_code_iva_deducible_tax_reagp-iva_reagp_purchase_12-invoice">
            <field name="code" ref="account_es.vat_code_iva_deducible_tax_reagp"/>
            <field name="tax" ref="iva_reagp_purchase_12"/>
            <field name="operator">+</field>
            <field name="amount">tax</field>
            <field name="type">invoice</field>
        </record>
        <record model="account.tax.code.line.template" id="vat_code_iva_deducible_tax_reagp-iva_reagp_purchase_12-credit">
            <field name="code" ref="account_es.vat_code_iva_deducible_tax_reagp"/>
            <field name="tax" ref="iva_reagp_purchase_12"/>
            <field name="operator">-</field>
            <field name="amount">tax</field>
            <field name="type">credit</field>
        </record>
        <record model="account.tax.template" id="irpf_reagp_purchase_2">
            <field name="name">Retención IRPF 2% Regimen Especial Agricultura y Pesca</field>
            <field name="description">Retención IRPF 2% Regimen Especial Agricultura y Pesca</field>
            <field name="account" ref="account_es.pgc_0"/>
            <field name="type">percentage</field>
            <field name="rate" eval="Decimal('-0.02')"/>
            <field name="invoice_account" ref="account_es.pgc_4751"/>
            <field name="credit_note_account" ref="account_es.pgc_4751"/>
            <field name="sequence" eval="6430"/>
        </record>
        <record model="account.tax.code.line.template" id="vat_code_irpf_purchase_base-irpf_reagp_purchase_2-invoice">
            <field name="code" ref="account_es.vat_code_irpf_purchase_base"/>
            <field name="tax" ref="irpf_reagp_purchase_2"/>
            <field name="operator">+</field>
            <field name="amount">base</field>
            <field name="type">invoice</field>
        </record>
        <record model="account.tax.code.line.template" id="vat_code_irpf_purchase_base-irpf_reagp_purchase_2-credit">
            <field name="code" ref="account_es.vat_code_irpf_purchase_base"/>
            <field name="tax" ref="irpf_reagp_purchase_2"/>
            <field name="operator">-</field>
            <field name="amount">base</field>
            <field name="type">credit</field>
        </record>
        <record model="account.tax.code.line.template" id="vat_code_irpf_purchase_tax-irpf_reagp_purchase_2-invoice">
            <field name="code" ref="account_es.vat_code_irpf_purchase_tax"/>
            <field name="tax" ref="irpf_reagp_purchase_2"/>
            <field name="operator">+</field>
            <field name="amount">tax</field>
            <field name="type">invoice</field>
        </record>
        <record model="account.tax.code.line.template" id="vat_code_irpf_purchase_tax-irpf_reagp_purchase_2-credit">
            <field name="code" ref="account_es.vat_code_irpf_purchase_tax"/>
            <field name="tax" ref="irpf_reagp_purchase_2"/>
            <field name="operator">-</field>
            <field name="amount">tax</field>
            <field name="type">credit</field>
        </record>
        <record model="account.tax.rule.template" id="fp_reagp">
            <field name="name">Régimen especial agricultura ganadería y pesca</field>
            <field name="account" ref="account_es.pgc_0"/>
            <field name="kind">purchase</field>
        </record>
        <record model="account.tax.rule.line.template" id="fp_reagp_iva">
            <field name="rule" ref="fp_reagp"/>
            <field name="tax" ref="iva_reagp_purchase_12"/>
            <field name="group" ref="account_es.tax_group_purchase"/>
            <field name="sequence" eval="10"/>
        </record>
        <record model="account.tax.rule.line.template" id="fp_reagp_irpf">
            <field name="rule" ref="fp_reagp"/>
            <field name="tax" ref="irpf_reagp_purchase_2"/>
            <field name="sequence" eval="20"/>
        </record>

Maybe we can include this as part of the oficial account_es module.

Altought it’s not used for everyone it only includes a tax rule that can be only used when required.

1 Like

I remember that I tried this aproach when implementing the first version of the REAGP tax rule and it was so complex to support all the reverse compute cases. Here is the issue explaining all the details if you are curious about it.