Adding read action for opening transaction

This commit is contained in:
2025-02-14 17:27:17 +01:00
parent 65ecfcd919
commit b5039f6468
3 changed files with 63 additions and 1 deletions

View File

@@ -12,6 +12,8 @@ from account.models import Account
from account.resource import AccountResource
from db import SessionDep
from transaction.models import TransactionRead
from transaction.resource import TransactionResource
from user.manager import get_current_user
@@ -55,6 +57,13 @@ def read_account(account_id: UUID, session: SessionDep, current_user=Depends(get
raise HTTPException(status_code=404, detail="Account not found")
return account
@router.get("/{account_id}/opening_state")
def read_account_opening_state(account_id: UUID, session: SessionDep, current_user=Depends(get_current_user)) -> TransactionRead:
transaction = TransactionResource.get_opening_transaction(session, account_id)
if not transaction:
raise HTTPException(status_code=404, detail="Account not found")
return transaction
@router.put("/{account_id}")
def update_account(account_id: UUID, account: AccountUpdate, session: SessionDep, current_user=Depends(get_current_user)) -> AccountRead:
db_account = AccountResource.get(session, account_id)