diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/tui-golden.py | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/scripts/tui-golden.py b/scripts/tui-golden.py index e67f0d7..9bb1edf 100755 --- a/scripts/tui-golden.py +++ b/scripts/tui-golden.py @@ -54,6 +54,7 @@ KEYS = { "pgup": "\x1b[5~", "pgdn": "\x1b[6~", "ctrlc": "\x03", + "ctrln": "\x0e", } # {org_name} {org_nr} {fy_label} {fy_start} {fy_end} are substituted at run @@ -131,6 +132,26 @@ SCENARIOS = [ }, ], }, + { + "name": "invoices", + "screen": "invoices", + "expect": ["Fakturor", "Faktura", "Testkund AB", "12 500,00"], + }, + { + "name": "customers", + "screen": "customers", + "expect": ["Kunder", "Testkund AB"], + }, + { + "name": "invoice-form", + "screen": "invoices", + "steps": [ + { + "keys": ["ctrln"], + "expect": ["Ny faktura", "Kund"], + }, + ], + }, ] # -------------------------------------------------------------------------- @@ -601,11 +622,14 @@ def setup_rig(repo, tmp, env): "--org", str(org_id), "fiscal_year.get", json.dumps({"id": fy_id})], env) fy = json.loads(out)["result"] + from datetime import date, timedelta + start = date.fromisoformat(fy.get("start_date", "2026-01-01")) + start_iso = start.isoformat() out = run_checked([str(bind / "bokfctl"), "--socket", str(sock), "--user", "admin", "--password", env["BOKFD_PASSWORD"], "--org", str(org_id), "voucher.post", json.dumps({ - "date": fy.get("start_date", "2026-01-01"), + "date": start_iso, "description": "Golden verifikat", "rows": [{"account": "1930", "debit_ore": 12300}, {"account": "3001", "credit_ore": 12300}], @@ -617,14 +641,12 @@ def setup_rig(repo, tmp, env): json.dumps({"filename": "kvitto.txt", "content_base64": "a3ZpdHRv", "voucher_id": vid})], env) - from datetime import date, timedelta - start = date.fromisoformat(fy.get("start_date", "2026-01-01")) golden_date = (start + timedelta(days=1)).isoformat() csv = ( "Bokförd;Valutadatum;Text;Typ;Insättningar;Uttag;Bokfört saldo\n" f"{golden_date};{golden_date};GOLDEN INSÄTTNING;Insättning;" "123,00;;1000,00\n" - f"{start.isoformat()};{start.isoformat()};CDON /26-09-17;" + f"{start_iso};{start_iso};CDON /26-09-17;" "Kortköp;;24,09;975,91\n" ) run_checked([str(bind / "bokfctl"), "--socket", str(sock), @@ -634,6 +656,30 @@ def setup_rig(repo, tmp, env): "account": "1930", "content_base64": base64.b64encode( csv.encode("utf-8")).decode()})], env) + out = run_checked([str(bind / "bokfctl"), "--socket", str(sock), + "--user", "admin", "--password", env["BOKFD_PASSWORD"], + "--org", str(org_id), "customer.create", + json.dumps({"name": "Testkund AB", + "address": "Testgatan 1", + "postal_code": "111 22", + "city": "Stockholm", + "email": "test@example.com", + "payment_days": 30})], env) + customer_id = json.loads(out)["result"]["id"] + due_date = (start + timedelta(days=30)).isoformat() + run_checked([str(bind / "bokfctl"), "--socket", str(sock), + "--user", "admin", "--password", env["BOKFD_PASSWORD"], + "--org", str(org_id), "invoice.issue", + json.dumps({ + "customer_id": customer_id, + "invoice_date": start_iso, + "due_date": due_date, + "rows": [{"description": "Konsulttjänster", + "quantity": "10", + "unit": "tim", + "unit_price_ore": 100000, + "vat_code": "25"}], + })], env) return daemon, sock, org_id, fy |
