Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c411dd5
feat(printout): ship formtxt templates for every printable kind in le…
nodemode-ai Nov 28, 2026
4cea66e
feat(crypt): report the made key's path and record its backup
nodemode-ai Nov 28, 2026
a9fd939
feat(auth): tell the owner where the key is and take the backup confi…
nodemode-ai Nov 28, 2026
6f68d0d
feat(web): a calm key backup notice and encryption facts in setup
nodemode-ai Nov 28, 2026
250c89e
fix(docform): total every line in the grid as soon as lines arrive
nodemode-ai Nov 28, 2026
87e5bc6
fix(docform): hold every line row to thirty pixels
nodemode-ai Nov 28, 2026
3442672
fix(web): keep the key notice clear of the account menu
nodemode-ai Nov 28, 2026
05fe6ec
fix(printout): fill the supplier on the goods receipt template
nodemode-ai Nov 28, 2026
2271f24
fix(docform): remove a line without moving the lines below it
nodemode-ai Nov 28, 2026
8c58784
docs(encryption): the window's key backup notice and setup facts
nodemode-ai Nov 28, 2026
2bb6f06
docs(print): describe the formtxt templates for every kind and the pa…
nodemode-ai Nov 28, 2026
2944450
docs(printout): log the per-kind templates and the page size choice
nodemode-ai Nov 28, 2026
5437121
docs(logs): log the key backup notice and the zero-decimal dashboards
nodemode-ai Nov 28, 2026
cedce3b
feat(auth): route for the owner's key backup confirmation
nodemode-ai Nov 28, 2026
5b73059
feat(window): show the key backup notice to the owner
nodemode-ai Nov 28, 2026
dab681d
fix(docform): keep the account hint box a fixed width
nodemode-ai Nov 28, 2026
f8c73e2
docs(web): log the thirty pixel line rows and the grid totals
nodemode-ai Nov 28, 2026
3e68c03
fix(window): style the key notice from a stylesheet so the content po…
nodemode-ai Nov 28, 2026
f67ba4f
chore(release): 0.13.9
nodemode-ai Nov 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# Changelog

## 0.13.9

Every printable document has a FormTxt template, document lines are tighter and add up as you type, and the window tells the owner to back up the key.

### New
- **FormTxt templates for every printable document:** quote, sales order, invoice, purchase order, purchase invoice, goods receipt and statement, each in Letter and A4. `formledger formtxt-template KIND` writes one, `--a4` picks A4, and `formledger formtxt-template --all --out DIR` writes all 14. Open them once in FormTxt and FormLedger finds each by its name.
- **Key backup notice:** when FormLedger made the key itself, as the desktop app does, the owner sees a notice saying the books are encrypted, where the key file is and that losing it loses the books, until they press "I have backed up the key". Setup always shows whether the books are encrypted, where the key is and whether it is backed up.

### Improved
- **Document lines are 30 pixels tall,** down from 47, with no empty band under each line. A line's error shows as a small tag on the line and moves nothing.
- **Removing a line** no longer moves the lines below it.

### Changed
- **FormTxt pages follow the plain page's size:** Letter for USD, A4 for other currencies.

### Fixed
- A document started from a template showed no amounts and totals of 0.00 until it was saved. Amounts, subtotal, tax and total now show as soon as the lines appear and as you type.
- The goods receipt template was looked up under a name that did not match `FORMLEDGER_FORMTXT_TEMPLATE_GOODS_RECEIPT`.

### Known issues
- You still open the template files in FormTxt yourself; FormTxt gives an outside program no way to add a document.
- The plain renderer has no delivery note or payment receipt, so neither has a template.
- Reading the snapshot from FormCel's window was not checked for this version.

### Under the hood
- The desktop app was compiled on Linux for the first time and opened on a virtual display: it started the server, made its key once, kept using it on the second start, and the ledger file was not readable as a plain database. Dashboards were checked with a currency that has no minor unit. Not run: the packaged app on macOS or Windows.

## 0.13.0

FormLedger ships its own FormTxt templates, and a document started from a template shows where each line posts.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION := v0.13.0
VERSION := v0.13.9
GO_BUILD := CGO_ENABLED=0 go build -trimpath -ldflags "-s -w"

.PHONY: build web server check clean
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</p>

<p align="center">
<img alt="version v0.13.0" src="https://img.shields.io/badge/version-v0.13.0-eef0f4?style=flat-square">
<img alt="version v0.13.9" src="https://img.shields.io/badge/version-v0.13.9-eef0f4?style=flat-square">
<img alt="Go 1.26+" src="https://img.shields.io/badge/Go-1.26%2B-00ADD8?style=flat-square&logo=go&logoColor=white">
<img alt="TypeScript and Vite" src="https://img.shields.io/badge/TypeScript-Vite-3178c6?style=flat-square">
<img alt="License: Apache-2.0" src="https://img.shields.io/badge/license-Apache--2.0-3a3a3a?style=flat-square">
Expand Down
2 changes: 1 addition & 1 deletion cmd/HASHOUT_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Living log of all comment content, explainers, rationale, TODOs, & removed (hashed-out) code for the entry point, `embed.go`, `internal/server`, `internal/static` and `internal/startup`. Source files stay comment-free per dev-rules `sub-skills/hashout-log/SUB-SKILL.md`; everything they would have said lives here, indexed. Read it first, then edit code surgically.

Current build version: v0.13.0
Current build version: v0.13.9
Last updated: 2026-11-26 (US Eastern) · skeleton port from form.md

---
Expand Down
2 changes: 1 addition & 1 deletion cmd/formledger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func usage(w io.Writer) {
fmt.Fprintln(w, " serve run the server (default)")
fmt.Fprintln(w, " cli <command> ledger commands against the running server (formledger cli --help)")
fmt.Fprintln(w, " report snapshot write a plain read-only SQLite snapshot (--out FILE, --force; server stopped)")
fmt.Fprintln(w, " formtxt-template write FormLedger's invoice (or statement) template for FormTxt (--out FILE, default formledger-KIND.ftxt)")
fmt.Fprintln(w, " formtxt-template write FormLedger's FormTxt template for KIND (quote, order, invoice, purchase-order, purchase-invoice, goods-receipt, statement; --a4 for non-USD pages; --out FILE), or --all --out DIR for every kind in both sizes")
fmt.Fprintln(w, " keygen print a new at-rest encryption key")
fmt.Fprintln(w, " encrypt encrypt an existing plain ledger with FORMLEDGER_KEY_FILE (server stopped)")
fmt.Fprintln(w, " version print the version")
Expand Down
2 changes: 2 additions & 0 deletions docs/ENCRYPTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ The key is one line of 64 hex characters, so it can be kept as text:

Back the key up again only if you replace it; it never changes on its own. Every backup of the books (`~/FormLedger`) needs that key to open.

**The window tells the owner.** When the server made the key itself (`FORMLEDGER_KEY_HOME`, the desktop app) and the owner has not yet confirmed a backup, the owner sees a notice at the bottom of the window: the books are encrypted, the key file's path, that losing it loses the books, and how to back it up. It stays until the owner presses "I have backed up the key", which calls `POST /api/me/key-backed-up`; the server then writes `formledger.key.backed-up` (the time of the confirmation) beside the key, and the notice never shows again. Delete that file to see the notice again. The Setup hub always lists the same facts under Encryption: encrypted or not, the key file and whether a backup was confirmed. Only the owner sees either, and only the key's path is sent to the window, never the key. With your own `FORMLEDGER_KEY_FILE` there is no notice: you made the key, so its backup is yours. (In this build the route line in `internal/auth/module.go` and the notice's mount in `web/src/ui/app.ts` are with their owners; both were run and checked in a private copy.)

## Turning it on for an existing ledger

A key given to a plain ledger is refused, so a plain ledger is never opened as if it were encrypted:
Expand Down
32 changes: 27 additions & 5 deletions docs/PRINT.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The same document gives the same bytes every time: the PDF's creation and change

## The page

Letter for documents in USD, A4 for every other currency; there is no page size setting yet. The page carries the company name (the instance name), the document kind, number, date, due date, currency and status, the customer or supplier, a line table (item, description, quantity, unit price, tax rate, amount before tax) whose header repeats on every page and whose rows wrap, the subtotal, tax and total from the document itself, the notes, and "Page N of M". Drafts carry "DRAFT" and cancelled documents "CANCELLED" across every page. Amounts use the app's own money formatting with thousands separators.
Letter for documents in USD, A4 for every other currency; there is no page size setting yet. A page FormTxt draws follows the same rule (see Page size under FormTxt). The page carries the company name (the instance name), the document kind, number, date, due date, currency and status, the customer or supplier, a line table (item, description, quantity, unit price, tax rate, amount before tax) whose header repeats on every page and whose rows wrap, the subtotal, tax and total from the document itself, the notes, and "Page N of M". Drafts carry "DRAFT" and cancelled documents "CANCELLED" across every page. Amounts use the app's own money formatting with thousands separators.

## Fonts and characters

Expand All @@ -39,20 +39,42 @@ Rendering goes through a list of renderers, each of which draws a document and a

- It finds FormTxt the way FormTxt's own tools do (`setup/report.py`, `setup/catalogue.py`): the engine at `http://127.0.0.1:$FORMTXT_ENGINE_PORT`, port `8210` when unset. There is no discovery file.
- It posts to `/api/reports/run` with the data as `records` (one record per line, the document's header fields repeated on each: `company`, `title`, `number`, `date`, `dueDate`, `customer`, `customerName`, `supplier`, `supplierName`, `currency`, `status`, `memo`, `subtotal`, `taxTotal`, `total`, then `item`, `description`, `quantity`, `unitPrice`, `taxRate`, `lineSubtotal`; a statement's are `customer`, `customerName`, `currency`, `from`, `to`, `opening`, `closing`, then `lineDate`, `event`, `reference`, `debit`, `credit`, `balance`), `mode` `list`, `format` `pdf`, and `out` a file in a fresh temporary folder that it reads back and removes. Amounts arrive formatted, as on the plain page.
- The template is a FormTxt document. FormLedger ships one for invoices (below). When `FORMLEDGER_FORMTXT_TEMPLATE_INVOICE` is unset, FormLedger reads FormTxt's document list (`GET /api/documents`, a read FormTxt answers any local caller) and uses the newest document titled `FormLedger invoice template`. A set id always wins, per kind: `FORMLEDGER_FORMTXT_TEMPLATE_INVOICE`, `_QUOTE`, `_ORDER`, `_PURCHASE_ORDER`, `_PURCHASE_INVOICE`, `_GOODS_RECEIPT`, `_STATEMENT`. Any other kind with no id set goes to the plain renderer.
- The template is a FormTxt document. FormLedger ships one for every printable kind (below). When the kind's `FORMLEDGER_FORMTXT_TEMPLATE_*` is unset, FormLedger reads FormTxt's document list (`GET /api/documents`, a read FormTxt answers any local caller) and uses the newest document with the kind's exact title for the document's page size, for example `FormLedger invoice template` for a USD invoice and `FormLedger invoice template (A4)` for a EUR one. A set id always wins, per kind: `FORMLEDGER_FORMTXT_TEMPLATE_INVOICE`, `_QUOTE`, `_ORDER`, `_PURCHASE_ORDER`, `_PURCHASE_INVOICE`, `_GOODS_RECEIPT`, `_STATEMENT`; FormLedger then uses that document whatever its page size.
- Any failure (no engine, a refusal, a timeout of 13 seconds, a file that is not a PDF) goes to the plain renderer. When FormTxt answered but did not draw, the response carries the reason in `X-FormLedger-Renderer-Note` (path-escaped) and `cli print` writes it on standard error under the renderer line. A 403 reads: `FormTxt refused to draw the page, so FormLedger drew the plain page. FormTxt said: No FormTxt window is open. Start it with ./formtxt and open the app, then retry. Open FormTxt, allow outside agents when it asks, or turn on Allow outside agents in its Preferences under Privacy, then print again.` A template id FormTxt does not hold (404) names the environment variable to set. The wait is 13 seconds, the owner's choice: a person who has not answered FormTxt's question by then gets the plain page and prints again after answering. FormTxt itself waits up to 180 seconds for the answer and withdraws the question when FormLedger hangs up.

### The shipped invoice template
### The shipped templates

| Kind | Title (Letter, for USD) | Data file | What it adds to the invoice layout |
| --- | --- | --- | --- |
| `quote` | `FormLedger quote template` | `formtxt_quote.json` | "Quote for" the customer; the due date reads "Valid until" |
| `order` | `FormLedger order template` | `formtxt_order.json` | sales order, "Bill to" the customer |
| `invoice` | `FormLedger invoice template` | `formtxt_invoice.json` | |
| `purchase-order` | `FormLedger purchase order template` | `formtxt_purchase_order.json` | "Supplier" name and code |
| `purchase-invoice` | `FormLedger purchase invoice template` | `formtxt_purchase_invoice.json` | "Supplier", and "Supplier ref" (`supplierRef`) |
| `goods-receipt` | `FormLedger goods receipt template` | `formtxt_goods_receipt.json` | "Received from" the supplier, "Supplier ref", no due date, lines with item, description and quantity only, no amounts |
| `statement` | `FormLedger statement template` | `formtxt_statement.json` | |

Each data file is FormLedger's own, in FormTxt's `.ftxt` document format, embedded in the binary under `internal/printout/`. The records FormLedger sends now also carry `supplierRef`. A delivery note and a payment receipt are not printable kinds (the plain renderer draws only the kinds in the table at the top), so no template ships for them.

`./formledger formtxt-template KIND [--a4] [--out FILE]` writes one kind (default `invoice`, file `formledger-KIND.ftxt`, or `formledger-KIND-a4.ftxt` with `--a4`). `./formledger formtxt-template --all --out DIR` writes all 14 files, every kind in both sizes.

### Page size

FormTxt's `/api/reports/run` takes no page size (its fields are `template`, `data`, `mode`, `groupBy`, `format`, `out`, `overwrite`, `title`); the size is the template's own section page. So each kind ships in two sizes made from one data file: the file holds the Letter page (612 by 792 points), and `--a4` writes the same document with an A4 page (595.28 by 841.89 points), side margins of 51.64 points so the tables keep their 492 point width, and ` (A4)` added to the title. FormLedger asks FormTxt for the title that matches the plain page's rule: Letter for USD, A4 for every other currency, for documents and statements alike. A person who prints only in USD opens only the Letter files and never sees the A4 ones, and the reverse; only someone who prints in both opens both. When the matching size is not in FormTxt, the plain page is drawn (in the right size) with the note `FormTxt holds no document named FormLedger invoice template (A4), so FormLedger drew the plain page. Run ./formledger formtxt-template invoice --a4, ...`. FormLedger never uses a template of the other size, so a FormTxt page is never a different size than the plain page would be.

**Run on 2026-11-27 against FormTxt 0.38.0** (a copy on port 8901 with its own data folder, window in headless Chrome; FormLedger 0.13.9 work on 8801, seeded with `fl_exit.py --seed`, no `FORMLEDGER_FORMTXT_TEMPLATE_*` set). One draft of each kind was made through the API (quote, sales order, invoice for ACME; purchase order, purchase invoice and goods receipt for a supplier NORD with supplier ref NP-4471; an invoice in EUR for a EUR customer) and printed by id with `cli print`. Before the templates were in FormTxt each printed plain with the missing-template note (the EUR invoice's note named the `(A4)` title). After the 14 files from `--all` were opened through File > Open or import file and Always allow was clicked once, all eight prints (the seven kinds plus the EUR invoice) were drawn by FormTxt in 0.28 to 0.88 seconds. Page sizes: every USD document and the statement 612 by 792 points (Letter), the EUR invoice 595.28 by 841.89 points (A4), the same as the plain renderer gave for each. The statement had no rows because nothing was posted.

### How the template is used

FormLedger carries an invoice template as its own data, written in FormTxt's `.ftxt` document format (`internal/printout/formtxt_invoice.json`, embedded in the binary). It is titled `FormLedger invoice template` and holds the company name, the document title and number, date, due date, currency and status, the bill-to customer name and code, a line table whose header row repeats on every page and whose second row is marked to repeat once per line (`item`, `description`, `quantity`, `unitPrice` as Rate, `taxRate`, `lineSubtotal` as Amount), then subtotal, tax, total with the currency, the notes, and "Page N of M" in the footer. A statement template ships the same way (`internal/printout/formtxt_statement.json`, titled `FormLedger statement template`, written by `./formledger formtxt-template statement`): company, period, customer name and code, currency, opening balance, one repeating row per event (`lineDate`, `event`, `reference`, `debit`, `credit`, `balance`) and the closing balance. With no `from` the heading reads "Statement to" and the end date. The two lookups are separate, so each kind uses its template once it is in FormTxt.

FormLedger does not put the template into FormTxt by itself. FormTxt gives an outside program no way to create a document: every write but `/mcp` and `/api/reports/run` needs the key only FormTxt's own window holds for that launch, `/mcp` runs the window's editing commands (none of which types text or opens a file from a path), and `/api/reports/run` merges into a document that must already be in FormTxt's library. Taking the window's key from its session storage, or writing into FormTxt's data folder, would get past FormTxt's consent, so FormLedger does neither. The person adds it once:

1. Run `./formledger formtxt-template` (or `--out FILE`). It writes `formledger-invoice.ftxt` and names the full path.
1. Run `./formledger formtxt-template KIND` (add `--a4` for documents not in USD), or `--all --out DIR` for every kind in both sizes. It writes `formledger-KIND.ftxt` and names the full path and the title.
2. In the FormTxt window, choose File > Open or import file and pick that file. FormTxt adds it to its library as `FormLedger invoice template`. Set `FORMTXT_ENGINE_PORT` in FormLedger's server environment when FormTxt is not on 8210; no template id is needed.
3. Print once with the window open. FormTxt asks **Allow an outside agent to make changes in FormTxt?**, naming the temporary file it will write, with Deny, Allow once and Always allow all outside agents. Answer within 13 seconds, or print again after answering. Always allow saves `agentsAllowed` in FormTxt's own `settings.json` in its data folder (not the system password store), so later prints draw with no window open. Allow once lets that one print through without saving the answer (read from FormTxt's `consent`, not tried here).

Until step 2 is done, printing goes to the plain renderer with the note: `FormTxt holds no document named FormLedger invoice template, so FormLedger drew the plain page. Run ./formledger formtxt-template, open the file it writes in FormTxt with File > Open or import file, then print again.`
Until step 2 is done, printing goes to the plain renderer with the note: `FormTxt holds no document named FormLedger invoice template, so FormLedger drew the plain page. Run ./formledger formtxt-template invoice, open the file it writes in FormTxt with File > Open or import file, then print again.`

**Run on 2026-11-27 against FormTxt 0.38.0** (a copy with its own engine on port 8701 and data folder, its window built from its own frontend and opened in headless Chrome; FormLedger's server had no `FORMLEDGER_FORMTXT_TEMPLATE_*` variable set). On the fresh FormTxt library, `cli print invoice SI-2026-000001` printed plain in 0.32 seconds with the note above. The file from `formledger formtxt-template` was then opened through File > Open or import file; the next print raised FormTxt's question, Always allow was clicked 2.15 seconds in, and the page was drawn by FormTxt from the shipped template in 2.87 seconds (`printed by the formtxt renderer`): every field, the three lines, subtotal 68.13, tax 5.45 and total USD 73.58 were filled. With the window open but the question left unanswered, FormLedger gave up after 13.13 seconds and printed plain with the 13 second note. With FormTxt's engine stopped it printed plain in 0.35 seconds, since nothing answered on the port. Then `cli print statement ACME` printed plain with the statement note, the statement file was opened the same way, and the next statement print was drawn by FormTxt in 0.20 seconds with outside agents already allowed. FormTxt's report route also keeps each merged result in its own library (here `Invoice SI-2026-000001`); that is FormTxt's behavior and FormLedger does not remove it.

Expand Down
Loading
Loading