fix: classify conditional previews and normalize currency

This commit is contained in:
2026-10-06 10:01:46 +00:00
parent 2a6076e86b
commit 367583522b
2 changed files with 33 additions and 3 deletions
+23
View File
@@ -31,6 +31,15 @@ def test_empty_conditional_close_is_closed_and_second_close_requires_correction(
assert second["success"] is False and second["error_code"] == "validation_error"
def test_preview_marks_approval_eligible_missing_valuation_as_conditional(tmp_path):
path = str(tmp_path / "ledger.sqlite3")
service.create_ledger_account("미확인 계좌", db_path=path)
preview = service.preview_asset_snapshot_close("2026-06-30", db_path=path)
assert preview["success"] is True
assert preview["close_status"] == "conditional"
assert any(warning["code"] == "missing_verified_exact_valuation" for warning in preview["warnings"])
def test_reconciliation_uses_corrected_investment_leaf_without_transaction_count_change(tmp_path):
path = str(tmp_path / "ledger.sqlite3")
account = service.create_ledger_account("투자", type="investment", last_balance=100, last_synced_at="2026-06-30", db_path=path)["account"]["id"]
@@ -421,6 +430,20 @@ def test_non_krw_account_valuation_is_excluded_without_fx_conversion(tmp_path):
assert any(item.get("reason") == "non_krw_without_fx" for item in report["excluded_items"])
def test_legacy_lowercase_krw_account_currency_selects_normalized_valuation(tmp_path):
path = str(tmp_path / "ledger.sqlite3")
account = service.create_ledger_account("계좌", currency="KRW", db_path=path)["account"]["id"]
service.register_account_valuation(
account, "2026-06-30", 100, currency="KRW",
verification_status="verified", db_path=path,
)
with sqlite3.connect(path) as conn:
conn.execute("UPDATE accounts SET currency='krw' WHERE id=?", (account,))
report = service.get_asset_snapshot_report("2026-06-30", db_path=path)
assert report["total_assets"] == 100
assert report["excluded_items"] == []
def test_rejected_valuation_is_not_an_unverified_candidate(tmp_path):
path = str(tmp_path / "ledger.sqlite3")
account = service.create_ledger_account("계좌", db_path=path)["account"]["id"]