51 lines
2.0 KiB
Python
51 lines
2.0 KiB
Python
import kv.schemas as schemas
|
|
import kv.crud as crud
|
|
from kv.database import get_db
|
|
from sqlalchemy.orm import Session
|
|
from fastapi import APIRouter, Depends
|
|
from typing import List
|
|
router = APIRouter()
|
|
|
|
"""get"""
|
|
|
|
|
|
@router.get("/get_details/{id}", response_model=List[schemas.PersonalAccountDetailsSerializer])
|
|
async def get_details(id: int, db: Session = Depends(get_db)):
|
|
data = crud.PersonalAccountViewSet.get_details(db, id)
|
|
return data
|
|
|
|
|
|
@router.get("/get_turn_over/{IDPersonalAccount}", response_model=List[schemas.TurnOverSerializer])
|
|
async def get_turn_over(IDPersonalAccount: int, db: Session = Depends(get_db)):
|
|
data = crud.PersonalAccountViewSet.get_turn_over(db, IDPersonalAccount)
|
|
return data
|
|
|
|
|
|
@router.get("/get_services/{IDPersonalAccount}", response_model=List[schemas.PersonalAccountTOServicesSerializer])
|
|
async def get_services(IDPersonalAccount: int, db: Session = Depends(get_db)):
|
|
data = crud.PersonalAccountViewSet.get_services(db, IDPersonalAccount)
|
|
return data
|
|
|
|
|
|
@router.get("/get_debt/{IDPersonalAccount}", response_model=List[schemas.PersonalAccountDebtSerilizer])
|
|
async def get_debt(IDPersonalAccount: int, db: Session = Depends(get_db)):
|
|
body = schemas.PersonalAccountInit( IDPersonalAccount = IDPersonalAccount)
|
|
data = crud.PersonalAccountViewSet.get_debt(db, body)
|
|
return data
|
|
|
|
|
|
@router.get("/get_debts/IDPersonalAccount={IDPersonalAccount},GetType={GetType}", response_model=List[schemas.PersonalAccountDebtsSerializer])
|
|
async def get_debts(IDPersonalAccount: int, GetType: bool, db: Session = Depends(get_db)):
|
|
to_data = schemas.PersonalAccountType(
|
|
IDPersonalAccount=IDPersonalAccount, GetType=GetType)
|
|
data = crud.PersonalAccountViewSet.get_debts(db, to_data)
|
|
return data
|
|
|
|
|
|
"""post"""
|
|
|
|
|
|
@router.post("/get_financial_account", response_model=List[schemas.ReportTOFinancialAccount])
|
|
async def get_financial_account(request: schemas.ReportTOFinancialAccountInit, db: Session = Depends(get_db)):
|
|
return crud.PersonalAccountViewSet.get_financial_account(db, request)
|