fix: 历史费用状态修正为「计入费用」

- data_fixes 新增 migrate_fix_expense_status
- 将 NULL/空/待审批 的费用状态统一修正为「计入费用」
- 服务启动时自动执行,幂等安全
- 版本号 v1.0.0.6
This commit is contained in:
mac
2026-07-07 18:39:11 +08:00
parent f9fe32beed
commit e7e93c06f8
3 changed files with 23 additions and 2 deletions

View File

@@ -92,3 +92,23 @@ def migrate_fix_service_fee_standard():
print(f"[migrate] project_finances: {affected} 条记录 service_fee_standard 修正为 5")
finally:
conn.close()
def migrate_fix_expense_status():
"""修正 expense_records 中空的 status 为默认值「计入费用」"""
from db import db
conn = db()
try:
cur = conn.cursor()
cur.execute(
"UPDATE expense_records SET status='计入费用' "
"WHERE status IS NULL OR status='' OR status='待审批'"
)
affected = cur.rowcount
cur.close()
if affected:
conn.commit()
print(f"[migrate] expense_records: {affected} 条记录 status 修正为 '计入费用'")
finally:
conn.close()