From b59cc286af364da8d2ba03f3ce17072a65520314 Mon Sep 17 00:00:00 2001 From: ai-bot Date: Sat, 14 Nov 2026 18:03:24 +0000 Subject: [PATCH] Keep transactions without an account and add their bitcoin price --- app.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 15f61d5..db03caf 100644 --- a/app.py +++ b/app.py @@ -152,17 +152,24 @@ def _load_markets(conn): return {row["id"]: dict(row) for row in rows} +def _with_price(transaction): + """Add the derived bitcoin price of docs/spec.md section 7.3.""" + transaction["btc_price_ore"] = tax.btc_price_ore(transaction) + return transaction + + def _load_transaction(conn, tx_id): row = conn.execute( "SELECT t.*, m.name AS market_name, d.name AS to_market_name," " COALESCE((SELECT SUM(c.cost_ore) FROM lot_consumptions c WHERE c.tx_id = t.id), 0)" - " AS cost_ore FROM transactions t JOIN markets m ON m.id = t.market_id" + " AS cost_ore FROM transactions t" + " LEFT JOIN markets m ON m.id = t.market_id" " LEFT JOIN markets d ON d.id = t.to_market_id WHERE t.id = ?", (tx_id,), ).fetchone() if row is None: raise ApiError(404, "Fann ikkje transaksjonen.") - return dict(row) + return _with_price(dict(row)) def _drop_ledger(conn):