Adding read action for opening transaction
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user