How to include the IRPF in WooCommerce as a negative tax

IMPORTANT NOTE: The information on income tax application of this article is not entirely correct, only the section on the surcharge by country is useful. If you want to correctly apply the IRPF in WooCommerce check this other more recent article .

WooCommerce is a fantastic plugin to make cheap and fast online stores but it does not always have solution for all needs. [19659004] In fact, one of its shortcomings is the impossibility, by default, to include negative taxes, such as the IRPF .

The problem

Every self-employed person knows that if he invoices another self-employed person or a company he must include in the invoice two taxes, the income tax withholding which is negative, which is usually -15%, and then as always 21% VAT.

With VAT there is no problem, even the installation of WooCommerce is set by him alone only with put as country Spain, but try to add a negative tax as a new rate, just do not leave, take it as positive .

Neither are the billing plugins for WooCommerce because although there are some like Sliced ​​Invoices great on the other hand, that allows you add an additional field called " Adjustment ", this is incorporated as a discount in the item lines of the invoice.

But this, as you already know, does not work in Spanish legislation, which indicates clearly that the IRPF must be applied after the subtotal of the prices, being a retention not something related to the products.

It is a usual request of many people in several forums, in the WooCommerce support page and in more sites, but it has easy solution.

The trick: the WooCommerce surcharge

And the solution is to add what is called ] a surcharge . It is a solution that is available in the documentation of the WooCommerce API .

The trick is simply to add what is called a surcharge , a surcharge, in our negative case which will be applied at the end of taxes, after the subtotal and before the total charge and, more importantly, from the invoice . [19659004] The sample code, available in the WooCommerce API is this:

Adding the retention of IRPF to WooCommerce

So to customize it so that we can use it to subtract 15% of IRPF in WooCommerce would be like this: