Spaces:
Sleeping
Sleeping
get income_statement report by report_id (#11)
Browse files- feat: endpoint to get income_statement report by report_id (8b7e482aa65e5b1ff7e1247d3e9014fa57e65e41)
Files changed (2)
46 unmodified lines47484946 unmodified linesif len(all_rows) == 0:raise HTTPException(status_code=status.HTTP_204_NO_CONTENT, detail="No income statements found for this user")return all_rows46 unmodified lines4748495051525354555657585960616263646546 unmodified linesif len(all_rows) == 0:raise HTTPException(status_code=status.HTTP_204_NO_CONTENT, detail="No income statements found for this user")return all_rows@r.get("/{report_id}",response_model=IncomeStatementResponse,responses={200: {"description": "Income statement found"},404: {"description": "Income statement not found"},500: {"description": "Internal server error"},},)async def get_income_statement(report_id: int, db: AsyncSession = Depends(get_db_session)) -> IncomeStatementResponse:income_statement = await IncomeStatementModel.get(db, id=report_id)if not income_statement:raise HTTPException(status_code=404, detail="Income statement not found")return income_statement
33 unmodified lines34353633 unmodified linesquery = sql.select(cls).where(cls.user_id == user_id)income_statements = await db.scalars(query)return income_statements33 unmodified lines34353637383940414233 unmodified linesquery = sql.select(cls).where(cls.user_id == user_id)income_statements = await db.scalars(query)return income_statements@classmethodasync def get(cls: "type[IncomeStatement]", db: AsyncSession, id: int) -> "IncomeStatement":query = sql.select(cls).where(cls.id == id)income_statement = await db.scalar(query)return income_statement
app/api/routers/income_statement.py+16
app/model/income_statement.py+6