Refactors pending entries and adds fiat amounts
Improves the handling of pending entries by extracting and deduplicating data from Fava's query results. Adds support for displaying fiat amounts alongside entries and extracts them from the position data in Fava. Streamlines receivables/payables/equity checks on the frontend by relying on BQL query to supply account type metadata and tags.
This commit is contained in:
parent
37fe34668f
commit
56a3e9d4e9
3 changed files with 106 additions and 64 deletions
|
|
@ -436,21 +436,32 @@ class FavaClient:
|
|||
response.raise_for_status()
|
||||
result = response.json()
|
||||
|
||||
# Fava query API returns: {"data": {"rows": [...], "columns": [...]}}
|
||||
# Fava query API returns: {"data": {"rows": [...], "types": [...]}}
|
||||
data = result.get("data", {})
|
||||
rows = data.get("rows", [])
|
||||
types = data.get("types", [])
|
||||
|
||||
# Build column name mapping
|
||||
column_names = [t.get("name") for t in types]
|
||||
|
||||
# Transform Fava's query result to transaction list
|
||||
transactions = []
|
||||
for row in rows:
|
||||
# Fava returns rows with various fields depending on the query
|
||||
# For "SELECT *", we get transaction details
|
||||
if isinstance(row, dict):
|
||||
# Rows are arrays, convert to dict using column names
|
||||
if isinstance(row, list) and len(row) == len(column_names):
|
||||
txn = dict(zip(column_names, row))
|
||||
|
||||
# Filter by flag if needed
|
||||
flag = row.get("flag", "*")
|
||||
flag = txn.get("flag", "*")
|
||||
if not include_pending and flag == "!":
|
||||
continue
|
||||
|
||||
transactions.append(txn)
|
||||
elif isinstance(row, dict):
|
||||
# Already a dict (shouldn't happen with BQL, but handle it)
|
||||
flag = row.get("flag", "*")
|
||||
if not include_pending and flag == "!":
|
||||
continue
|
||||
transactions.append(row)
|
||||
|
||||
return transactions[:limit]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue