feat: Implement currency management with models, routes, and UI updates; add backfill script for existing records
This commit is contained in:
17
routes/currencies.py
Normal file
17
routes/currencies.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from typing import List, Dict, Any
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from models.currency import Currency
|
||||
from routes.dependencies import get_db
|
||||
|
||||
router = APIRouter(prefix="/api/currencies", tags=["Currencies"])
|
||||
|
||||
|
||||
@router.get("/", response_model=List[Dict[str, Any]])
|
||||
def list_currencies(db: Session = Depends(get_db)):
|
||||
results = []
|
||||
for c in db.query(Currency).filter_by(is_active=True).order_by(Currency.code).all():
|
||||
results.append({"id": c.code, "name": f"{c.name} ({c.code})", "symbol": c.symbol})
|
||||
return results
|
||||
Reference in New Issue
Block a user