From 1436b275a6a4ece349ccb06252ba43d90f506bc8 Mon Sep 17 00:00:00 2001 From: ai-bot Date: Sun, 15 Nov 2026 18:30:58 +0000 Subject: [PATCH] Fill the bank and the second leg of a cost --- app.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app.py b/app.py index 812d8c1..283621f 100644 --- a/app.py +++ b/app.py @@ -196,7 +196,14 @@ def _drop_ledger(conn): def _write_transaction(conn, tx_id, tx, picks): + """Insert or update one row, filling in what the server derives.""" now = _now_stamp() + if tx["type"] == "admin_cost": + # The cost stands on the bank and carries the same kroner back in, so the + # bank never goes negative and no other account is touched (section 3.11). + tx = dict(tx) + tx["market_id"] = _bank_market_id(conn) + tx["leg_in_ore"] = tx["leg_out_ore"] if tx_id is None: cursor = conn.execute( "INSERT INTO transactions (date, type, market_id, taxable, note, leg_in_sats,"