Implements expense approval workflow
Adds an admin approval workflow for user-submitted expenses. This ensures that only valid expenses affect user balances. The workflow includes pending expense states, admin approval/rejection actions, balance filtering, and UI updates.
This commit is contained in:
parent
018a074915
commit
3b371e3bec
4 changed files with 207 additions and 22 deletions
23
crud.py
23
crud.py
|
|
@ -236,18 +236,35 @@ async def get_entry_lines(journal_entry_id: str) -> list[EntryLine]:
|
|||
|
||||
|
||||
async def get_all_journal_entries(limit: int = 100) -> list[JournalEntry]:
|
||||
entries = await db.fetchall(
|
||||
entries_data = await db.fetchall(
|
||||
"""
|
||||
SELECT * FROM journal_entries
|
||||
ORDER BY entry_date DESC, created_at DESC
|
||||
LIMIT :limit
|
||||
""",
|
||||
{"limit": limit},
|
||||
JournalEntry,
|
||||
)
|
||||
|
||||
for entry in entries:
|
||||
entries = []
|
||||
for entry_data in entries_data:
|
||||
# Parse flag and meta from database
|
||||
from .models import JournalEntryFlag
|
||||
flag = JournalEntryFlag(entry_data.get("flag", "*"))
|
||||
meta = json.loads(entry_data.get("meta", "{}")) if entry_data.get("meta") else {}
|
||||
|
||||
entry = JournalEntry(
|
||||
id=entry_data["id"],
|
||||
description=entry_data["description"],
|
||||
entry_date=entry_data["entry_date"],
|
||||
created_by=entry_data["created_by"],
|
||||
created_at=entry_data["created_at"],
|
||||
reference=entry_data["reference"],
|
||||
flag=flag,
|
||||
meta=meta,
|
||||
lines=[],
|
||||
)
|
||||
entry.lines = await get_entry_lines(entry.id)
|
||||
entries.append(entry)
|
||||
|
||||
return entries
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue