Fix loan valuation definition bypasses
This commit is contained in:
@@ -104,6 +104,30 @@ def test_import_historical_kb_does_not_replace_newer_current_balance(monkeypatch
|
||||
assert service.list_account_valuations(account, db_path=path)["count"] == 2
|
||||
|
||||
|
||||
def test_loan_import_preserves_transactions_and_current_cache_without_valuation_candidate(monkeypatch, tmp_path):
|
||||
path = str(tmp_path / "ledger.sqlite3")
|
||||
account = service.create_ledger_account("대출", type="loan", db_path=path)["account"]["id"]
|
||||
monkeypatch.setattr(
|
||||
imports_service,
|
||||
"parse_kb_bank_pdf",
|
||||
lambda *_: _parsed(
|
||||
_fake_tx("2026-06-30", 700, kind="kb"),
|
||||
"loan-kb",
|
||||
{"final_balance": 700, "account_number_masked": ""},
|
||||
),
|
||||
)
|
||||
|
||||
result = imports_service.import_kb_bank_pdf("ignored", "pw", account_id=account, db_path=path)
|
||||
current = service.list_ledger_accounts(active_only=False, db_path=path)["accounts"][0]
|
||||
|
||||
assert result["success"] is True
|
||||
assert result["inserted_count"] == 1
|
||||
assert current["last_balance"] == 700
|
||||
assert current["last_balance_basis_date"] == "2026-06-30"
|
||||
assert service.list_ledger_transactions(account_id=account, db_path=path)["count"] == 1
|
||||
assert service.list_account_valuations(account, db_path=path)["count"] == 0
|
||||
|
||||
|
||||
def test_import_historical_toss_bank_does_not_replace_newer_current_balance(monkeypatch, tmp_path):
|
||||
path = str(tmp_path / "ledger.sqlite3")
|
||||
account = service.create_ledger_account("Toss", institution="토스뱅크", last_balance=900, last_synced_at="2026-06-30", db_path=path, last_balance_basis_date="2026-06-30")["account"]["id"]
|
||||
|
||||
Reference in New Issue
Block a user