refactor(backend): update financial record model, schema and expense claims

- models/financial_record.py: update financial record model
- schemas/reimbursement.py: update reimbursement schema
- services/expense_claims.py: update expense claims service
This commit is contained in:
caoxiaozhu
2026-05-13 06:54:27 +00:00
parent 9459476d82
commit 999872a060
3 changed files with 37 additions and 2 deletions

View File

@@ -98,7 +98,11 @@ class ExpenseClaimService:
def list_claims(self, current_user: CurrentUserContext) -> list[ExpenseClaim]:
stmt = (
select(ExpenseClaim)
.options(selectinload(ExpenseClaim.items))
.options(
selectinload(ExpenseClaim.items),
selectinload(ExpenseClaim.employee).selectinload(Employee.manager),
selectinload(ExpenseClaim.employee).selectinload(Employee.roles),
)
.order_by(ExpenseClaim.created_at.desc(), ExpenseClaim.occurred_at.desc())
)
stmt = self._apply_claim_scope(stmt, current_user)
@@ -107,7 +111,11 @@ class ExpenseClaimService:
def get_claim(self, claim_id: str, current_user: CurrentUserContext) -> ExpenseClaim | None:
stmt = (
select(ExpenseClaim)
.options(selectinload(ExpenseClaim.items))
.options(
selectinload(ExpenseClaim.items),
selectinload(ExpenseClaim.employee).selectinload(Employee.manager),
selectinload(ExpenseClaim.employee).selectinload(Employee.roles),
)
.where(ExpenseClaim.id == claim_id)
)
stmt = self._apply_claim_scope(stmt, current_user)