|
|
@@ -239,6 +239,30 @@ async def modify_institution_controller(
|
|
|
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_payment:expense:institution:modify"]))],
|
|
|
) -> JSONResponse:
|
|
|
"""编辑费控制度"""
|
|
|
+ # enterprise_id 推导
|
|
|
+ if not data.get("enterprise_id"):
|
|
|
+ from app.plugin.module_payment.enterprise.model import EnterpriseModel
|
|
|
+ from sqlalchemy import select
|
|
|
+ tenant_id = auth.user.tenant_id if auth.user and auth.user.tenant_id else auth.tenant_id
|
|
|
+ stmt = select(EnterpriseModel).where(EnterpriseModel.tenant_id == tenant_id).limit(1)
|
|
|
+ result = await auth.db.execute(stmt)
|
|
|
+ enterprise = result.scalar_one_or_none()
|
|
|
+ if enterprise:
|
|
|
+ data["enterprise_id"] = enterprise.enterprise_id
|
|
|
+ # name → institution_name
|
|
|
+ if data.get("name") and not data.get("institution_name"):
|
|
|
+ data["institution_name"] = data["name"]
|
|
|
+ # 时间格式
|
|
|
+ if data.get("effective_start_date") and len(data["effective_start_date"]) == 10:
|
|
|
+ data["effective_start_date"] = data["effective_start_date"] + " 00:00:00"
|
|
|
+ if data.get("effective_end_date") and len(data["effective_end_date"]) == 10:
|
|
|
+ data["effective_end_date"] = data["effective_end_date"] + " 23:59:59"
|
|
|
+ elif not data.get("effective_end_date") and data.get("effective_time_type") == "unlimited":
|
|
|
+ data["effective_end_date"] = "2099-12-31 23:59:59"
|
|
|
+ # expense_type 映射
|
|
|
+ EXPENSE_TYPE_MAP = {"GENERAL": "DEFAULT", "DEFAULT": "DEFAULT"}
|
|
|
+ if data.get("expense_type") in EXPENSE_TYPE_MAP:
|
|
|
+ data["expense_type"] = EXPENSE_TYPE_MAP[data["expense_type"]]
|
|
|
institution_modify_model = AlipayEbppInvoiceInstitutionModifyModel(**data)
|
|
|
result = await InstitutionService.modify_institution_service(auth=auth, data=institution_modify_model)
|
|
|
log.info(f"编辑费控制度成功: institution_id={institution_modify_model.institution_id}")
|