Keep transactions without an account and add their bitcoin price

This commit is contained in:
ai-bot committed 2026-11-14 18:03:24 +00:00
1 parent 6b79452e95
commit b59cc286af
1 file changed
+9 -2
+9 -2
View File
@@ -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):