HEL-269: 完成月结锁账、撤演示数据与代码收尾

锁账后写保护与闭期补录留痕;重开须审批并按版本链再结;列表/导出改走真实 API。

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
总工
2026-08-30 21:42:22 +08:00
co-authored by Cursor multica-agent
parent f5e0915f63
commit e5e326514d
26 changed files with 3455 additions and 487 deletions
+37 -2
View File
@@ -109,11 +109,46 @@ def _company_rows(connection: sqlite3.Connection) -> list[sqlite3.Row]:
).fetchall()
def _period_status_for_cutoff(
connection: sqlite3.Connection, cutoff: str
) -> tuple[str | None, str]:
ym = str(cutoff or "")[:7]
exists = connection.execute(
"SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'period_close_runs'"
).fetchone()
if exists is None:
return None, ""
row = connection.execute(
"""
SELECT status FROM period_close_runs
WHERE year_month = ?
ORDER BY version DESC LIMIT 1
""",
(ym,),
).fetchone()
mapping = {
"closed": ("closed", "已锁定"),
"reopened": ("reopened", "已重开"),
"failed": ("failed", "结账失败"),
"pending": ("pending", "待结账"),
"closing": ("closing", "处理中"),
}
if row is not None:
return mapping.get(row["status"], (row["status"], str(row["status"])))
locked = connection.execute(
"SELECT 1 FROM closed_periods WHERE year_month = ?", (ym,)
).fetchone()
if locked is not None:
return "closed", "已锁定"
return None, ""
def company_summaries(
connection: sqlite3.Connection, *, from_date: str, cutoff: str
) -> tuple[list[dict[str, object]], dict[str, object]]:
companies = _company_rows(connection)
events = _load_eligible(connection, from_date=from_date, cutoff=cutoff)
period_status, period_label = _period_status_for_cutoff(connection, cutoff)
debit_total = ZERO
credit_total = ZERO
@@ -125,8 +160,8 @@ def company_summaries(
"detail_count": 0,
"debit": ZERO,
"credit": ZERO,
"period_status": None,
"period_status_label": "",
"period_status": period_status,
"period_status_label": period_label,
}
for event in events: