Invoice Calculation - Please help us!

Hello Community,

@Maxime_GRIMLER and me are currently working to make a really big feature possible for version 1.6: allow you - the users - to reorder the calculation process. Many users requested this feature because they need the taxes calculated before tax, or after or another way to calculate their invoices.
There already is an existing feature request for that but we need the help of all users to make this possible.

How you can help

At the moment we struggle to identify which combinations should and can be possible and which actually make sense.
Therefore we ask you to write down in which order you need the calculation.
There are two parts: items and invoices.

Item calculations

We have the following amounts available for calculation:

  • Item price
  • item amount
  • item discount
  • item tax rate

Invoice calculations

We have the following amounts available for calculation:

  • Item subtotal (price x amount)
  • invoice discount
  • invoice tax rates

Example for a calculation process

Please use the option for preformatted text in the editor menu to format all calculations.

Item calculation
1. item price x item amount = item subtotal
2. (item subtotal - item discount ) + item tax = item total

Invoice calculation
3. (item total - invoice discount ) + invoice tax = invoice total

This would be an replicable calculation process.
Please add your desired process now.

Overview of user-requested Calculations

Last Update: 2017-11-23

Thank you all for your help!

1 Like


Just a quick add, at the moment in the dev version, it’s possible to order tax and discount for items. Which means you can choose to calculate tax after the discount of your item or add the discount after the item have been taxable (which is the actual solution)
(cf : Error in Tax Calculation)

From my perspective, Calculation 1 is the only that is correct. So I would prefer this one.

An other idea: Is it possible to build a section within the system settings where the user can build the calculation for himself using variables/placeholders?

$item_subtotal = $item_price * $item_amount
$item_total = ($item_subtotal - $item_discount ) + $item_tax
$invoice_total = ($item_total - $invoice_discount ) + $invoice_tax

When you then add $item_subtotal into your template you can be sure, that it is calculated exactly the way you wanted it to be calculated.

1 Like

A post was split to a new topic: Tax questions for decimals and items

Calculation 1 is for me the good one.

Anyway what I have achieved is to let you order in the settings the items

  • item tax
  • item discount

And in a second area for invoice

  • invoice tax
  • invoice discount

It’s actually the order by default in IP and the order which will be by default if my solution is accepted (I don’t want anyone to have some problems with his invoices so every user will have to make his own changes).

If someone has a calc to test I will be happy to test it but it has to be detailed and you need to specify order (item tax/item discount - invoice tax/invoice discount) and if invoice tax is placeed before or after item tax


1 Like

In a matter of a poll I also would recommend first deducing the discount and then calculating the tax.

Well, since you take a grab on the tax calculation I would like to point out something else:

There are countries that work with a withholding tax.

I.e. the invoice needs to list the brutto items.
Then you need to deduce the withholding tax and in the bottom line you will find the net total, which the customer is supposed to pay like this:

2x 187,50 375,00
Total (including tax) 375,00
The withholding tax of 20% is payed by the receiving party 75,00
Total net 300,00

I managed to adapt the template to print the right invoice.

But, since the invoice is linked to 20% tax and the customer payed 300, invoiceplaine thinks the total of this invoice is 300 plus 20% tax (360) and thus thinks I am still lacking 60€.

My questions is, if you also want to take into account such sceanrios, where the tax rate is not added on top but deduced from the total.

1 Like

Calculation 1 is fine!

I think this scenario should be implemented as a setting besides the order settings. Thanks for the hint.

It is absolutely possible that there is no such thing as invoice tax in your country. If so, just ignore the invoice tax part.

That’s the goal of what I have dev with @Kovah you are free to order item tax/item discount as you wish and invoice tax/invoice discount as you wish

But if some people has a calc to let us test it will be cool (but not the start price and final price we really need all settings invoice tax place before/after …) and all detailed :slight_smile:

Calculate tax and item price automatically by inputting invoice total

eg item I want to sell for Rs 200 including tax, then

item total = 200
tax rate = 18%
need to calculate
item tax = ?
item Price = ?

(item total * 100 ) / (100 + Tax rate) = item Price
item tax = (item Price /100) *tax rate

(item total * 100 ) / (100 + Tax rate) = item Price
200 * 100 = 20000
20000/118 = 169.49
item price =169.49

Could you put your suggestion into a more readable format like explained in the first post?

Calculation that I gave is for peoples who wants tax to be calculated automatically.

eg like retailers who sell there product directly based on mrp, for them it will be difficult to calculate and insert item pricing.

so to fix this will have to create input box for ‘item total’ .
here vendors will enter MRP and qty, and tax will be calculated automatically.

in above comment MRP == 200.

i just make a calculation, if seller sell a product at specific price (including all discounts and taxes) and discount & taxes calculated on the basis on selling price automatically.
i just create input field where seller input their final prices, discount & taxes calculated on the basis on final prices.
so customer will input

  1. Item Price
  2. Tax Rate
  3. Item Final Price (Selling Price)

when save invoice, Item Final Price Remains same as entered and there are changes in discount & taxes according to Item Final Price. As i make tax calculation after any discount.

item_sp >>> Item Final Price (Selling Price)

if(item_sp > 0){
itemP1 = 100 * item_sp / (100 + item_tax_rate_percent);
item_discount = item->item_price - itemP1;
item_discount_total = item_discount * item_quantity;

Listen please, this thread is not about adding new features like calculating discounts or taxes from a final item price. :warning:

This thread is just about the order of calculations in the current state.

ok, then i delete my reply, or if you have any such topic, you can transfer this to those topic

this is on the support of Siddhant_Naik’s Post

For me in Germany I need this:

item price (include taxes) x item amount = invoice total
invoice total / 1 + (tax rate in percent) = invoice tax

So in the invoice it stands like this

product 1 3,99€ 1 piece = 3,99
price without tax = 3,35
taxes includes 19% = 0,64
total = 3,99

The problem in the version 1.5.5 with prices like 3,99 the will rounding errors. Like this

3,35€ * 10 pieces = 33,50 * 0,19 taxes = 6,37 € + 33,50 € = 39,87
3,99€ * 10 pieces = 39,99 (here the taxes included in the price)
So I give my customers 12 cents.