mirror of
https://github.com/Zproger/Aurum.git
synced 2026-10-13 19:16:40 +07:00
Aurum — a self-hosted personal finance operating system: cash flow, net worth tracking, budgets, goals, recurring payments, reports, proactive alerts, and a compound-interest returns calculator, all bilingual (RU/EN) and mobile-first. Ships as a three-container Docker Compose stack (Postgres + FastAPI + nginx-served React frontend). See README.md for setup and CONTRIBUTING.md for development.
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.api.deps import get_session
|
|
from app.schemas.account import AccountCreate, AccountUpdate, AccountWithBalance
|
|
from app.services.account_service import create_account, delete_account, list_accounts, update_account
|
|
|
|
router = APIRouter(prefix="/accounts", tags=["accounts"])
|
|
|
|
|
|
@router.get("", response_model=list[AccountWithBalance])
|
|
async def read_accounts(
|
|
include_archived: bool = False, session: AsyncSession = Depends(get_session)
|
|
) -> list[AccountWithBalance]:
|
|
return await list_accounts(session, include_archived)
|
|
|
|
|
|
@router.post("", response_model=AccountWithBalance, status_code=201)
|
|
async def create_account_route(
|
|
payload: AccountCreate, session: AsyncSession = Depends(get_session)
|
|
) -> AccountWithBalance:
|
|
return await create_account(session, payload)
|
|
|
|
|
|
@router.patch("/{account_id}", response_model=AccountWithBalance)
|
|
async def update_account_route(
|
|
account_id: int, payload: AccountUpdate, session: AsyncSession = Depends(get_session)
|
|
) -> AccountWithBalance:
|
|
return await update_account(session, account_id, payload)
|
|
|
|
|
|
@router.delete("/{account_id}", status_code=204)
|
|
async def delete_account_route(account_id: int, session: AsyncSession = Depends(get_session)) -> None:
|
|
await delete_account(session, account_id)
|