34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
from fastapi import FastAPI
|
|
|
|
from app.model.ReimburseModel import ReimburseService, ReimburseModel
|
|
from app.utils.db_utils import AsyncSessionDep
|
|
|
|
|
|
def add_approve_route(app: FastAPI):
|
|
# 提交报销单接口
|
|
@app.post('/submit_reimburse')
|
|
async def submit_reimburse(reimburse: dict, session: AsyncSessionDep):
|
|
reimburse_id = reimburse.get('id')
|
|
# 先查一遍报销单信息
|
|
reimburse_cls: ReimburseModel = await ReimburseService.query_item(session=session, row_dict={"id": reimburse_id})
|
|
|
|
# 1. 没有审批单——
|
|
# 2. 审批单为审批中状态——不处理
|
|
# 3. 审批单为已通过状态——不处理
|
|
# 4. 审批单为已驳回状态——
|
|
# 5. 审批单为已撤回状态——
|
|
|
|
# 2,3 的情况下不再提交报销单
|
|
|
|
if reimburse_cls.approve:
|
|
if reimburse_cls.approve.status == 'approving':
|
|
return {"message": "报销单已提交审批,请勿重复提交!"}
|
|
if reimburse_cls.approve.status == 'approved':
|
|
return {"message": "报销单已通过审批,请勿重复提交!"}
|
|
|
|
# 1,4,5 的情况下新建审批单
|
|
# 新建审批单,走审批流程
|
|
print(reimburse_cls.amount)
|
|
|
|
return
|