Files
X-Financial/document/development/2026-07-18/dev-logs/bugs/employee-age-birthdate-conversion.md

19 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 员工年龄反算出生日期偏差一年
日期2026-07-18
文档路径document/development/2026-07-18/dev-logs/bugs/employee-age-birthdate-conversion.md
## 修复记录
- 15:40记录 bug 修复:员工生日在当年尚未到来时,编辑年龄会反算出少一年的年龄。
- Git 提交检查:`git fetch --all --prune` 成功upstream `origin/main` 无新提交;本地 ahead 19 条,最新包括 `07241b46 fix(docker): manage local postgres in default compose``787bc3a4 feat(platform): close AI expense value loop``242d68c3 feat(approval): add task workflow and waiver decisions`,另有 16 条。
- 修改:`employeeManagementModel.js` 在目标生日尚未到来时向前校正出生年份,并为年龄与出生日期转换函数增加可注入的参考日期;新增 `employee-management-age.test.mjs` 覆盖未过生日和已过生日两个边界。
- 操作:在 `local-x-financial-linux` 容器内运行员工年龄、员工历史和规则权限定向测试,并执行 Vite 生产构建与 `git diff --check`
- 验证:以 2026-07-18 为参考日期30 岁且生日为 12 月 31 日时正确生成 `1995-12-31`,回算年龄仍为 30定向前端测试 9 项全部通过,前端全量测试 `820/820` 通过Vite 生产构建成功,差异格式检查通过。
- 影响:员工管理中直接修改年龄后,保存与重新加载不再把员工年龄静默减一岁。
- 16:03补齐 0 岁与闰日出生日期边界。
- Git 提交检查:沿用本轮 15:54 拉取检查upstream `origin/main` 无新提交,本地 ahead 19 条。
- 修改出生年按参考日中生日是否已过推导0 岁且生日未到时使用上一出生年度避免生成未来日期2 月 29 日跨非闰年统一按 2 月 28 日计算和保存。
- 验证:参考日 2026-07-18、0 岁、保留 12 月 31 日时生成 `2025-12-31` 并回算 0 岁;闰日跨到非闰年生成合法 `2001-02-28` 并回算 23 岁;定向测试 22 项、前端全量测试 `823/823`、生产构建均通过。
- 影响:新生儿档案和闰日生日员工的编辑结果保持合法、可保存且年龄一致。