mirror of
https://github.com/elisiariocouto/leggen.git
synced 2025-12-14 09:42:21 +00:00
Add hide_missing_ids filter to transaction queries
- Add hide_missing_ids parameter to database functions to filter out transactions without internalTransactionId - Update API routes to support the new filter parameter - Update unit tests to include the new parameter - Add opencode.json configuration file
This commit is contained in:
committed by
Elisiário Couto
parent
c5fd26cb3e
commit
947342e196
@@ -18,6 +18,9 @@ async def get_all_transactions(
|
||||
summary_only: bool = Query(
|
||||
default=True, description="Return transaction summaries only"
|
||||
),
|
||||
hide_missing_ids: bool = Query(
|
||||
default=True, description="Hide transactions without internalTransactionId"
|
||||
),
|
||||
date_from: Optional[str] = Query(
|
||||
default=None, description="Filter from date (YYYY-MM-DD)"
|
||||
),
|
||||
@@ -47,6 +50,18 @@ async def get_all_transactions(
|
||||
min_amount=min_amount,
|
||||
max_amount=max_amount,
|
||||
search=search,
|
||||
hide_missing_ids=hide_missing_ids,
|
||||
)
|
||||
|
||||
# Get total count for pagination info (respecting the same filters)
|
||||
total_transactions = await database_service.get_transaction_count_from_db(
|
||||
account_id=account_id,
|
||||
date_from=date_from,
|
||||
date_to=date_to,
|
||||
min_amount=min_amount,
|
||||
max_amount=max_amount,
|
||||
search=search,
|
||||
hide_missing_ids=hide_missing_ids,
|
||||
)
|
||||
|
||||
# Get total count for pagination info
|
||||
@@ -111,6 +126,9 @@ async def get_all_transactions(
|
||||
async def get_transaction_stats(
|
||||
days: int = Query(default=30, description="Number of days to include in stats"),
|
||||
account_id: Optional[str] = Query(default=None, description="Filter by account ID"),
|
||||
hide_missing_ids: bool = Query(
|
||||
default=True, description="Hide transactions without internalTransactionId"
|
||||
),
|
||||
) -> APIResponse:
|
||||
"""Get transaction statistics for the last N days from database"""
|
||||
try:
|
||||
@@ -128,6 +146,7 @@ async def get_transaction_stats(
|
||||
date_from=date_from,
|
||||
date_to=date_to,
|
||||
limit=None, # Get all matching transactions for stats
|
||||
hide_missing_ids=hide_missing_ids,
|
||||
)
|
||||
|
||||
# Calculate stats
|
||||
|
||||
@@ -115,6 +115,7 @@ class DatabaseService:
|
||||
min_amount: Optional[float] = None,
|
||||
max_amount: Optional[float] = None,
|
||||
search: Optional[str] = None,
|
||||
hide_missing_ids: bool = True,
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""Get transactions from SQLite database"""
|
||||
if not self.sqlite_enabled:
|
||||
@@ -131,6 +132,7 @@ class DatabaseService:
|
||||
min_amount=min_amount,
|
||||
max_amount=max_amount,
|
||||
search=search,
|
||||
hide_missing_ids=hide_missing_ids,
|
||||
)
|
||||
logger.debug(f"Retrieved {len(transactions)} transactions from database")
|
||||
return transactions
|
||||
@@ -146,6 +148,7 @@ class DatabaseService:
|
||||
min_amount: Optional[float] = None,
|
||||
max_amount: Optional[float] = None,
|
||||
search: Optional[str] = None,
|
||||
hide_missing_ids: bool = True,
|
||||
) -> int:
|
||||
"""Get total count of transactions from SQLite database"""
|
||||
if not self.sqlite_enabled:
|
||||
@@ -162,7 +165,9 @@ class DatabaseService:
|
||||
# Remove None values
|
||||
filters = {k: v for k, v in filters.items() if v is not None}
|
||||
|
||||
count = sqlite_db.get_transaction_count(account_id=account_id, **filters)
|
||||
count = sqlite_db.get_transaction_count(
|
||||
account_id=account_id, hide_missing_ids=hide_missing_ids, **filters
|
||||
)
|
||||
logger.debug(f"Total transaction count: {count}")
|
||||
return count
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user