feat: 单独查询项目已花费的金额以及预算余额
This commit is contained in:
@@ -8,6 +8,7 @@ from app.model.ProjectModel import ProjectModel, ProjectService
|
||||
from app.model.ReimburseModel import ReimburseService
|
||||
from app.utils.db_utils import AsyncSessionDep
|
||||
|
||||
|
||||
def add_approve_route(app: FastAPI):
|
||||
# 提交报销单接口
|
||||
@app.post('/submit_reimburse')
|
||||
@@ -31,6 +32,9 @@ def add_approve_route(app: FastAPI):
|
||||
project_cls_list = (await session.execute(ProjectService.select_cls().where(ProjectModel.id.in_(proj_id_list)))).scalars().all()
|
||||
project_dict_list = [item.model_dump() for item in project_cls_list]
|
||||
for dict_item in project_dict_list:
|
||||
# 已花费金额
|
||||
dict_item['spent'] = result[dict_item['id']]
|
||||
# 剩余金额
|
||||
dict_item['balance'] = Decimal(dict_item['budget']) - Decimal(dict_item['spent'])
|
||||
|
||||
return project_dict_list
|
||||
|
||||
Reference in New Issue
Block a user