Skip to content

Open-source personal finance manager. Self-hosted, privacy-first.

fix(recurring): link imported charges when generating pending bills (#1233)

Carson Jonesc86801404bb1
diff --git a/backend/app/services/recurring_match_service.py b/backend/app/services/recurring_match_service.py
index 1f68920e..45d54326 100644
--- a/backend/app/services/recurring_match_service.py
+++ b/backend/app/services/recurring_match_service.py
@@ -58,7 +58,7 @@ from app.services.reconciliation_engine import Expectation, Movement, evaluate
# Real-transaction sources a recurring charge can arrive under. Excludes
# "recurring" itself: that is the generated placeholder, handled separately.
-_REAL_SOURCES = ("sync", "ofx", "csv", "manual")
+_REAL_SOURCES = ("sync", "import", "ofx", "csv", "manual")
def _date_reach(policy: dict[str, Any]) -> tuple[int, int]:
diff --git a/backend/tests/test_recurring_match.py b/backend/tests/test_recurring_match.py
index 437ac858..06f1a68b 100644
--- a/backend/tests/test_recurring_match.py
+++ b/backend/tests/test_recurring_match.py
@@ -335,12 +335,15 @@ async def test_advance_past_early_charge_still_advances(session, test_user, test
@pytest.mark.asyncio
-async def test_generate_pending_links_existing_real_tx(session, test_user, test_workspace, account):
- """A synced charge that already covers the occurrence is linked, not duplicated."""
[email protected]("source", ["sync", "import"])
+async def test_generate_pending_links_existing_real_tx(
+ session, test_user, test_workspace, account, source
+):
+ """A synced or imported charge that already covers the occurrence is linked, not duplicated."""
bill = await _make_bill(session, test_workspace, test_user, account)
real = await _add_tx(
session, test_user, test_workspace, account,
- date=date(2025, 1, 11), source="sync", external_id="bank-1",
+ date=date(2025, 1, 11), source=source, external_id="bank-1",
)
count = await generate_pending(session, test_user.id, up_to=date(2025, 1, 20))