aboutsummaryrefslogtreecommitdiff
path: root/scripts/tui-sandbox.sh
diff options
context:
space:
mode:
authorAnders Betts <anders.betts@gmail.com>2026-09-18 14:32:23 +0200
committerAnders Betts <anders.betts@gmail.com>2026-09-18 14:32:23 +0200
commita5d3ddf6d512bc459cfa450c6b449c2e7a245373 (patch)
treee14c2b28e3cd6d7b744f301b5bf498f5feb8f03e /scripts/tui-sandbox.sh
parent07b5e5890fedbf71a1503f984dfbc2baa872223c (diff)
downloadbokf-a5d3ddf6d512bc459cfa450c6b449c2e7a245373.tar.gz
bokf-a5d3ddf6d512bc459cfa450c6b449c2e7a245373.zip
reports: Kapitas-style TUI tables, corrected moms rules (schema v3)v0.1.26
The report views dumped JSON; they now render Saldobalans, Resultatrapport (previous-year column, 89xx bokfört/ej bokfört), Balansrapport (Ing balans/Ing saldo/Period/Utg balans, Beräknat resultat) and Momsrapport ruta för ruta, with Swedish amount formatting (1 234,56). The moms starter rules missed 33xx sales, sent reverse-charge VAT 2614 to box 10 instead of 30 and had box 48 positive. Rules may now share a box and report.vat sums them; box 49 is the sum of the moms boxes only. Schema v3 replaces the rules for existing orgs. Verified on a copy of the live DB: 05=703 200, 10=175 800, 20=1 453, 30=851, 48=-1 030, 49=175 621, matching the Kapitas 2027 export. Ctrl+R reload passes --socket and auto-login no longer rewrites tui.conf; pty tests now run through scripts/tui-sandbox.sh so they cannot touch the real config, cache or bw session.
Diffstat (limited to 'scripts/tui-sandbox.sh')
-rwxr-xr-xscripts/tui-sandbox.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/scripts/tui-sandbox.sh b/scripts/tui-sandbox.sh
new file mode 100755
index 0000000..b6b592d
--- /dev/null
+++ b/scripts/tui-sandbox.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Run a command with isolated bokftui config/cache for pty smoke tests, so a
+# test can never clobber the real ~/.config/bokf/tui.conf or
+# ~/.cache/bokf/tui.log.
+#
+# scripts/tui-sandbox.sh [--keep] -- command [args...]
+#
+# XDG_CONFIG_HOME and XDG_CACHE_HOME point at a fresh temp dir (printed on
+# stderr). The dir is removed on exit unless --keep is given.
+set -eu
+
+keep=0
+if [ "${1:-}" = "--keep" ]; then
+ keep=1
+ shift
+fi
+if [ "${1:-}" = "--" ]; then
+ shift
+fi
+if [ "$#" -eq 0 ]; then
+ echo "usage: scripts/tui-sandbox.sh [--keep] -- command [args...]" >&2
+ exit 2
+fi
+
+dir=$(mktemp -d "${TMPDIR:-/tmp}/bokf-tui-XXXXXX")
+mkdir -p "$dir/config" "$dir/cache"
+export XDG_CONFIG_HOME="$dir/config"
+export XDG_CACHE_HOME="$dir/cache"
+
+cleanup() {
+ [ "$keep" -eq 1 ] || rm -rf "$dir"
+}
+trap cleanup EXIT INT TERM
+
+echo "tui-sandbox: config=$dir/config cache=$dir/cache" >&2
+"$@"