Preserve original tax when appling tax rules

Rational

Tax rules are used to manage the Spanish IRPF. This means that self-employees customers have to pay a % of self-employees profits in advance to the Tax Authorities. This is achieved by applying a tax deduction (a tax with negative tax rate) to the original invoice.

For example, if we have an invoice of 100€, with 21% VAT and 15% IRPF reduction it will produce the following amounts:

Untaxed Amount:     100 €
VAT Amount:          21 €
IRPF Amount:        -15 €
Tax Amount:           6 €
--------------------------
Total Amount:       106 €

From: https://groups.google.com/d/msg/tryton/Gc_1ivnZl0U/yQhIfVNTAAAJ

The current tax rule system allows to substitute one tax with another but does not allow to add additional taxes to the current tax (which is the case of the IRPF tax rules). Currently in order to add additional taxes to the current tax the following must be done:

  • Create a new tax with two children: 1. The original tax and the new added tax.

Although this works, it makes the number of available taxes unmaintainable as the number of taxes is the product of all IVA taxes per the IRPF taxes.

Proposal

Add a check on the tax line to preserve the original taxes when applying the tax lines. If this mark is checked, applying the tax rule will return the substitution tax plus the source tax.

Implentation

https://bugs.tryton.org/issue6721

Other References

This will probably also make Issue 5121: Allow to modify unit_price on child taxes - Tryton issue tracker no more required, as we required it for an IRPF tax (which had a parent tax due to the tax rule), and this won’t be the case anymore.

Does the added tax depends really on the initial tax?

No, the added tax is always the same.

So it could be just added using the empty call.

Ouch. It’s working as expected. So the tax rule was wrongly defined on our side.

Thanks for your time.

It is always the same in the case of IRPF, but not in the case of RE (Recargo de Equivalencia).

Here’s the list of taxes and replacements needed:

IVA 21% => IVA 21% + RE 5.2%
IVA 10% => IVA 10% + RE 1.4%
IVA 4% => IVA 4% + RE 0.5%

So in this case we must create:

  • The standard IVA 21% tax
  • The parent tax named “IVA 21% + RE 5.2%”
  • A “IVA 21%” tax which is a child of “IVA 21% + RE 5.2%”
  • A “RE 5.2%” tax which is a child of “IVA 21% + RE 5.2%”

So we’re creating 4 tax records where 2 should be enough.

Idem for the “IVA 10%” and “IVA 4%” cases.

What do you mean by “empty call”? On version 4.5 I tried the following:

  • Create a tax named “IVA 21%”

  • Create another tax named “IRPF 15%”

  • Create a tax rule named “IRPF” which has a single rule line where:

    • origin is empty
    • replacement tax is “IRPF 15%”
  • I assigned the IRPF rule to a party

  • I created a product with the tax “IVA 21%” assigned

  • I created an invoice to that party and when I choose the product only the “IRPF 15%” tax is added to the invoice line. We need to have both: “IVA 21%” and “IRPF 15%” taxes in the line.

Am I doing something wrong?

Also, looking at the code I don’t see how we can currently achieve what it is requested at the beginning of this thread.

After a phone call with pokoli, I managed to make it work. Thanks!

So the include original tax is needed?

Yes, it is needed for the RE case.

I implemented it in Issue 6721: Preserve original tax when applying a tax rule - Tryton issue tracker