Subtotal of 2 items
- Input
- 3x R$ 45,50 + 1x R$ 120,00
- Expected output
- R$ 256,50
Each line (quantity times unit price) is rounded to 2 decimals before summing, which keeps cents truncated on individual lines from piling up in the subtotal.
how to make an invoice
An invoice is not a price list, it is a document with a fixed calculation order: line items sum into a subtotal first, then discount reduces the base, only then tax applies, and getting that order wrong changes the final amount the client pays.
Each line (quantity times unit price) is rounded to 2 decimals before summing, which keeps cents truncated on individual lines from piling up in the subtotal.
The discount is subtracted before tax enters the calculation; applied after tax instead, the client would pay tax on an amount they never actually owed.
$19.72 in tax comes from 246.50 × 0.08; currency formatting runs through Intl.NumberFormat per currency (BRL uses a decimal comma, USD a decimal point), so the same number prints differently depending on the chosen currency.
Click “Print / PDF”. The tool opens the browser's print dialog showing only the invoice sheet (without the editing fields), and at the print destination you simply choose “Save as PDF”. This method uses the browser's own PDF engine, producing a crisp, selectable file with no external servers involved.
Before: the discount reduces the subtotal into a taxable base, and only that smaller base receives the tax rate; applying the steps in reverse order would charge tax on an amount the client never actually paid.
In structure, yes: issuer, recipient, line items, subtotal, discount, tax and total appear in both; what changes country to country is the tax requirement layered on top (an official fiscal receipt, a sequential serial number, tax declared separately), which this commercial document does not replace.
Because the total depends on two more variables independent from the subtotal: the flat discount applied and the chosen tax rate; two identical subtotals with a different discount or rate close on different totals even with the same line items.
Yes, the tax rate is a free field from 0 to 100%; at 0%, the total is exactly the taxable base (subtotal minus discount), with no extra amount added on top.
#0001
Issued: 2026-09-09
Due: 2026-09-09
| Description | Qty | Unit price | Total |
|---|---|---|---|
| — | 1 | R$ 0,00 | R$ 0,00 |
The invoice is built and rendered entirely in your browser. No data, amounts or logo are sent to any server, the PDF is generated by your browser's own print function.