diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/PAYROLL.md | 19 | ||||
| -rw-r--r-- | docs/PROTOCOL.md | 52 | ||||
| -rw-r--r-- | docs/STATE.md | 70 | ||||
| -rw-r--r-- | docs/TUI-GUIDELINES.md | 17 |
4 files changed, 107 insertions, 51 deletions
diff --git a/docs/PAYROLL.md b/docs/PAYROLL.md index b821754..b78aeba 100644 --- a/docs/PAYROLL.md +++ b/docs/PAYROLL.md @@ -5,7 +5,7 @@ Status: Design draft · 2026-09-21 · License: GPL-3.0-or-later Payroll for a small Swedish AB that runs monthly salaries from the books. Wave 1 is the engine and the mandatory steps; the employee is the owner but the schema and commands are multi-employee from the start. Wave 2 (the -lönebesked PDF and its delivery) is done; wave 3 is the TUI. +lönebesked PDF and its delivery) and wave 3 (the TUI) are done. ## 1. Scope @@ -227,12 +227,19 @@ the base is the gross. SMTP configuration `SMTP_NOT_CONFIGURED` and a failed delivery `SMTP_FAILED` (the stored attachment stays linked). `dry_run` validates, renders and stores nothing. See `PROTOCOL.md` §7.12. -- **TUI — Lön** (new section after Fakturering): `Lönekörningar` (list, - Ctrl+N for a new run), `Anställda` under Register, and a **Skattetabeller** - action/status that fetches and warns. +- **TUI — Lön** (done, `clients/screens_payroll.c`): `Lönekörningar` (list, + Ctrl+N for a new run) under Lön, `Anställda` under Bolaget, and a + **Skattetabeller** screen (via System, since the tables are national) + with status, the Skatteverket fetch and the offline file import. - The run screen shows the preview (F5), posts with Ctrl+Enter after - confirmation, then offers the buttons **Lönebesked**, **AGI-underlag** and - **Betala skatt & avgifter** as manual steps. + confirmation, then offers the buttons **Lönebesked** (saves/opens the + PDF), **AGI-underlag** (`payroll.agi` in a pager, owner only) and + **Betala skatt & avgifter** (`payroll.pay_tax` with a date prompt) as + manual steps. Steps that do not apply yet are dimmed with the reason. + Posting and paying show the resulting voucher as `V-<n>`. +- The list title warns when the current year's tax tables are missing; a + new run is refused with a pointer to Anställda when nobody has a monthly + salary. ## 7. Testing diff --git a/docs/PROTOCOL.md b/docs/PROTOCOL.md index ebce8bf..76197d9 100644 --- a/docs/PROTOCOL.md +++ b/docs/PROTOCOL.md @@ -378,8 +378,9 @@ resolved rows in a dry run. `default_series` (1–8 characters, e.g. `A`, `V-`, `A `) is used when `voucher.post` carries no `series` and as the default series for new -templates. `attachment_dir` (a path, up to 255 characters) is the folder the -TUI file browser opens in when attaching underlag. `bank_account` (digits +templates. `attachment_dir` (a path, up to 255 characters) is accepted for +compatibility, but the TUI file browser now remembers the directory of the +last picked attachment client-side. `bank_account` (digits only, up to 10 characters, default `1930`) is the account `bank.import` uses when the request carries no `account`. `invoice_receivable_account` (default `1510`) and `invoice_revenue_account` (default `3001`) are the receivable and @@ -925,6 +926,26 @@ commands. Implemented screens (0.1.0-dev): number, e-mail, your reference, payment days, notes). Ctrl+N creates, Enter edits (F5 validates with a dry run, Ctrl+Enter saves), `d` archives/reactivates. +- **Lönekörningar** — the monthly payroll runs (`payroll.run_list`, newest + period first) with status (`bokförd`/`betald`), gross and net. Ctrl+N + starts a new run (period YYYY-MM and pay date, defaulting into the + selected fiscal year) when an active employee with a monthly salary + exists, Enter opens an existing run. The run screen shows the status and + totals, `F5` previews (`payroll.run_preview` for a new run, the stored + lines for a posted one), `Ctrl+Enter` posts after confirmation + (`payroll.run_post`, showing the voucher), and the manual steps are the + action rows **Lönebesked** (PDF via `payroll.payslip`), **AGI-underlag** + (`payroll.agi`, owner only) and **Betala skatt & avgifter** + (`payroll.pay_tax`); a disabled step names its reason. The list title + warns when the current year's tax tables are missing. +- **Anställda** — the employee register (name, masked personnummer, salary, + tax table/column, e-mail). Ctrl+N creates, Enter edits (an empty + personnummer keeps the stored one), `d` archives/reactivates; F5 + validates with a dry run and Ctrl+Enter saves. +- **Skattetabeller** (via **System**) — stored tax table years, the current + year's status, fetch time and source. Owners fetch Skatteverket's official + monthly table (`payroll.tax_tables_fetch`) or import a file offline + (`payroll.tax_tables_import`). - **Rapporter** — saldobalans, resultaträkning, balansräkning, moms, inkomstdeklaration (INK2/SRU), årsredovisning (K2 text draft) and kontolista (all accounts with type, moms treatment, SRU and status). @@ -939,18 +960,27 @@ commands. Implemented screens (0.1.0-dev): events, AGM and payment dates, proposed dividend, employees, other notes), edited per field; a new fiscal year inherits the stable fields. The årsredovisning draft reads them without prompting. -- **Företagsuppgifter** — the org record (name, org number, VAT number, - address, e-mail, phone, moms period, framework, fiscal-year start month), - plus the invoice bankgiro and "vår referens"; editable in place, only - owners can save, others see it read-only. The accounting accounts and the - SMTP transport live in **Inställningar**. -- **Revision** — chain verification and behandlingshistorik. +- **Bolaget** — the dashboard's hub for the org's master data: + **Företagsuppgifter** (name, org number, VAT number, address, e-mail, + phone, moms period, framework, fiscal-year start month), editable in + place by owners, others see it read-only; **Fakturauppgifter** + (standardserie, fordringskonto, intäktskonto, bankgiro, vår referens) and + **E-post (SMTP)** (host, port, user, sender, reply-to, security, + password), both `settings.set` and open to bookkeepers; + **Styrelseledamöter**; and the registers **Anställda**, **Kunder** and + **Momsregler**. +- **System** — the hub with **Skattetabeller** and **Revision**. The file + browser starts in the directory of the last picked attachment (remembered + in the client's `tui.conf`) and falls back to `$HOME` when it is gone. +- **Revision** (via **System**) — chain verification and + behandlingshistorik. **Ctrl+N is the universal "add" key**: it starts a new verifikat from the dashboard, the voucher list and the voucher detail view; a new mall from the -Mallar menu; a new fiscal year from the year picker; and maps to the editor -in Ingående balans and to file upload in Underlag. F5 is the universal -refresh. Hints show the keys per screen. +Mallar menu; a new customer or employee from their registers; a new payroll +run from Lönekörningar; a new fiscal year from the year picker; and maps to +the editor in Ingående balans and to file upload in Underlag. F5 is the +universal refresh. Hints show the keys per screen. **Ctrl+R reloads the client in place** (for hot-reloading after a rebuild): it re-execs the installed binary with `--org`, `--fy` and `--screen NAME` diff --git a/docs/STATE.md b/docs/STATE.md index 4425b10..929ddf1 100644 --- a/docs/STATE.md +++ b/docs/STATE.md @@ -6,34 +6,49 @@ Read with `AGENTS.md` (rules) and `docs/TUI-GUIDELINES.md` (UI conventions). ## Status Working self-hosted bookkeeping system, not production-proven. Backend ledger -core is complete, as are invoicing and the payroll engine; filing/year-end -work and the payroll TUI remain. TUI is usable and exercised by -`make test-pty` (golden screen-text scenarios); `make test` covers the -server/protocol/ledger, the TUI widget unit tests and the docs consistency -check. +core is complete, as are invoicing, the payroll engine and the payroll TUI; +filing/year-end work remains. TUI is usable and exercised by `make test-pty` +(golden screen-text scenarios, now including the payroll run and the +lönebesked); `make test` covers the server/protocol/ledger, the TUI widget +unit tests and the docs consistency check. ## Resume here (2026-09-21) -- **Deployed**: `v0.1.54`, healthy on `nas` (Alpine runtime, static aarch64 +- **Deployed**: `v0.1.59`, healthy on `nas` (Alpine runtime, static aarch64 binaries cross-compiled on this machine — ~20 s, the host only assembles - the image; image 33.7 MB, no `libssl3`). `main` is ahead of the deployment: - payroll (schema v11), the query helpers and the mail fixes are **not - deployed** yet — deploy before the human tries payroll in the TUI. -- **Next task**: the **Lön** TUI section (wave 3) per `docs/PAYROLL.md` §6: - `Lönekörningar` (list + Ctrl+N), `Anställda` under Register, a - `Skattetabeller` fetch/status action, and the run screen with F5 preview, - Ctrl+Enter post and the manual buttons Bokför, Lönebesked, AGI-underlag, - Betala skatt & avgifter. -- **Follow-ups from the payroll waves**: fold `payroll.settings_get/set` into + the image; image 33.7 MB, no `libssl3`). `v0.1.55` brought the payroll + server waves (schema v11: employees, tax tables, lönebesked) and the + payroll TUI; `v0.1.56` the **Bolaget** hub; `v0.1.57` the flat main menu + without section headings, the **System** hub (Skattetabeller, Revision) + and the client-side remembered attachment directory; `v0.1.58` loads the + system CA bundle explicitly so the static binaries can verify TLS (the + Skatteverket fetch, SMTP, static clients); `v0.1.59` fixes form saving on + modern terminals (modifyOtherKeys level 2, Kitty keyboard protocol, and + `^Enter/F9` in the hints). The live database migrated v9 → v11 on the + v0.1.55 startup with the automatic pre-migration snapshot in + `var/db/backup/`. `main` and the tags are pushed to `nas`. +- **Next tasks (payroll follow-ups)**: fold `payroll.settings_get/set` into `settings.get/set` (cmd_settings.c was busy during wave 1); settle the over-80k % rule (SKV 433 leaves it ambiguous — currently a clear - `INVALID_ARGS`); move `invoice.send` to the shared `src/mail.c`; add a pty - scenario for the payslip. -- **Already merged on main since the last deploy**: payroll schema v10/v11 + - employees/tax tables/runs/payslip (`e692f0f`, `4488b6c`), `mail.c` + - `smtp_reply_to` (`e25a8c9`), query helpers `db_row_json`/`req_list`/ - `req_exec` (`b1956aa`), and a Makefile fix that tracks the test binaries' - `.d` files (a stale `smtp_check.o` hung `make test`). + `INVALID_ARGS`); move `invoice.send` to the shared `src/mail.c`. The TUI + has no screen for the payroll account/rate settings yet (they are + defaults and can stay server-side until the fold). +- **Done in the TUI wave**: `clients/screens_payroll.c` with Lönekörningar + (list + Ctrl+N, run screen with F5 preview, Ctrl+Enter post after + confirmation and the action rows Lönebesked, AGI-underlag, Betala skatt & + avgifter), Anställda under Företag and the Skattetabeller + fetch/import/status screen under System. A pty scenario posts a run and + fetches its lönebesked, so the payslip PDF path is exercised end to end. +- **Menu (2026-09-21)**: the dashboard is one flat list without section + headings: Verifikat, Underlag, Bankavstämning, Mallar, Fakturor, + Lönekörningar, Rapporter, Bokslut, Bolaget, System, Ingående balans, + Räkenskapsår, Logga ut. **Bolaget** is the master-data hub + (Företagsuppgifter, Fakturauppgifter, E-post (SMTP), Styrelseledamöter + and the registers Anställda, Kunder, Momsregler); **System** holds + Skattetabeller and Revision. Inställningar is gone, and bilagornas mapp + is no longer a setting: the file browser remembers the last pick + directory in `tui.conf` and falls back to `$HOME`. `--screen settings` + remains an alias for Bolaget. ## Open decisions @@ -60,8 +75,9 @@ None open. Completed items that used to be listed here are archived in 11. ~~SIE import only into an empty fiscal year~~ chronological multi-year import works; each year must still target an empty fiscal year. 12. TUI polish: horizontal scrolling in long text fields, bracketed paste. -13. Payroll TUI (wave 3) and the payroll follow-ups listed under "Resume - here"; payroll is server-complete but has no employee registered yet. +13. ~~Payroll TUI (wave 3)~~ done (`clients/screens_payroll.c`); the + remaining payroll follow-ups are listed under "Resume here". No + employee is registered yet in the real orgs. 14. Invoice follow-ups when needed: credit notes (`invoice.credit`), per-row account in the invoice form, kundreskontra view. 15. `make test-pty` speed if it ever exceeds ~60 s: parallelise the @@ -75,7 +91,7 @@ Original entries for the struck items are in `docs/DECISIONS.md`. ## Environment / how to run -- **Deployed**: `scripts/deploy.sh` (latest `v0.1.54`, healthy on nas). +- **Deployed**: `scripts/deploy.sh` (latest `v0.1.59`, healthy on nas). Live daemon `tls:bokf.makandra.eu:8788`, token `~/.config/bokf/migration-token` (scopes `read,write`; owner-only actions like closing years must be done by the human in the TUI). Git remote @@ -165,9 +181,9 @@ Original entries for the struck items are in `docs/DECISIONS.md`. pärm (får refereras i efterhand, även i stängda år). - **Lön (2026-09-21)**: bara ägaren är anställd, men schema och kommandon är fleranvändarklara. Lönemotorn (schema v11: anställda, skattetabeller, - lönekörningar, lönebesked + mejl) är klar server-side; TUI:t saknas och + lönekörningar, lönebesked + mejl) och TUI-sektionen Lön är klara, men **ingen anställd är registrerad än** (personnummer, lön, skattetabell och - kolumn fylls i under Anställda). Konton enligt historiken: + kolumn fylls i under Register → Anställda). Konton enligt historiken: 7210/7510/2710/2731/1630. Skattetabellerna hämtas med en knapp från Skatteverket (varning när året är gammalt), personnumret är krypterat i databasen. Ingen semesteruppbokning; arbetsgivardeklarationen (AGI) görs diff --git a/docs/TUI-GUIDELINES.md b/docs/TUI-GUIDELINES.md index 46982ed..190a5c5 100644 --- a/docs/TUI-GUIDELINES.md +++ b/docs/TUI-GUIDELINES.md @@ -33,7 +33,7 @@ there. | `Ctrl+F` | Attach a file via the file browser (voucher form and voucher detail) | | `k` | Underlag: link the highlighted attachment to a voucher picked from a list | | `Ctrl+X` | Clear the current row — only inside row editors (never "new") | -| `Ctrl+Enter` | Save/post the current form. Enabled via xterm `modifyOtherKeys`; terminals that cannot send it keep `F9` working | +| `Ctrl+Enter` | Save/post the current form. Enabled via xterm `modifyOtherKeys` level 2 or the Kitty keyboard protocol; terminals that send neither keep `F9` working, and the hints show `^Enter/F9` | Every screen prints its keys in the footer via `hints()`. If a key exists, the footer shows it; if the footer shows it, the key works. Control keys are @@ -43,7 +43,8 @@ written compactly as `^N`, `^A`, `^C`, `^R` to save width. - Rows are numbered `NN. text`, right-aligned so 2- and 3-digit numbers line up. - Verifikation ids are shown concatenated as `series+number` (`V-8`, `A8`), - using the org's `default_series` (Inställningar) for new vouchers. + using the org's `default_series` (Bolaget → Fakturauppgifter) for new + vouchers. - The last row may be an action (e.g. `+ Nytt verifikat (Ctrl+N)`); selecting it runs the action instead of opening a detail view. - Selection memory: lists remember the selected row by identity (voucher id), @@ -134,11 +135,13 @@ written compactly as `^N`, `^A`, `^C`, `^R` to save width. `BACK`, `REFRESH` or `SUBMIT` (the widget returns as on `Esc`/`F5`/ `Ctrl+Enter`). Hooks exist on `tui_form_run_hook`, `tui_rt_set_key`, `tui_pager_hook` and `tui_select_list_hook`. -- File browser (`file_browser`): starts in the org's `attachment_dir` (or - `$HOME`; a leading `~` is expanded to `$HOME`), `.. (uppåt)` is the first row, directories sort first with a - trailing `/`, hidden files are skipped. Enter enters a directory or picks a - file; `Esc` cancels. Selected files are uploaded immediately as unlinked - underlag and linked when the voucher is posted. +- File browser (`file_browser`): starts in the directory where the last + attachment was picked (remembered in `tui.conf`), falling back to `$HOME` + when it is gone (a leading `~` is expanded to `$HOME`), `.. (uppåt)` is + the first row, directories sort first with a trailing `/`, hidden files + are skipped. Enter enters a directory or picks a file; `Esc` cancels. + Picking a file remembers its directory. Selected files are uploaded + immediately as unlinked underlag and linked when the voucher is posted. ## Messages |
