Keep transactions without an account and add their bitcoin price
This commit is contained in:
1 parent
6b79452e95
commit
b59cc286af
1 file changed
+9
-2
@@ -152,17 +152,24 @@ def _load_markets(conn):
|
|||||||
return {row["id"]: dict(row) for row in rows}
|
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):
|
def _load_transaction(conn, tx_id):
|
||||||
row = conn.execute(
|
row = conn.execute(
|
||||||
"SELECT t.*, m.name AS market_name, d.name AS to_market_name,"
|
"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)"
|
" 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 = ?",
|
" LEFT JOIN markets d ON d.id = t.to_market_id WHERE t.id = ?",
|
||||||
(tx_id,),
|
(tx_id,),
|
||||||
).fetchone()
|
).fetchone()
|
||||||
if row is None:
|
if row is None:
|
||||||
raise ApiError(404, "Fann ikkje transaksjonen.")
|
raise ApiError(404, "Fann ikkje transaksjonen.")
|
||||||
return dict(row)
|
return _with_price(dict(row))
|
||||||
|
|
||||||
|
|
||||||
def _drop_ledger(conn):
|
def _drop_ledger(conn):
|
||||||
|
|||||||
Reference in new issue
Block a user