Files
X-Financial/document/development/2026-07-16/dev-logs/bugs/standard-adjustment-server-authoritative-amount.md
caoxiaozhu 787bc3a481 feat(platform): close AI expense value loop
Add tenant-safe value, telemetry, connector, commercial, and production-readiness foundations.
2026-07-17 14:14:08 +08:00

3.5 KiB
Raw Blame History

修复记录

  • 18:11记录 bug 修复:接受住宿职级标准调整时不再信任客户端金额、天数或金额快照。
    • Git 提交检查:已执行 git fetch --all --pruneHEAD..origin/main 未发现 upstream 新提交;本地相对 upstream ahead 17 个既有提交,依次为 242d68c3 feat(approval): add task workflow and waiver decisions28b834ed fix(approval): replay immutable action responses4940ebc4 feat(approval): add safe risk disposition workflowee88a36b feat(ai): add tenant-safe hierarchical expense learning6bdf65bc feat(expenses): add authoritative pre-review workflowae3f02c3 feat(expense): add persistent zero-entry receipt association54754b55 feat(ai): add personal expense application memory211f85d9 feat(ai): unify verified expense application workflow5b246307 feat(ai): issue verified application preview decisionsa662cfe6 feat(ai): add expense application feedback ledger5ed34c2b feat(expenses): backfill historical claims into expense cases11275e4b fix(migrations): enforce schema ownership safety1347366b feat(expenses): secure timeline and draft events22669a90 feat(expenses): show unified expense event timelinea616b30c fix(expenses): unify AI application submission transaction653eda05 feat(auth): add opaque bearer sessions661990b2 feat(expenses): add transactional expense case events;这些提交均早于本次未提交修复,本次没有拉取、合并或覆盖共享工作树。
    • 修改:expense_claim_standard_adjustment.py 只从已锁定的 ExpenseClaimItem.item_amount 读取原始金额,只接受服务端差旅规则计算出的最终可报金额;客户端携带的 application_daysoriginal_amountreimbursable_amount 仅作为旧界面兼容展示字段,不参与计算。服务端快照新增规则名、规则版本(无发布版本时使用内容指纹)、地点、匹配城市、职级、职级档、天数、每日住宿标准、住宿标准总额及计算指纹。
    • 修改:为标准调整增加 PostgreSQL advisory lock + Claim/Item 行锁和非 PostgreSQL 进程内串行锁;请求支持 request_id 幂等键与 expected_updated_at 乐观前置条件。相同请求直接重放且不改 created_at/计算快照,同请求号改选其他明细会被拒绝;单次调整只替换被选明细的快照,不再误删其他明细已接受的标准调整。
    • 操作:在 local-x-financial-linux 容器及 /tmp/x-financial-server-venv 中运行定向、接口全量和服务全量测试;运行 scoped Ruff 与 git diff --check,未在宿主机运行 Python/pytest也未修改规则表或其他用户文件。
    • 验证:标准调整定向回归(含非 PostgreSQL 同租户同单据锁竞争)9 passedtest_reimbursement_endpoints.py 全量 22 passedScoped Ruff 与 git diff --check 通过。test_expense_claim_service.py 全量为 112 passed, 8 failed8 个失败均位于既有审批任务配置/旧错误文案断言(直属领导任务、费用申请提交、本人审批、重复退回),不经过标准调整实现;本次新增及关联标准调整用例全部通过。
    • 影响:伪造低原金额、任意可报金额或超长住宿天数不能降低或抬高实际报销额;规则缺失时整次操作失败关闭且不改金额。审批人看到的原额、可报额和差额均可追溯到数据库明细与服务端规则证据,重复点击和并发请求不会重写金额证据。