Wrong calculation order

I think you mean the discount for each item in invoice/quote. For invoices you must change following lines in application/modules/invoices/models/mdl_item_amounts.php :

$item_subtotal = $item->item_quantity * $item->item_price;
//$item_tax_total = $item_subtotal * ($item->item_tax_rate_percent / 100);
$item_discount_total = $item->item_discount_amount * $item->item_quantity;
$item_tax_total = ($item_subtotal - $item_discount_total) * ($item->item_tax_rate_percent / 100);
$item_total = $item_subtotal + $item_tax_total - $item_discount_total;

And the same way for quotes in application/modules/quotes/models/mdl_quote_item_amounts.php :

$item_subtotal = $item->item_quantity * $item_price;
// $item_tax_total = $item_subtotal * ($item->item_tax_rate_percent / 100);
$item_discount_total = $item->item_discount_amount * $item->item_quantity;
$item_tax_total = ($item_subtotal - $item_discount_total)* ($item->item_tax_rate_percent / 100);
$item_total = $item_subtotal + $item_tax_total - $item_discount_total;

Short solution:

  1. Delete/comment old line for $item_tax_total
  2. Calculate $item_discount_total first
  3. Substract $item_discount_total first from $item_subtotal and than calculate $item_tax_total

@Kovah May you patch this issue in next version?

Hi, I’ve tried all posted solutions and haven’t been able to solve the discount order issue. I need the discount to be calculated before the tax is applied, but no matter what I change it won’t have an effect. It even shows after the tax when creating new quotes.

Have anyone found a working solution to this. Also is this an error or is how it’s intended in the first place, because if it is, it would be great to have a setting to use it one way or another.

Added an issue report for that.
https://development.invoiceplane.com/browse/IP-367