Invoice mistakes usually happen when tax and discount logic is unclear. The safest structure is: line subtotal, line tax, line discount, then final line total.

Use this formula per item: base = quantity × unit price. Tax amount = base × tax rate. Discount amount = base × discount rate. Line total = base + tax amount − discount amount.

After all lines are calculated, sum subtotals, taxes, and discounts separately. Show those values transparently before the final total. This helps clients validate and pay faster.

If your business uses multiple tax rates, keep every line independent. Never apply one global percentage without checking local rules first.