# finance.credit-note.calculate
A credit note reverses all or part of an invoice already issued. The rule that
matters, and the one that is easy to get wrong, is the VAT rate: a credit note
adjusts the original supply and its original VAT charge (HMRC VAT Notice 700,
"The VAT guide", paragraph 18.2, https://www.gov.uk/guidance/vat-guide-notice-700),
so its VAT is at the rate that applied at the **original invoice's tax point**,
not the rate on the day the credit note is written. Crediting a 2010 invoice
today gives 17.5% VAT, because that was the rate then. The rates themselves come
from finance.tax.vat-rate through finance.invoice.calculate.
Each credit is against one line of the original invoice, either:
- **by units** (`quantity`): returned goods or days not worked, credited at the
original unit price and the original discount; or
- **by amount** (`net`): a price reduction or goodwill credit, a net amount
taken off that line, VAT added at the line's tax category.
Set exactly one of the two. The credit note is then calculated by
finance.invoice.calculate from negative lines, so it is an `Invoice` with every
amount negative, VAT per line and grouped by rate exactly as the invoice was,
and crediting the whole invoice line by line gives back its totals negated.
Each credit line keeps the original line's description.
Credits are checked against the original: a line can not be credited for more
than its net total, counting every credit against it in this note (units and
amounts together); a credit against a line that was itself a credit is refused.
Credits made on earlier credit notes are not known here; pass only what is
still available, or check the history first.
Crediting units one at a time can round differently from the whole line when
the line had a percentage discount (a 10% discount on 3 x 1.99 is rounded once
on 5.97, not three times on 1.99), so the last unit of a discounted line may be
refused by a penny. Credit the remaining units together, or the remaining
amount by `net`.