# finance.invoice.calculate This is the whole point of the registry in one function. It is about forty lines in each language and it invents no arithmetic at all: line totals, discounts, rate lookup, VAT and summation are all capabilities that already exist and are already pinned by their own vectors. VAT is calculated per line and then grouped by rate, which is the method HMRC accepts and which keeps a line's tax reconcilable against that line. The alternative - summing nets per rate first, then taxing the group - differs by a penny often enough to matter, so the choice is recorded here rather than left to whoever writes the next invoice screen. The tax point is an argument. Reprinting a 2009 invoice gives 2009 rates, because the rate lookup takes the date. 1.0.1 adds tests; behaviour unchanged.