diff --git a/docs/TODO.md b/docs/TODO.md index e520652..6535fe6 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -208,6 +208,63 @@ The `Forvaltningskostnad` figure shows kroner from `totals.admin_cost_ore`, and goes away. **Verify:** the report shows one Forvaltningskostnad figure, in kroner. +## Phase B4 — kroner on an account, and the bank (steps B4.1-B4.9) + +The owner's third review round. Kroner can live on an account as a derived balance, kroner can +move between accounts, and the costs are paid from a fictional bank account so that no real +account is touched. The steps are lettered on purpose: Phase C and Phase D keep their numbers. + +### B4.1 `docs/spec.md`, `docs/TODO.md` +Fold the approved text in: the new §3.11, and the lines that change in §3.2, §3.10, §4, §4.1, +§5.2, §7.3, §7.4, §7.6, §8 and §13, plus this phase and the decisions D28-D32. +**Verify:** the spec reads consistently, and Phase C still starts at 56 and Phase D at 72. + +### B4.2 `database.py` +Seed the bank account next to the settings and the rates: one `markets` row named `Bank` with +`kind = 'other'`, `taxable = 0` and `archived = 1`, and the setting `bank_market_id` pointing at +it. Both with `INSERT OR IGNORE`, so a second run changes nothing. +**Verify:** a fresh database has exactly one `Bank` row and a `bank_market_id`; a second run adds +nothing. + +### B4.3 `validation.py` +A `transfer_out` carries exactly one of `leg_out_sats` and `leg_out_ore`; `Til` is required when +the amount is in sats and may be empty when it is in kroner. `admin_cost` is sent as `leg_out_ore` +only: the server fills `market_id` (the bank) and the matching `leg_in_ore`, and the taxable flag +defaults to ticked. +**Verify:** eight payloads, clean and rejected, each with its Nynorsk message. + +### B4.4 `ledger.py` +`kroner_in_market(market_id, date)`, and a refusal in `rebuild()` that names the kroner shortfall; +a `transfer_out` that carries kroner consumes no lots and mirrors none. +**Verify:** the unit tests, plus a hand check of a filled account, an over-drawn one, and one that +sold sats first. + +### B4.5 `app.py` +`_sync_transfer_pair()` mirrors `leg_out_ore` for a kroner transfer and writes no pair when `Til` +is empty; `_write_transaction()` fills the bank and the second leg of an `admin_cost`; +`GET /api/markets` carries `kroner_ore` and leaves the bank out. +**Verify:** `curl` a kroner transfer in, a withdrawal, an over-drawn one and a +`Forvaltningskostnad`. + +### B4.6 `tax.py`, `export.py` +Nothing taxable changes: the cost line stays `admin_cost_ore` from the kroner out of the bank, the +bank is in no figure, and no CSV column is added. +**Verify:** the suite, and that a kroner transfer moves no figure in the report. + +### B4.7 `static/transaction.html`, `static/transaction.js` +The currency choice on `Sendt` (sats/kr) and an empty `Til` allowed for kroner. +**Verify:** in the browser, a kroner transfer, a withdrawal, and the refusal message. + +### B4.8 `static/markets.html`, `static/markets.js` +A `Kroner` column, for the real accounts only. +**Verify:** the balance is shown, it drops when kroner are transferred out, and it rises when they +arrive. + +### B4.9 `tests/test_ledger.py`, `tests/test_tax.py` +The kroner balance, the refusals, the bank's two legs leaving it at zero, and that no tax figure +moves. +**Verify:** `python3 -m unittest discover -s tests -v` — green. + ## Phase C — StartOS package (steps 56-71) ### 56. `package.json`, `tsconfig.json`, `.prettierrc`