feat(server): 报销单输出工号/邮箱并扩展申请人邮箱前缀匹配

- ExpenseClaimRead 新增 employee_no/employee_email 字段,ExpenseClaim 模型补对应只读属性
- expense_claim_access_policy 在姓名匹配未果时,按 candidate@% 邮箱前缀匹配 Employee.email,命中唯一记录即返回
- test_backend_pagination/test_expense_claim_service 补充工号/邮箱字段断言与邮箱前缀匹配用例
- 更新公司通信费报销规则表
This commit is contained in:
caoxiaozhu
2026-06-22 15:55:48 +08:00
parent 1b04ee1c4c
commit aa965da69d
6 changed files with 70 additions and 0 deletions

View File

@@ -58,6 +58,14 @@ class ExpenseClaim(Base):
def employee_position(self) -> str | None:
return str(self.employee.position).strip() if self.employee is not None and self.employee.position else None
@property
def employee_no(self) -> str | None:
return str(self.employee.employee_no).strip() if self.employee is not None and self.employee.employee_no else None
@property
def employee_email(self) -> str | None:
return str(self.employee.email).strip() if self.employee is not None and self.employee.email else None
@property
def employee_grade(self) -> str | None:
return str(self.employee.grade).strip() if self.employee is not None and self.employee.grade else None

View File

@@ -144,6 +144,8 @@ class ExpenseClaimRead(BaseModel):
claim_no: str
employee_id: str | None
employee_name: str
employee_no: str | None = None
employee_email: str | None = None
department_id: str | None
department_name: str
employee_position: str | None = None

View File

@@ -509,6 +509,20 @@ class ExpenseClaimAccessPolicy:
if employee is not None:
return employee
for candidate in normalized_candidates:
if self.is_email_like(candidate):
continue
matches = list(
self.db.scalars(
select(Employee)
.options(*load_options)
.where(func.lower(Employee.email).like(f"{candidate.lower()}@%"))
.limit(2)
).all()
)
if len(matches) == 1:
return matches[0]
for candidate in normalized_candidates:
matches = list(
self.db.scalars(