fix: preserve schema 15 compatibility for v0.1.8

This commit is contained in:
2026-10-17 18:27:53 +09:00
parent a97548c36b
commit 1134f058cc
61 changed files with 2650 additions and 644 deletions
@@ -102,3 +102,40 @@ def test_empty_close_is_saved_without_fake_marker(tmp_path):
def test_double_close_is_idempotent(tmp_path):
path = _db(tmp_path, [_row("t1")]); sid, _, _ = _review_approve(path); first = close_monthly_settlement(sid, 1, db_path=str(path)); second = close_monthly_settlement(sid, 999, db_path=str(path))
assert first["success"] and second["success"] and second["idempotent"] is True
def test_legacy_finalization_and_correction_preserve_closed_canonical_month(tmp_path):
from jarca_ledger_mcp import service
path = _db(tmp_path, [_row("t1")])
sid, _, _ = _review_approve(path)
assert close_monthly_settlement(sid, 1, db_path=str(path))["success"]
canonical = get_settlement_cashflow_snapshot(sid, db_path=str(path))
with sqlite3.connect(path) as conn:
parent = conn.execute("SELECT * FROM monthly_settlement WHERE id=?", (sid,)).fetchone()
asset = service.create_manual_asset("Legacy cash", 500, "2026-10-31", "cash", db_path=str(path))
assert asset["success"]
previous = ""
for number in range(2):
draft = service.create_settlement_draft(
"2026-10", "tester", f"legacy-draft-{number}", db_path=str(path),
correction_of_run_id=previous, correction_reason="correct" if previous else "",
)
assert draft["success"], draft
did = draft["draft"]["id"]
review = service.review_settlement_draft(did, db_path=str(path))
assert review["success"]
approved = service.approve_settlement_draft(
did, review["version"], review["review_fingerprint"], "tester", "reviewed", "fixture", db_path=str(path),
)
assert approved["success"], approved
closed = service.finalize_settlement_draft(
did, review["version"], review["review_fingerprint"], f"legacy-close-{number}", db_path=str(path),
)
assert closed["success"], closed
previous = closed["snapshot_run_id"]
assert get_settlement_cashflow_snapshot(sid, db_path=str(path)) == canonical
with sqlite3.connect(path) as conn:
assert conn.execute("SELECT * FROM monthly_settlement WHERE id=?", (sid,)).fetchone() == parent
assert conn.execute("SELECT COUNT(DISTINCT settlement_run_id) FROM settlement_cashflow_snapshots").fetchone() == (2,)
assert conn.execute("SELECT COUNT(*) FROM settlement_cashflow_snapshots WHERE monthly_settlement_id=?", (sid,)).fetchone() == (1,)
assert conn.execute("PRAGMA foreign_key_check").fetchall() == []