فهرست منبع

fix(expense): 添加员工API联动 - 前端直调添加员工时触发部门制度额度同步

alphah 2 هفته پیش
والد
کامیت
8a9b982658
1فایلهای تغییر یافته به همراه10 افزوده شده و 0 حذف شده
  1. 10 0
      backend/app/plugin/module_payment/employee/controller.py

+ 10 - 0
backend/app/plugin/module_payment/employee/controller.py

@@ -77,6 +77,16 @@ async def add_employee_controller(
     """添加员工"""
     result = await EmployeeService.add_employee_service(auth=auth, data=data)
     log.info(f"添加员工成功: {data.employee_name}, employee_id={result.employee_id}")
+    # 联动:员工加入部门时,为引用该部门的制度创建额度记录
+    if result.employee_id and data.enterprise_id and data.department_ids:
+        try:
+            from app.plugin.module_payment.expense.institution.scope_sync import sync_employee_add_to_department_institutions
+            await sync_employee_add_to_department_institutions(
+                auth=auth, enterprise_id=data.enterprise_id,
+                employee_id=result.employee_id, department_ids=data.department_ids,
+            )
+        except Exception as e:
+            log.warning(f"添加员工联动额度失败(不影响主体操作): {e}")
     return SuccessResponse(data=result, msg="添加员工成功")