Add invoice generator and mileage logbook

Invoices: business details and logo, saved customers, numbering, GST per
line, PDF download (fpdf2), and marking paid, which records the income in
the book (split into Incl and Excl GST rows when an invoice has both) or
uses an already-imported bank deposit. Statement import treats a split
payment as the one bank line it came from.

Mileage: vehicles and trips with odometer readings, business or private
use, IRD kilometre rates entered per income year, a per-vehicle tier 1/2
claim and a CSV logbook export. Report only: nothing is added to the
cashbook or IR10.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Opus 5.5 committed 2026-10-25 18:56:30 +13:00
1 parent 4b3e5f0932
commit 177dfbc0a4
15 files changed
+2208 -10

No files matched your search

+44 -3
View File
@@ -251,6 +251,45 @@ authority, partnership or trust income, and no taxable property sales.
Entered amounts are saved per book in the database. These figures are worked out
from your records and aren't tax advice.
### Sending invoices
**Invoices** makes the invoices you send to customers, as PDFs.
- **Business details:** set your name, address, GST number, bank account, logo (PNG or
JPEG), payment terms and invoice numbering once. The logo is stored in `data/invoices`.
- **Customers:** saved for reuse. An invoice keeps the customer's details from when it
was made, so later edits to the customer don't change invoices already sent.
- **Numbers:** invoices are numbered in order (`INV-0001`, ...) when they're created.
Numbers are never reused, and a voided invoice keeps its number.
- **GST:** prices are entered excluding GST. Untick *GST* on a line for items with no GST
(for example costs passed on at cost). GST is 15% of the taxable lines, rounded once per
invoice. With a GST number, invoices that charge GST are titled *Tax invoice*.
- **Status:** a draft can be edited. Once it's marked sent, only its notes can change. Move
it back to draft to correct it, or void it.
- **Paid:** marking an invoice paid records the money in the book for the payment date,
as *Sales*. If that bank statement is already imported, pick the matching deposit, and
the bank line is used instead of adding a new one. Otherwise a new row is added, and a
statement imported later recognises it (same date and amount) as already in the book.
An invoice with GST and non-GST items becomes two rows, *Incl GST* and *Excl GST*, so
the GST return is right. *Undo payment* removes the rows it added, or puts a matched bank
line back as it was.
### Mileage
**Mileage** is a vehicle logbook. It works out the claim at IRD's kilometre rates.
- Add your vehicles, then log each trip: date, from and to, purpose, customer, and either
both odometer readings or the distance. The next trip's start reading defaults to the
last one. Readings that overlap another trip are saved with a warning.
- Untick *Business trip* for private use, so the business-use percentage is shown.
- Enter IRD's tier 1 and tier 2 rates for each income year (April to March). They
change every year, so none are built in. Tier 1 covers each vehicle's first 14,000
business km in the year, and tier 2 the rest.
- **Export logbook (CSV)** downloads the year's trips for your records.
Mileage is a report only. It doesn't add anything to the cashbook or the IR10, so
reimbursements you pay yourself from the bank aren't counted twice.
### Books kept in spreadsheets
Earlier versions kept each book as an `.ods` file in `data/`. At startup the app copies
@@ -303,11 +342,13 @@ src/
main.py app setup, security middleware, startup
config.py settings from the environment / .env
deps.py current user, admin check, database connections
routers/ auth, users, books, statements and page routes
services/ accounts, statement files, LibreOffice
routers/ auth, users, books, statements, invoices, mileage and page routes
services/ accounts, statement files, invoice PDFs, LibreOffice
db/, schemas/ account tables (SQLAlchemy) and request/response models
static/ the web pages (cashbook, sign-in, register, users)
static/ the web pages (cashbook, sign-in, register, users), invoices.js, mileage.js
ledger.py SQLite storage: books, transactions, GST and summaries
invoices.py customers, invoices, numbering, GST and recording payments
mileage.py vehicle logbook and the kilometre-rate claim
tax.py IR10 and IR4 figures
statements.py reads ANZ CSV and PDF statements, GST/category guesses
export.py exports a book to .xlsx/.ods/.csv (also a CLI)