Fix Review 64 valuation authority regressions
This commit is contained in:
@@ -65,6 +65,42 @@ def test_late_import_current_balance_is_authoritative_by_evidence_basis_date(mon
|
||||
}
|
||||
|
||||
|
||||
def test_empty_balance_with_basis_date_is_rejected_without_mutation_before_import(tmp_path, monkeypatch):
|
||||
path = str(tmp_path / "ledger.sqlite3")
|
||||
account = service.create_ledger_account("KB", institution="KB국민은행", db_path=path)["account"]["id"]
|
||||
before = service.list_ledger_accounts(active_only=False, db_path=path)["accounts"][0]
|
||||
before_valuations = service.list_account_valuations(account, db_path=path)["valuations"]
|
||||
|
||||
rejected = service.update_ledger_account(
|
||||
account,
|
||||
last_balance="",
|
||||
last_balance_basis_date="2026-07-01",
|
||||
db_path=path,
|
||||
)
|
||||
|
||||
after = service.list_ledger_accounts(active_only=False, db_path=path)["accounts"][0]
|
||||
after_valuations = service.list_account_valuations(account, db_path=path)["valuations"]
|
||||
assert rejected["success"] is False
|
||||
assert rejected["error_code"] == "validation_error"
|
||||
assert after == before
|
||||
assert after_valuations == before_valuations
|
||||
|
||||
monkeypatch.setattr(
|
||||
imports_service,
|
||||
"parse_kb_bank_pdf",
|
||||
lambda *_: _parsed(_transaction("2026-06-30", 900, 1), "hash-valid"),
|
||||
)
|
||||
monkeypatch.setattr(imports_service, "now_iso", lambda: "2026-07-02T09:00:00")
|
||||
imported = imports_service.import_kb_bank_pdf("synthetic", "pw", account_id=account, db_path=path)
|
||||
|
||||
current = service.list_ledger_accounts(active_only=False, db_path=path)["accounts"][0]
|
||||
valuations = service.list_account_valuations(account, db_path=path)["valuations"]
|
||||
assert imported["success"] is True
|
||||
assert current["last_balance"] == 900
|
||||
assert current["last_balance_basis_date"] == "2026-06-30"
|
||||
assert {(item["basis_date"], item["amount"]) for item in valuations} == {("2026-06-30", 900)}
|
||||
|
||||
|
||||
def test_account_write_sync_timestamp_does_not_infer_balance_basis_or_candidate(tmp_path):
|
||||
path = str(tmp_path / "ledger.sqlite3")
|
||||
unknown = service.create_ledger_account(
|
||||
|
||||
Reference in New Issue
Block a user