# Update unit price + tax rules

**URL:** https://discuss.tryton.org/t/update-unit-price-tax-rules/1544
**Category:** User
**Created:** [July 9, 2019, 10:37am UTC](https://discuss.tryton.org/t/update-unit-price-tax-rules/1544 "2019-07-09T10:37:12Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![albert](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/albert/32/21_2.png) [@albert](https://discuss.tryton.org/u/albert)
#### Post date: [July 9, 2019, 10:37am UTC](https://discuss.tryton.org/t/update-unit-price-tax-rules/1544/1 "2019-07-09T10:37:12Z")

</div>

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/](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](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](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?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [July 9, 2019, 10:52am UTC](https://discuss.tryton.org/t/update-unit-price-tax-rules/1544/2 "2019-07-09T10:52:29Z")

</div>

> [@albert](#):
>
> 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.

Such behavior will make the reverse computation very complex.

Nothing prevents a tax rule to be customized to [return more than one substituted taxes](http://hg.tryton.org/modules/account/file/00ceeb0849ee/tax.py#l1591).

---

<div class="post-metadata">

### Author: ![sergyo](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/sergyo/32/181_2.png) [@sergyo](https://discuss.tryton.org/u/sergyo)
#### Post date: [July 9, 2019, 10:59am UTC](https://discuss.tryton.org/t/update-unit-price-tax-rules/1544/3 "2019-07-09T10:59:39Z")

</div>

> [@albert](#):
>
> Does anybody have a good alternative to create those taxes so that they can be used in tax rules?

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

> [@albert](#):
>
> 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?

I agree with you.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [July 9, 2019, 2:11pm UTC](https://discuss.tryton.org/t/update-unit-price-tax-rules/1544/4 "2019-07-09T14:11:03Z")

</div>

> [@albert](#):
>
> Does anybody have a good alternative to create those taxes so that they can be used in tax rules?

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

```auto
        <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.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [July 9, 2019, 2:14pm UTC](https://discuss.tryton.org/t/update-unit-price-tax-rules/1544/5 "2019-07-09T14:14:26Z")

</div>

> [@ced](#):
>
> > 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.
> 
> Such behavior will make the reverse computation very complex.

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](https://bugs.tryton.org/issue5121) if you are curious about it.
