fix: address account valuation review findings

This commit is contained in:
2026-10-07 00:12:45 +00:00
parent 6a8a27a74e
commit f25b30c750
23 changed files with 1506 additions and 62 deletions
+8 -5
View File
@@ -75,9 +75,9 @@ def test_reconciliation_prefers_investment_total_value_over_balance(tmp_path):
def test_historical_account_update_preserves_current_and_adds_one_candidate(tmp_path):
path = str(tmp_path / "ledger.sqlite3")
created = service.create_ledger_account("계좌", last_balance=900, last_synced_at="2026-06-30", db_path=path)
created = service.create_ledger_account("계좌", last_balance=900, last_synced_at="2026-06-30", db_path=path, last_balance_basis_date="2026-06-30")
account = created["account"]["id"]
updated = service.update_ledger_account(account, last_balance=700, last_synced_at="2026-06-01", db_path=path)
updated = service.update_ledger_account(account, last_balance=700, last_synced_at="2026-06-01", last_balance_basis_date="2026-06-01", db_path=path)
assert updated["account"]["last_balance"] == 900 and updated["account"]["last_synced_at"] == "2026-06-30"
values = service.list_account_valuations(account, db_path=path)["valuations"]
assert len(values) == 2 and sum(v["basis_date"] == "2026-06-01" for v in values) == 1
@@ -294,20 +294,23 @@ def test_loan_representative_is_always_aggregated_as_liability(tmp_path):
assert report["included_items"][0]["liquidity_bucket"] == "loan"
def test_loan_balance_fallback_without_representative_definition_is_excluded(tmp_path):
def test_loan_balance_without_representative_definition_is_rejected_without_write(tmp_path):
path = str(tmp_path / "ledger.sqlite3")
loan = service.create_ledger_account(
"대출", type="loan", last_balance=100,
last_synced_at="2026-06-30", db_path=path,
)["account"]["id"]
service.register_account_valuation(
rejected = service.register_account_valuation(
loan, "2026-06-30", 100, valuation_kind="balance",
verification_status="verified", db_path=path,
)
assert rejected["success"] is False
assert rejected["error_code"] == "validation_error"
assert service.list_account_valuations(loan, db_path=path)["count"] == 0
report = service.get_asset_snapshot_report("2026-06-30", db_path=path)
assert report["total_liabilities"] == 0
assert report["net_worth"] == 0
assert report["excluded_items"][0]["reason"] == "missing_representative_liability_definition"
assert report["excluded_items"][0]["reason"] == "missing_verified_exact_valuation"
def test_warning_candidate_public_payload_is_minimal():