diff options
| author | Anders Betts <anders.betts@gmail.com> | 2026-09-21 23:09:57 +0200 |
|---|---|---|
| committer | Anders Betts <anders.betts@gmail.com> | 2026-09-21 23:09:57 +0200 |
| commit | 8350815a8c6987b288551848eda1c678739c8d4a (patch) | |
| tree | 04ef3c56e10fa8b06768465910d10a57779e8731 /docs/INVOICING.md | |
| parent | bf9012dad7ef34bbbfb073bc0f37b0161f0496f3 (diff) | |
| download | bokf-0.1.62.tar.gz bokf-0.1.62.zip | |
invoices: text rows, duplicate and payment link (schema v12); smtp address checksv0.1.62
Diffstat (limited to 'docs/INVOICING.md')
| -rw-r--r-- | docs/INVOICING.md | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/docs/INVOICING.md b/docs/INVOICING.md index 7c6ce2e..a04c869 100644 --- a/docs/INVOICING.md +++ b/docs/INVOICING.md @@ -206,6 +206,8 @@ CREATE TABLE invoices ( CHECK (status IN ('issued','credited')), document_id INTEGER, voucher_id INTEGER, + paid_date TEXT NOT NULL DEFAULT '', + payment_voucher_id INTEGER, last_sent_at TEXT, last_sent_to TEXT, created_at TEXT NOT NULL, @@ -214,7 +216,9 @@ CREATE TABLE invoices ( UNIQUE (org_id, number), FOREIGN KEY (org_id, customer_id) REFERENCES customers(org_id, id), FOREIGN KEY (org_id, document_id) REFERENCES attachments(org_id, id), - FOREIGN KEY (org_id, voucher_id) REFERENCES vouchers(org_id, id) + FOREIGN KEY (org_id, voucher_id) REFERENCES vouchers(org_id, id), + FOREIGN KEY (org_id, payment_voucher_id) + REFERENCES vouchers(org_id, id) ) STRICT; CREATE TABLE invoice_rows ( @@ -232,6 +236,7 @@ CREATE TABLE invoice_rows ( vat_code TEXT NOT NULL DEFAULT '25' CHECK (vat_code IN ('25','12','6','0','rc','eu')), account TEXT NOT NULL DEFAULT '', + is_text INTEGER NOT NULL DEFAULT 0, UNIQUE (org_id, id), UNIQUE (org_id, invoice_id, line_no), FOREIGN KEY (org_id, invoice_id) REFERENCES invoices(org_id, id) @@ -240,7 +245,19 @@ CREATE TABLE invoice_rows ( `vouchers.source` gains `invoice` (and later `credit`): the CHECK constraint must be widened. `invoice_rows` are written once at issue; `invoices` only -changes `status`, `last_sent_*` and (later) credit links. +changes `status`, `last_sent_*`, `paid_date`/`payment_voucher_id` and (later) +credit links. Schema v12 adds `invoice_rows.is_text` and the two payment +columns with forward `ALTER TABLE`s; the composite foreign key on +`payment_voucher_id` exists in fresh databases only (SQLite cannot add one +later), and `invoice.pay` validates the reference in code either way. + +A **text row** (`is_text`) is a free-text line in the table: only +`description` is meaningful, it has no quantity, unit, price or VAT and +contributes nothing to the totals or the posting voucher. It renders in the +description column only. Every invoice still needs at least one priced row. +When an invoice is marked **paid** (`invoice.pay`), `paid_date` is the +payment voucher's date and `payment_voucher_id` links it; partial payments +are not modelled. Customer seed: Andra bygg AB (Solna, SE559232855201, Eric Lejeby, 30), NZ Bygg AB (Bromma, SE559264837101, Valentyne Schnelle, 30), |
