aboutsummaryrefslogtreecommitdiff
path: root/docs/INVOICING.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/INVOICING.md')
-rw-r--r--docs/INVOICING.md38
1 files changed, 31 insertions, 7 deletions
diff --git a/docs/INVOICING.md b/docs/INVOICING.md
index 7c6ce2e..de584cf 100644
--- a/docs/INVOICING.md
+++ b/docs/INVOICING.md
@@ -14,7 +14,8 @@ the generated PDF reproduces the existing document.
- Customer register (name, address, momsreg.nr, e-mail, er referens,
payment terms), owner-editable and audited.
- One-page invoice document generated by bokfd, visually matching the
- existing Google Sheets export (same grid, colours and wordmark).
+ existing Google Sheets export (same grid, colours and `FAKTURA` wordmark;
+ the header shows the organization name).
- A configurable, always-increasing invoice number series per org, plus an
OCR reference that Bankgiro accepts.
- Issue in one action: number + PDF (stored as an immutable attachment) +
@@ -49,13 +50,19 @@ Colours:
| Body text | `#314c59` |
| Header/table text on the bar | `#ffffff` |
+The header bar's colour is the shared document setting
+`document_header_color` (`#rrggbb`, default `#314c59`, also used by the
+lönebesked).
+
Fonts:
- Body: Helvetica (PDF base-14, metrically compatible with Arial); no
embedding.
-- Wordmark `MAKANDRA AB` and `FAKTURA`: Comfortaa Bold (SIL OFL) as
- pre-generated vector outlines, drawn as filled paths. No font file or
- TrueType machinery at runtime.
+- Wordmark `FAKTURA`: Comfortaa Bold (SIL OFL) as pre-generated vector
+ outlines, drawn as filled paths; no font file or TrueType machinery at
+ runtime. The header's left side prints the organization `name` in
+ Helvetica-Bold, scaled down and truncated with `...` if it would reach
+ `FAKTURA`.
Grid (points, origin top-left; refined against the originals in
`tests/` golden comparisons):
@@ -63,7 +70,7 @@ Grid (points, origin top-left; refined against the originals in
| Element | x | y |
|---|---|---|
| Header bar (x 17.3–577.7) | 17.3 | 53.3–75.7 |
-| Wordmark `MAKANDRA AB` (ink left/baseline) | 21.74 | 69.14 |
+| Header name (org `name`, ink left/baseline) | 21.74 | 69.14 |
| `FAKTURA` (ink right/baseline) | 576.87 | 69.14 |
| Info labels (bold 7.285 pt), right-aligned | 113.98 | 101.11 + 14.71/row |
| Info values (9.107 pt), left-aligned | 118.87 | same rows |
@@ -206,6 +213,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 +223,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 +243,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 +252,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),