Open-source personal finance manager. Self-hosted, privacy-first.
feat: adjust recurring dates around weekends (#506)
seraphblade201049165d0dc405
diff --git a/backend/alembic/versions/066_recurring_weekend_adjustment.py b/backend/alembic/versions/066_recurring_weekend_adjustment.pynew file mode 100644index 00000000..a88181cf--- /dev/null+++ b/backend/alembic/versions/066_recurring_weekend_adjustment.py@@ -0,0 +1,48 @@+"""add recurring weekend adjustment policy (issue #496)++Revision ID: 066+Revises: 065+Create Date: 2026-08-05++Existing recurring transactions retain their current behavior through the+server-side ``none`` default. The check constraint keeps persisted values in+sync with the API's validated policy set.+"""+from typing import Sequence, Union++import sqlalchemy as sa+from alembic import op++revision: str = "066"+down_revision: Union[str, None] = "065"+branch_labels: Union[str, Sequence[str], None] = None+depends_on: Union[str, Sequence[str], None] = None+++_CONSTRAINT_NAME = "ck_recurring_transactions_weekend_adjustment"+++def upgrade() -> None:+ op.add_column(+ "recurring_transactions",+ sa.Column(+ "weekend_adjustment",+ sa.String(length=20),+ nullable=False,+ server_default=sa.text("'none'"),+ ),+ )+ op.create_check_constraint(+ _CONSTRAINT_NAME,+ "recurring_transactions",+ "weekend_adjustment IN ('none', 'previous_friday', 'next_monday')",+ )+++def downgrade() -> None:+ op.drop_constraint(+ _CONSTRAINT_NAME,+ "recurring_transactions",+ type_="check",+ )+ op.drop_column("recurring_transactions", "weekend_adjustment")diff --git a/backend/app/models/recurring_transaction.py b/backend/app/models/recurring_transaction.pyindex becc8276..30607a83 100644--- a/backend/app/models/recurring_transaction.py+++ b/backend/app/models/recurring_transaction.py@@ -3,7 +3,7 @@ from datetime import date, datetimefrom decimal import Decimalfrom typing import TYPE_CHECKING, Optional-from sqlalchemy import Boolean, Date, DateTime, ForeignKey, Integer, Numeric, String, UniqueConstraint+from sqlalchemy import Boolean, CheckConstraint, Date, DateTime, ForeignKey, Integer, Numeric, String, UniqueConstraintfrom sqlalchemy.dialects.postgresql import UUIDfrom sqlalchemy.orm import Mapped, mapped_column, relationshipfrom sqlalchemy.sql import func@@ -21,6 +21,10 @@ class RecurringTransaction(Base):__tablename__ = "recurring_transactions"__table_args__ = (UniqueConstraint("user_id", "description", "frequency", "start_date", name="uq_recurring_tx"),+ CheckConstraint(+ "weekend_adjustment IN ('none', 'previous_friday', 'next_monday')",+ name="ck_recurring_transactions_weekend_adjustment",+ ),)id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)@@ -35,6 +39,9 @@ class RecurringTransaction(Base):currency: Mapped[str] = mapped_column(String(3), default="USD")type: Mapped[str] = mapped_column(String(10)) # debit, creditfrequency: Mapped[str] = mapped_column(String(20)) # weekly, monthly, quarterly, yearly+ weekend_adjustment: Mapped[str] = mapped_column(+ String(20), default="none", server_default="none"+ )day_of_month: Mapped[Optional[int]] = mapped_column(Integer, nullable=True)start_date: Mapped[date] = mapped_column(Date)end_date: Mapped[Optional[date]] = mapped_column(Date, nullable=True)diff --git a/backend/app/schemas/recurring_transaction.py b/backend/app/schemas/recurring_transaction.pyindex e020ee33..b37f0eb0 100644--- a/backend/app/schemas/recurring_transaction.py+++ b/backend/app/schemas/recurring_transaction.py@@ -1,10 +1,12 @@import uuidfrom datetime import date as _Datefrom decimal import Decimal-from typing import Optional+from typing import Literal, Optionalfrom pydantic import BaseModel, ConfigDict+WeekendAdjustment = Literal["none", "previous_friday", "next_monday"]+class RecurringTransactionCreate(BaseModel):description: str@@ -12,6 +14,7 @@ class RecurringTransactionCreate(BaseModel):currency: str = "USD"type: str # debit, creditfrequency: str # weekly, monthly, quarterly, yearly+ weekend_adjustment: WeekendAdjustment = "none"day_of_month: Optional[int] = Nonestart_date: _Dateend_date: Optional[_Date] = None@@ -27,6 +30,7 @@ class RecurringTransactionUpdate(BaseModel):currency: Optional[str] = Nonetype: Optional[str] = Nonefrequency: Optional[str] = None # weekly, monthly, quarterly, yearly+ weekend_adjustment: Optional[WeekendAdjustment] = Noneday_of_month: Optional[int] = Nonestart_date: Optional[_Date] = Noneend_date: Optional[_Date] = None@@ -46,6 +50,7 @@ class RecurringTransactionRead(BaseModel):currency: strtype: strfrequency: str+ weekend_adjustment: WeekendAdjustment = "none"day_of_month: Optional[int] = Nonestart_date: _Dateend_date: Optional[_Date] = Nonediff --git a/backend/app/services/dashboard_service.py b/backend/app/services/dashboard_service.pyindex c572579a..a90b2821 100644--- a/backend/app/services/dashboard_service.py+++ b/backend/app/services/dashboard_service.py@@ -58,7 +58,7 @@ async def _get_recurring_projections(.where(RecurringTransaction.workspace_id == workspace_id,RecurringTransaction.is_active == True,- RecurringTransaction.start_date < month_end,+ RecurringTransaction.start_date < month_end + timedelta(days=2),or_(RecurringTransaction.category_id.is_(None),Category.treat_as_transfer.is_not(True),@@ -84,6 +84,7 @@ async def _get_recurring_projections(range_start=month_start,range_end=month_end,intended_day=rec.day_of_month or rec.start_date.day,+ weekend_adjustment=rec.weekend_adjustment,)for occ_date in occurrences:projections.append({@@ -749,7 +750,7 @@ async def get_projected_transactions(.where(RecurringTransaction.workspace_id == workspace_id,RecurringTransaction.is_active == True,- RecurringTransaction.start_date < month_end,+ RecurringTransaction.start_date < month_end + timedelta(days=2),or_(RecurringTransaction.category_id.is_(None),Category.treat_as_transfer.is_not(True),@@ -782,6 +783,7 @@ async def get_projected_transactions(range_start=month_start,range_end=month_end,intended_day=rec.day_of_month or rec.start_date.day,+ weekend_adjustment=rec.weekend_adjustment,)cat_name, cat_icon, cat_color = cat_map.get(rec.category_id, (None, None, None)) if rec.category_id else (None, None, None)diff --git a/backend/app/services/recurring_match_service.py b/backend/app/services/recurring_match_service.pyindex b60f988f..df98bf56 100644--- a/backend/app/services/recurring_match_service.py+++ b/backend/app/services/recurring_match_service.py@@ -154,12 +154,17 @@ async def find_bill_for_incoming(RecurringTransaction.type == tx_type,))+ from app.services.recurring_transaction_service import adjust_weekend_date+best: Optional[RecurringTransaction] = Nonebest_score = 0.0for rec in result.scalars():before, after = _match_window(rec.frequency)- lo = rec.next_occurrence - timedelta(days=before)- hi = rec.next_occurrence + timedelta(days=after)+ effective_occurrence = adjust_weekend_date(+ rec.next_occurrence, rec.weekend_adjustment+ )+ lo = effective_occurrence - timedelta(days=before)+ hi = effective_occurrence + timedelta(days=after)if not (lo <= tx_date <= hi):continuescore = _description_similarity(rec.description, description)diff --git a/backend/app/services/recurring_transaction_service.py b/backend/app/services/recurring_transaction_service.pyindex e756def7..896e6bf4 100644--- a/backend/app/services/recurring_transaction_service.py+++ b/backend/app/services/recurring_transaction_service.py@@ -3,7 +3,7 @@ import uuidfrom datetime import date, timedeltafrom typing import Optional-from sqlalchemy import or_, select+from sqlalchemy import and_, or_, selectfrom sqlalchemy.ext.asyncio import AsyncSessionfrom app.models.account import Account@@ -79,6 +79,7 @@ async def create_recurring_transaction(currency=data.currency,type=data.type,frequency=data.frequency,+ weekend_adjustment=data.weekend_adjustment,day_of_month=data.day_of_month,start_date=data.start_date,end_date=data.end_date,@@ -105,6 +106,12 @@ async def update_recurring_transaction(update_data = data.model_dump(exclude_unset=True)+ if (+ "weekend_adjustment" in update_data+ and update_data["weekend_adjustment"] is None+ ):+ raise ValueError("weekend_adjustment is required")+# A recurring transaction must always have an account — reject an explicit# null, and verify ownership of any new account_id.if "account_id" in update_data:@@ -170,28 +177,50 @@ def _advance_date(return _advance_months(current, 1, target_day)+def adjust_weekend_date(+ nominal_date: date, weekend_adjustment: str = "none"+) -> date:+ """Return the effective date without changing the nominal schedule date."""+ if weekend_adjustment not in ("none", "previous_friday", "next_monday"):+ raise ValueError(f"Unsupported weekend adjustment: {weekend_adjustment}")++ weekday = nominal_date.weekday()+ if weekend_adjustment == "none" or weekday < calendar.SATURDAY:+ return nominal_date+ if weekend_adjustment == "previous_friday":+ return nominal_date - timedelta(days=weekday - calendar.FRIDAY)+ return nominal_date + timedelta(days=7 - weekday)++def get_occurrences_in_range(start: date, frequency: str, end_date: Optional[date],range_start: date, range_end: date,intended_day: Optional[int] = None,+ weekend_adjustment: str = "none",) -> list[date]:- """Compute all occurrence dates for a recurring pattern within [range_start, range_end).- Pure date math — no DB writes. Used by dashboard for virtual projections."""+ """Compute effective occurrence dates within ``[range_start, range_end)``.++ Schedule advancement and end-date checks use nominal dates. The two-day+ scan margin captures nominal weekend occurrences that move across a range+ boundary; filtering happens only after calculating each effective date.+ """day = intended_day if intended_day else start.day+ nominal_range_start = range_start - timedelta(days=2)+ nominal_range_end = range_end + timedelta(days=2)occurrences: list[date] = []current = start- # Advance to range_start without collecting- while current < range_start:+ while current < nominal_range_start:if end_date and current > end_date:return occurrencescurrent = _advance_date(current, frequency, intended_day=day)- # Collect occurrences within range- while current < range_end:+ while current < nominal_range_end:if end_date and current > end_date:break- occurrences.append(current)+ effective_date = adjust_weekend_date(current, weekend_adjustment)+ if range_start <= effective_date < range_end:+ occurrences.append(effective_date)current = _advance_date(current, frequency, intended_day=day)- if len(occurrences) > 200: # safety limit+ if len(occurrences) > 200:breakreturn occurrences@@ -211,7 +240,16 @@ async def generate_pending(RecurringTransaction.user_id == user_id,RecurringTransaction.is_active == True,RecurringTransaction.auto_generate == True,- RecurringTransaction.next_occurrence <= cutoff,+ or_(+ and_(+ RecurringTransaction.weekend_adjustment == "previous_friday",+ RecurringTransaction.next_occurrence <= cutoff + timedelta(days=2),+ ),+ and_(+ RecurringTransaction.weekend_adjustment != "previous_friday",+ RecurringTransaction.next_occurrence <= cutoff,+ ),+ ),))recurring_list = list(result.scalars().all())@@ -223,9 +261,15 @@ async def generate_pending(# constraint — the user should edit the recurring to fix it.if recurring.account_id is None:continue- # Generate transactions until next_occurrence is past the cutoff- while recurring.next_occurrence <= cutoff:- # Check if past end_date+ # Generate while the effective date is due. The nominal pointer remains+ # authoritative and is the only date used for schedule advancement and+ # end-date evaluation.+ while True:+ effective_occurrence = adjust_weekend_date(+ recurring.next_occurrence, recurring.weekend_adjustment+ )+ if effective_occurrence > cutoff:+ breakif recurring.end_date and recurring.next_occurrence > recurring.end_date:recurring.is_active = Falsebreak@@ -236,7 +280,7 @@ async def generate_pending(# stamped with the recurring link so a later synced charge merges# into it rather than duplicating.existing_real = await recurring_match_service.find_real_tx_for_occurrence(- session, recurring, recurring.next_occurrence+ session, recurring, effective_occurrence)if existing_real is not None:existing_real.recurring_transaction_id = recurring.id@@ -248,7 +292,7 @@ async def generate_pending(description=recurring.description,amount=recurring.amount,currency=recurring.currency,- date=recurring.next_occurrence,+ date=effective_occurrence,type=recurring.type,source="recurring",recurring_transaction_id=recurring.id,diff --git a/backend/app/services/transaction_calendar_service.py b/backend/app/services/transaction_calendar_service.pyindex 69c22901..55113cfd 100644--- a/backend/app/services/transaction_calendar_service.py+++ b/backend/app/services/transaction_calendar_service.py@@ -20,7 +20,10 @@ from app.schemas.transaction_calendar import ()from app.services.dashboard_service import _balance_at, _daily_balance_deltas_by_datefrom app.services.fx_rate_service import convert as fx_convert-from app.services.recurring_transaction_service import get_occurrences_in_range+from app.services.recurring_transaction_service import (+ adjust_weekend_date,+ get_occurrences_in_range,+)async def get_transaction_calendar(@@ -307,13 +310,19 @@ def _actual_item(def _count_occurrences_before(recurring: RecurringTransaction, end: date) -> int:- """Count still-virtual occurrences before ``end`` without truncating."""+ """Count still-virtual effective occurrences before ``end`` without truncating."""+ nominal_start = recurring.next_occurrence+ first_effective = adjust_weekend_date(+ nominal_start, recurring.weekend_adjustment+ )+ range_start = min(nominal_start, first_effective)range_end = end- if recurring.end_date is not None and recurring.end_date < range_end:- range_end = recurring.end_date + timedelta(days=1)+ if recurring.end_date is not None:+ final_effective = adjust_weekend_date(+ recurring.end_date, recurring.weekend_adjustment+ )+ range_end = min(range_end, final_effective + timedelta(days=1))- range_start = recurring.next_occurrence- occurrence_start = recurring.next_occurrencecount = 0while range_start < range_end:# Weekly is the shortest supported cadence. Two hundred-week chunks@@ -321,16 +330,15 @@ def _count_occurrences_before(recurring: RecurringTransaction, end: date) -> int# an arbitrarily long carry horizon.chunk_end = min(range_start + timedelta(weeks=200), range_end)occurrences = get_occurrences_in_range(- start=occurrence_start,+ start=nominal_start,frequency=recurring.frequency,end_date=recurring.end_date,range_start=range_start,range_end=chunk_end,intended_day=recurring.day_of_month or recurring.start_date.day,+ weekend_adjustment=recurring.weekend_adjustment,)count += len(occurrences)- if occurrences:- occurrence_start = occurrences[-1]range_start = chunk_endreturn count@@ -350,7 +358,7 @@ async def _project_recurring_items(.where(RecurringTransaction.workspace_id == workspace_id,RecurringTransaction.is_active == True,- RecurringTransaction.start_date < end,+ RecurringTransaction.start_date < end + timedelta(days=2),Account.is_closed == False,).options(@@ -376,6 +384,7 @@ async def _project_recurring_items(range_start=start,range_end=end,intended_day=rec.day_of_month or rec.start_date.day,+ weekend_adjustment=rec.weekend_adjustment,)category = rec.categoryaccount = rec.accountdiff --git a/backend/mcp_server/tools/lifecycle.py b/backend/mcp_server/tools/lifecycle.pyindex aa323594..f5b84368 100644--- a/backend/mcp_server/tools/lifecycle.py+++ b/backend/mcp_server/tools/lifecycle.py@@ -41,6 +41,7 @@ async def list_recurring_transactions("currency": r.currency,"type": r.type,"frequency": r.frequency,+ "weekend_adjustment": r.weekend_adjustment,"interval": getattr(r, "interval", None),"next_occurrence": r.next_occurrence.isoformat() if getattr(r, "next_occurrence", None) else None,"start_date": r.start_date.isoformat() if getattr(r, "start_date", None) else None,diff --git a/backend/mcp_server/tools/proposals.py b/backend/mcp_server/tools/proposals.pyindex b21260fa..ddb0bf3b 100644--- a/backend/mcp_server/tools/proposals.py+++ b/backend/mcp_server/tools/proposals.py@@ -33,6 +33,7 @@ from app.schemas.goal import GoalCreatefrom app.schemas.recurring_transaction import (RecurringTransactionCreate,RecurringTransactionUpdate,+ WeekendAdjustment,)from app.schemas.rule import RuleAction, RuleCondition, RuleCreatefrom app.schemas.transaction import TransactionCreate@@ -621,6 +622,11 @@ async def propose_create_transaction("amount": {"type": "number", "exclusiveMinimum": 0},"type": {"type": "string", "enum": ["debit", "credit"]},"frequency": {"type": "string", "enum": ["weekly", "monthly", "quarterly", "yearly"]},+ "weekend_adjustment": {+ "type": "string",+ "enum": ["none", "previous_friday", "next_monday"],+ "default": "none",+ },"day_of_month": {"type": "integer", "minimum": 1, "maximum": 31, "description": "Required for monthly or quarterly"},"start_date": {"type": "string", "format": "date", "description": "Defaults to today"},"end_date": {"type": "string", "format": "date"},@@ -644,6 +650,7 @@ async def propose_create_recurring_transaction(type: str,frequency: str,account_id: str,+ weekend_adjustment: WeekendAdjustment = "none",day_of_month: int | None = None,start_date: str | None = None,end_date: str | None = None,@@ -686,6 +693,7 @@ async def propose_create_recurring_transaction("currency": resolved_currency,"type": type,"frequency": frequency,+ "weekend_adjustment": weekend_adjustment,"day_of_month": int(day_of_month) if day_of_month else None,"start_date": target_start.isoformat(),"end_date": target_end.isoformat() if target_end else None,@@ -708,6 +716,7 @@ async def propose_create_recurring_transaction(currency=resolved_currency,type=type,frequency=frequency,+ weekend_adjustment=weekend_adjustment,day_of_month=int(day_of_month) if day_of_month else None,start_date=target_start,end_date=target_end,@@ -737,6 +746,10 @@ async def propose_create_recurring_transaction("description": {"type": "string", "minLength": 1, "maxLength": 500},"amount": {"type": "number", "exclusiveMinimum": 0},"frequency": {"type": "string", "enum": ["weekly", "monthly", "quarterly", "yearly"]},+ "weekend_adjustment": {+ "type": "string",+ "enum": ["none", "previous_friday", "next_monday"],+ },"day_of_month": {"type": "integer", "minimum": 1, "maximum": 31},"end_date": {"type": "string", "format": "date"},"category_id": {"type": "string", "format": "uuid"},@@ -757,6 +770,7 @@ async def propose_update_recurring_transaction(description: str | None = None,amount: float | None = None,frequency: str | None = None,+ weekend_adjustment: str | None = None,day_of_month: int | None = None,end_date: str | None = None,category_id: str | None = None,@@ -794,6 +808,8 @@ async def propose_update_recurring_transaction(changes["amount"] = float(amount)if frequency is not None:changes["frequency"] = frequency+ if weekend_adjustment is not None:+ changes["weekend_adjustment"] = weekend_adjustmentif day_of_month is not None:changes["day_of_month"] = int(day_of_month)if end_date is not None:@@ -815,6 +831,7 @@ async def propose_update_recurring_transaction("amount": num(rt.amount),"currency": rt.currency,"frequency": rt.frequency,+ "weekend_adjustment": rt.weekend_adjustment,"day_of_month": rt.day_of_month,"is_active": bool(getattr(rt, "is_active", True)),},@@ -830,6 +847,8 @@ async def propose_update_recurring_transaction(update_data["amount"] = Decimal(str(changes["amount"]))if "frequency" in changes:update_data["frequency"] = changes["frequency"]+ if "weekend_adjustment" in changes:+ update_data["weekend_adjustment"] = changes["weekend_adjustment"]if "day_of_month" in changes:update_data["day_of_month"] = changes["day_of_month"]if "end_date" in changes:diff --git a/backend/tests/test_agents_mcp_tools.py b/backend/tests/test_agents_mcp_tools.pyindex 1f447dd9..5f2678c2 100644--- a/backend/tests/test_agents_mcp_tools.py+++ b/backend/tests/test_agents_mcp_tools.py@@ -472,11 +472,13 @@ async def test_propose_create_recurring_monthly_full(session=session, ctx=ctx,description="Netflix", amount=55.0, type="debit",frequency="monthly", day_of_month=10,+ weekend_adjustment="previous_friday",account_id=str(test_account.id),)assert r["kind"] == "create_recurring_transaction"assert r["proposed"]["day_of_month"] == 10assert r["proposed"]["frequency"] == "monthly"+ assert r["proposed"]["weekend_adjustment"] == "previous_friday"async def test_propose_update_recurring_no_changes(@@ -827,6 +829,7 @@ async def test_propose_create_recurring_transaction_external_apply_writes(frequency="monthly",day_of_month=10,account_id=str(test_account.id),+ weekend_adjustment="next_monday",apply=True,)assert result.get("applied") is True@@ -839,6 +842,7 @@ async def test_propose_create_recurring_transaction_external_apply_writes(assert row.description == "Netflix"assert row.frequency == "monthly"assert row.day_of_month == 10+ assert row.weekend_adjustment == "next_monday"async def test_propose_update_recurring_transaction_external_apply_writes(@@ -873,12 +877,14 @@ async def test_propose_update_recurring_transaction_external_apply_writes(session=session, ctx=ctx,recurring_id=str(rt.id),amount=27.90,+ weekend_adjustment="previous_friday",apply=True,)assert result.get("applied") is Trueawait session.refresh(rt)assert float(rt.amount) == 27.90+ assert rt.weekend_adjustment == "previous_friday"async def test_propose_cancel_recurring_transaction_deactivate_apply(diff --git a/backend/tests/test_dashboard_service.py b/backend/tests/test_dashboard_service.pyindex 2901764e..9e52c7b5 100644--- a/backend/tests/test_dashboard_service.py+++ b/backend/tests/test_dashboard_service.py@@ -935,6 +935,39 @@ async def test_get_projected_transactions_with_recurring(session, test_user, tesassert result[0].amount == 2500.0+async def test_projected_transactions_use_effective_month_without_duplicates(+ session, test_user, test_workspace+):+ rec = RecurringTransaction(+ id=uuid.uuid4(),+ user_id=test_user.id,+ workspace_id=test_workspace.id,+ description="Month boundary rent",+ amount=Decimal("1000"),+ type="debit",+ frequency="monthly",+ currency="BRL",+ start_date=date(2026, 8, 1),+ next_occurrence=date(2026, 8, 1),+ weekend_adjustment="previous_friday",+ )+ session.add(rec)+ await session.commit()++ july = await get_projected_transactions(+ session, test_workspace.id, test_user.id, month=date(2026, 7, 1)+ )+ august = await get_projected_transactions(+ session, test_workspace.id, test_user.id, month=date(2026, 8, 1)+ )++ july_dates = [item.date for item in july if item.recurring_id == str(rec.id)]+ august_dates = [item.date for item in august if item.recurring_id == str(rec.id)]+ assert july_dates == ["2026-07-31"]+ assert august_dates == []++# ---------------------------------------------------------------------------# get_summary with recurring projections# ---------------------------------------------------------------------------diff --git a/backend/tests/test_recurring_api.py b/backend/tests/test_recurring_api.pyindex a1b4b92c..40221707 100644--- a/backend/tests/test_recurring_api.py+++ b/backend/tests/test_recurring_api.py@@ -26,6 +26,7 @@ async def test_create_recurring_transaction(client, auth_headers, test_categorieassert data["description"] == "Netflix"assert data["frequency"] == "monthly"assert data["is_active"] is True+ assert data["weekend_adjustment"] == "none"# next_occurrence should be start_date since skip_first not setassert data["next_occurrence"] == "2026-03-01"@@ -314,3 +315,128 @@ async def test_generate_pending_skips_legacy_null_account(# Should not raise; should report 0 generated for the legacy row.count = await generate_pending(session, test_user.id, up_to=_date(2026, 4, 1))assert count == 0+++async def test_weekend_adjustment_create_read_and_update(+ client, auth_headers, test_account+):+ create_response = await client.post(+ "/api/recurring-transactions",+ json={+ "description": "Adjusted rent",+ "amount": 1200,+ "currency": "BRL",+ "type": "debit",+ "frequency": "monthly",+ "start_date": "2026-08-01",+ "weekend_adjustment": "previous_friday",+ "account_id": str(test_account.id),+ },+ headers=auth_headers,+ )+ assert create_response.status_code == 201+ created = create_response.json()+ assert created["weekend_adjustment"] == "previous_friday"+ assert created["next_occurrence"] == "2026-08-01"++ list_response = await client.get(+ "/api/recurring-transactions", headers=auth_headers+ )+ listed = next(row for row in list_response.json() if row["id"] == created["id"])+ assert listed["weekend_adjustment"] == "previous_friday"++ update_response = await client.patch(+ f"/api/recurring-transactions/{created['id']}",+ json={"weekend_adjustment": "next_monday"},+ headers=auth_headers,+ )+ assert update_response.status_code == 200+ updated = update_response.json()+ assert updated["weekend_adjustment"] == "next_monday"+ assert updated["next_occurrence"] == "2026-08-01"+++async def test_invalid_weekend_adjustment_is_rejected(+ client, auth_headers, test_account+):+ create_response = await client.post(+ "/api/recurring-transactions",+ json={+ "description": "Invalid policy",+ "amount": 10,+ "type": "debit",+ "frequency": "monthly",+ "start_date": "2026-08-01",+ "weekend_adjustment": "nearest_weekday",+ "account_id": str(test_account.id),+ },+ headers=auth_headers,+ )+ assert create_response.status_code == 422++ valid_response = await client.post(+ "/api/recurring-transactions",+ json={+ "description": "Valid policy",+ "amount": 10,+ "type": "debit",+ "frequency": "monthly",+ "start_date": "2026-08-01",+ "account_id": str(test_account.id),+ },+ headers=auth_headers,+ )+ recurring_id = valid_response.json()["id"]+ update_response = await client.patch(+ f"/api/recurring-transactions/{recurring_id}",+ json={"weekend_adjustment": "nearest_weekday"},+ headers=auth_headers,+ )+ assert update_response.status_code == 422+++async def test_weekend_adjustment_update_rejects_null_but_allows_omission(+ client, auth_headers, test_account+):+ create_response = await client.post(+ "/api/recurring-transactions",+ json={+ "description": "Null policy regression",+ "amount": 10,+ "type": "debit",+ "frequency": "monthly",+ "start_date": "2026-08-01",+ "weekend_adjustment": "previous_friday",+ "account_id": str(test_account.id),+ },+ headers=auth_headers,+ )+ assert create_response.status_code == 201+ recurring_id = create_response.json()["id"]++ omitted_response = await client.patch(+ f"/api/recurring-transactions/{recurring_id}",+ json={},+ headers=auth_headers,+ )+ assert omitted_response.status_code == 200+ assert omitted_response.json()["weekend_adjustment"] == "previous_friday"++ null_response = await client.patch(+ f"/api/recurring-transactions/{recurring_id}",+ json={"weekend_adjustment": None},+ headers=auth_headers,+ )+ assert null_response.status_code == 400+ assert null_response.json()["detail"] == "weekend_adjustment is required"++ list_response = await client.get(+ "/api/recurring-transactions", headers=auth_headers+ )+ listed = next(+ row for row in list_response.json() if row["id"] == recurring_id+ )+ assert listed["weekend_adjustment"] == "previous_friday"diff --git a/backend/tests/test_recurring_match.py b/backend/tests/test_recurring_match.pyindex f39a4c00..fb625459 100644--- a/backend/tests/test_recurring_match.py+++ b/backend/tests/test_recurring_match.py@@ -148,6 +148,44 @@ async def test_find_bill_rejects_low_similarity(session, test_user, test_workspaassert match is None+async def test_find_bill_centers_existing_tolerance_on_effective_date(+ session, test_user, test_workspace, account+):+ bill = await _make_bill(+ session,+ test_workspace,+ test_user,+ account,+ start_date=date(2026, 8, 2),+ weekend_adjustment="next_monday",+ )++ match = await rms.find_bill_for_incoming(+ session,+ test_user.id,+ account.id,+ Decimal("39.90"),+ "BRL",+ "debit",+ date(2026, 8, 8),+ "NETFLIX SUBSCRIPTION",+ )+ outside = await rms.find_bill_for_incoming(+ session,+ test_user.id,+ account.id,+ Decimal("39.90"),+ "BRL",+ "debit",+ date(2026, 8, 9),+ "NETFLIX SUBSCRIPTION",+ )++ assert match is not None and match.id == bill.id+ assert outside is None++# ---------------------------------------------------------------------------# find_placeholder_for_incoming (placeholder-first path)# ---------------------------------------------------------------------------@@ -258,6 +296,37 @@ async def test_generate_pending_links_existing_real_tx(session, test_user, test_assert len(result.scalars().all()) == 1 # only the synced row, no duplicate+async def test_generate_pending_matches_real_transaction_on_effective_date(+ session, test_user, test_workspace, account+):+ bill = await _make_bill(+ session,+ test_workspace,+ test_user,+ account,+ start_date=date(2026, 8, 1),+ weekend_adjustment="previous_friday",+ )+ real = await _add_tx(+ session,+ test_user,+ test_workspace,+ account,+ date=date(2026, 7, 31),+ source="sync",+ external_id="effective-date",+ )++ count = await generate_pending(session, test_user.id, up_to=date(2026, 7, 31))++ assert count == 0+ await session.refresh(real)+ assert real.recurring_transaction_id == bill.id+ await session.refresh(bill)+ assert bill.next_occurrence == date(2026, 9, 1)++@pytest.mark.asyncioasync def test_generate_pending_stamps_placeholder_link(session, test_user, test_workspace, account):bill = await _make_bill(session, test_workspace, test_user, account)diff --git a/backend/tests/test_recurring_transaction_service.py b/backend/tests/test_recurring_transaction_service.pyindex a4463846..7b30a35f 100644--- a/backend/tests/test_recurring_transaction_service.py+++ b/backend/tests/test_recurring_transaction_service.py@@ -12,6 +12,7 @@ from app.models.transaction import Transactionfrom app.schemas.recurring_transaction import RecurringTransactionCreate, RecurringTransactionUpdatefrom app.services.recurring_transaction_service import (_advance_date,+ adjust_weekend_date,create_recurring_transaction,delete_recurring_transaction,generate_pending,@@ -282,6 +283,124 @@ def test_advance_date_quarterly_leap_year_clamping_recovers():assert may == date(2024, 5, 30)+ ("nominal", "policy", "expected"),+ [+ (date(2026, 8, 1), "none", date(2026, 8, 1)),+ (date(2026, 8, 1), "previous_friday", date(2026, 7, 31)),+ (date(2026, 8, 1), "next_monday", date(2026, 8, 3)),+ (date(2026, 8, 2), "none", date(2026, 8, 2)),+ (date(2026, 8, 2), "previous_friday", date(2026, 7, 31)),+ (date(2026, 8, 2), "next_monday", date(2026, 8, 3)),+ (date(2026, 8, 3), "none", date(2026, 8, 3)),+ (date(2026, 8, 3), "previous_friday", date(2026, 8, 3)),+ (date(2026, 8, 3), "next_monday", date(2026, 8, 3)),+ (date(2026, 8, 7), "none", date(2026, 8, 7)),+ (date(2026, 8, 7), "previous_friday", date(2026, 8, 7)),+ (date(2026, 8, 7), "next_monday", date(2026, 8, 7)),+ ],+)+def test_adjust_weekend_date(nominal, policy, expected):+ assert adjust_weekend_date(nominal, policy) == expected+++def test_adjust_weekend_date_rejects_unsupported_policy_on_weekday():+ with pytest.raises(+ ValueError, match="Unsupported weekend adjustment: nearest_weekday"+ ):+ adjust_weekend_date(date(2026, 8, 3), "nearest_weekday")+++ ("frequency", "start", "intended_day", "expected"),+ [+ (+ "weekly",+ date(2026, 8, 1),+ 1,+ [+ (date(2026, 8, 1), date(2026, 7, 31)),+ (date(2026, 8, 8), date(2026, 8, 7)),+ (date(2026, 8, 15), date(2026, 8, 14)),+ ],+ ),+ (+ "monthly",+ date(2026, 1, 31),+ 31,+ [+ (date(2026, 1, 31), date(2026, 1, 30)),+ (date(2026, 2, 28), date(2026, 2, 27)),+ (date(2026, 3, 31), date(2026, 3, 31)),+ ],+ ),+ (+ "quarterly",+ date(2026, 1, 31),+ 31,+ [+ (date(2026, 1, 31), date(2026, 1, 30)),+ (date(2026, 4, 30), date(2026, 4, 30)),+ (date(2026, 7, 31), date(2026, 7, 31)),+ ],+ ),+ (+ "yearly",+ date(2024, 2, 29),+ 29,+ [+ (date(2024, 2, 29), date(2024, 2, 29)),+ (date(2025, 2, 28), date(2025, 2, 28)),+ (date(2026, 2, 28), date(2026, 2, 27)),+ ],+ ),+ ],+)+def test_weekend_adjustment_never_changes_nominal_cadence(+ frequency, start, intended_day, expected+):+ current = start+ actual = []+ for _ in expected:+ actual.append((current, adjust_weekend_date(current, "previous_friday")))+ current = _advance_date(current, frequency, intended_day=intended_day)+ assert actual == expected+++def test_occurrence_range_uses_effective_date_across_month_boundary():+ july = get_occurrences_in_range(+ start=date(2026, 8, 1),+ frequency="monthly",+ end_date=None,+ range_start=date(2026, 7, 1),+ range_end=date(2026, 8, 1),+ weekend_adjustment="previous_friday",+ )+ august = get_occurrences_in_range(+ start=date(2026, 8, 1),+ frequency="monthly",+ end_date=None,+ range_start=date(2026, 8, 1),+ range_end=date(2026, 9, 1),+ weekend_adjustment="previous_friday",+ )++ assert july == [date(2026, 7, 31)]+ assert august == []+ assert july.count(date(2026, 7, 31)) + august.count(date(2026, 7, 31)) == 1+++def test_occurrence_range_moves_sunday_to_following_monday():+ assert get_occurrences_in_range(+ start=date(2026, 8, 2),+ frequency="monthly",+ end_date=None,+ range_start=date(2026, 8, 1),+ range_end=date(2026, 9, 1),+ weekend_adjustment="next_monday",+ ) == [date(2026, 8, 3)]++# ---------------------------------------------------------------------------# get_occurrences_in_range# ---------------------------------------------------------------------------@@ -549,3 +668,98 @@ async def test_generate_pending_no_duplicates(count2 = await generate_pending(session, test_user.id, up_to=date(2025, 3, 1))assert count1 == 3assert count2 == 0+++async def test_generate_pending_previous_friday_uses_effective_cutoff_and_date(+ session: AsyncSession, test_user, test_workspace, test_account_for_recurring+):+ rec = await create_recurring_transaction(+ session,+ test_workspace.id,+ test_user.id,+ RecurringTransactionCreate(+ description="Weekend rent",+ amount=Decimal("1000"),+ type="debit",+ frequency="monthly",+ start_date=date(2026, 8, 1),+ weekend_adjustment="previous_friday",+ account_id=test_account_for_recurring.id,+ ),+ )++ assert await generate_pending(session, test_user.id, up_to=date(2026, 7, 31)) == 1+ transaction = (+ await session.execute(+ select(Transaction).where(Transaction.recurring_transaction_id == rec.id)+ )+ ).scalar_one()+ assert transaction.date == date(2026, 7, 31)+ await session.refresh(rec)+ assert rec.next_occurrence == date(2026, 9, 1)+++async def test_generate_pending_next_monday_waits_until_effective_date(+ session: AsyncSession, test_user, test_workspace, test_account_for_recurring+):+ rec = await create_recurring_transaction(+ session,+ test_workspace.id,+ test_user.id,+ RecurringTransactionCreate(+ description="Weekend salary",+ amount=Decimal("2000"),+ type="credit",+ frequency="monthly",+ start_date=date(2026, 8, 2),+ weekend_adjustment="next_monday",+ account_id=test_account_for_recurring.id,+ ),+ )++ assert await generate_pending(session, test_user.id, up_to=date(2026, 8, 2)) == 0+ await session.refresh(rec)+ assert rec.next_occurrence == date(2026, 8, 2)++ assert await generate_pending(session, test_user.id, up_to=date(2026, 8, 3)) == 1+ transaction = (+ await session.execute(+ select(Transaction).where(Transaction.recurring_transaction_id == rec.id)+ )+ ).scalar_one()+ assert transaction.date == date(2026, 8, 3)+ await session.refresh(rec)+ assert rec.next_occurrence == date(2026, 9, 2)+++async def test_generate_pending_weekend_adjustment_respects_nominal_end_date(+ session: AsyncSession, test_user, test_workspace, test_account_for_recurring+):+ rec = await create_recurring_transaction(+ session,+ test_workspace.id,+ test_user.id,+ RecurringTransactionCreate(+ description="Final weekend bill",+ amount=Decimal("50"),+ type="debit",+ frequency="monthly",+ start_date=date(2026, 8, 1),+ end_date=date(2026, 8, 1),+ weekend_adjustment="previous_friday",+ account_id=test_account_for_recurring.id,+ ),+ )++ assert await generate_pending(session, test_user.id, up_to=date(2026, 7, 31)) == 1+ assert await generate_pending(session, test_user.id, up_to=date(2026, 12, 31)) == 0+ result = await session.execute(+ select(Transaction).where(Transaction.recurring_transaction_id == rec.id)+ )+ assert [transaction.date for transaction in result.scalars()] == [date(2026, 7, 31)]+ await session.refresh(rec)+ assert rec.next_occurrence == date(2026, 9, 1)+ assert rec.is_active is Falsediff --git a/backend/tests/test_transaction_calendar_service.py b/backend/tests/test_transaction_calendar_service.pyindex e0bf5fe4..1f408de3 100644--- a/backend/tests/test_transaction_calendar_service.py+++ b/backend/tests/test_transaction_calendar_service.py@@ -496,6 +496,134 @@ async def test_transaction_calendar_ignored_projection_matches_posted_balance(assert by_date[day].ending_balance == 1000.0+async def test_transaction_calendar_uses_effective_weekend_date_and_balance(+ session: AsyncSession, test_user, test_workspace+):+ account = Account(+ id=uuid.uuid4(),+ user_id=test_user.id,+ workspace_id=test_workspace.id,+ name="Boundary account",+ type="checking",+ balance=Decimal("0"),+ currency="BRL",+ )++ recurring = RecurringTransaction(+ id=uuid.uuid4(),+ user_id=test_user.id,+ workspace_id=test_workspace.id,+ account_id=account.id,+ description="August rent",+ amount=Decimal("300"),+ currency="BRL",+ type="debit",+ frequency="monthly",+ start_date=date(2026, 8, 1),+ next_occurrence=date(2026, 8, 1),+ weekend_adjustment="previous_friday",+ )+ session.add_all([account, recurring])+ await session.commit()++ calendar = await get_transaction_calendar(+ session, test_workspace.id, test_user.id, month=date(2026, 7, 1)+ )+ july_31 = next(day for day in calendar.days if day.date == date(2026, 7, 31))+ august_1 = next(day for day in calendar.days if day.date == date(2026, 8, 1))++ assert [item.description for item in july_31.items] == ["August rent"]+ assert july_31.projected_expense == 300.0+ assert july_31.ending_balance == -300.0+ assert august_1.projected_count == 0+ assert august_1.ending_balance == -300.0+++ ("nominal_date", "weekend_adjustment", "effective_date", "comparison_date"),+ [+ (+ date(2026, 8, 30),+ "previous_friday",+ date(2026, 8, 28),+ date(2026, 8, 30),+ ),+ (+ date(2026, 8, 29),+ "next_monday",+ date(2026, 8, 31),+ date(2026, 8, 31),+ ),+ ],+)+async def test_transaction_calendar_weekend_balance_matches_overlapping_views(+ session: AsyncSession,+ test_user,+ test_workspace,+ nominal_date: date,+ weekend_adjustment: str,+ effective_date: date,+ comparison_date: date,+):+ account = Account(+ id=uuid.uuid4(),+ user_id=test_user.id,+ workspace_id=test_workspace.id,+ name="Checking",+ type="checking",+ balance=Decimal("0"),+ currency="BRL",+ )+ recurring = RecurringTransaction(+ id=uuid.uuid4(),+ user_id=test_user.id,+ workspace_id=test_workspace.id,+ account_id=account.id,+ description="Weekend-adjusted debit",+ amount=Decimal("100"),+ currency="BRL",+ type="debit",+ frequency="weekly",+ start_date=nominal_date,+ next_occurrence=nominal_date,+ weekend_adjustment=weekend_adjustment,+ )+ session.add_all([+ account,+ Transaction(+ id=uuid.uuid4(),+ user_id=test_user.id,+ workspace_id=test_workspace.id,+ account_id=account.id,+ description="Opening",+ amount=Decimal("1000"),+ currency="BRL",+ date=date(2026, 7, 1),+ type="credit",+ source="opening_balance",+ ),+ recurring,+ ])+ await session.commit()++ august = await get_transaction_calendar(+ session, test_workspace.id, test_user.id, month=date(2026, 8, 1)+ )+ september = await get_transaction_calendar(+ session, test_workspace.id, test_user.id, month=date(2026, 9, 1)+ )+ august_by_date = {day.date: day for day in august.days}+ september_by_date = {day.date: day for day in september.days}++ assert august_by_date[effective_date].projected_count == 1+ if effective_date in september_by_date:+ assert september_by_date[effective_date].projected_count == 1+ assert august_by_date[comparison_date].ending_balance == 900.0+ assert september_by_date[comparison_date].ending_balance == 900.0++@pytest.mark.asyncioasync def test_transaction_calendar_overlap_carries_virtual_occurrences(session: AsyncSession, test_user, test_workspacediff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.jsonindex 1892a0ef..6339f187 100644--- a/frontend/src/locales/de.json+++ b/frontend/src/locales/de.json@@ -786,6 +786,10 @@"weekly": "Wöchentlich","yearly": "Jährlich","dayOfMonth": "Tag des Monats",+ "weekendAdjustment": "Wochenendanpassung",+ "weekendAdjustmentNone": "Keine Anpassung",+ "weekendAdjustmentPreviousFriday": "Freitag vor dem Wochenende",+ "weekendAdjustmentNextMonday": "Montag nach dem Wochenende","startDate": "Startdatum","endDate": "Enddatum (optional)","category": "Kategorie",diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.jsonindex 4476a456..3da348d1 100644--- a/frontend/src/locales/en.json+++ b/frontend/src/locales/en.json@@ -786,6 +786,10 @@"weekly": "Weekly","yearly": "Yearly","dayOfMonth": "Day of month",+ "weekendAdjustment": "Weekend adjustment",+ "weekendAdjustmentNone": "No adjustment",+ "weekendAdjustmentPreviousFriday": "Friday before the weekend",+ "weekendAdjustmentNextMonday": "Monday after the weekend","startDate": "Start date","endDate": "End date (optional)","category": "Category",diff --git a/frontend/src/locales/es.json b/frontend/src/locales/es.jsonindex ce2e7c23..42d7ff9c 100644--- a/frontend/src/locales/es.json+++ b/frontend/src/locales/es.json@@ -786,6 +786,10 @@"weekly": "Semanal","yearly": "Anual","dayOfMonth": "Día del mes",+ "weekendAdjustment": "Ajuste de fin de semana",+ "weekendAdjustmentNone": "Sin ajuste",+ "weekendAdjustmentPreviousFriday": "Viernes anterior al fin de semana",+ "weekendAdjustmentNextMonday": "Lunes posterior al fin de semana","startDate": "Fecha de inicio","endDate": "Fecha de fin (opcional)","category": "Categoría",diff --git a/frontend/src/locales/fr.json b/frontend/src/locales/fr.jsonindex 31b52622..434f96cf 100644--- a/frontend/src/locales/fr.json+++ b/frontend/src/locales/fr.json@@ -786,6 +786,10 @@"weekly": "Hebdomadaire","yearly": "Annuelle","dayOfMonth": "Jour du mois",+ "weekendAdjustment": "Ajustement du week-end",+ "weekendAdjustmentNone": "Aucun ajustement",+ "weekendAdjustmentPreviousFriday": "Vendredi avant le week-end",+ "weekendAdjustmentNextMonday": "Lundi après le week-end","startDate": "Date de début","endDate": "Date de fin (optionnel)","category": "Catégorie",diff --git a/frontend/src/locales/it.json b/frontend/src/locales/it.jsonindex 2e9f14da..9f0c8c5f 100644--- a/frontend/src/locales/it.json+++ b/frontend/src/locales/it.json@@ -786,6 +786,10 @@"weekly": "Settimanale","yearly": "Annuale","dayOfMonth": "Giorno del mese",+ "weekendAdjustment": "Regolazione del fine settimana",+ "weekendAdjustmentNone": "Nessuna regolazione",+ "weekendAdjustmentPreviousFriday": "Venerdì prima del fine settimana",+ "weekendAdjustmentNextMonday": "Lunedì dopo il fine settimana","startDate": "Data di inizio","endDate": "Data di fine (facoltativa)","category": "Categoria",diff --git a/frontend/src/locales/pl.json b/frontend/src/locales/pl.jsonindex 966f913d..33e3135e 100644--- a/frontend/src/locales/pl.json+++ b/frontend/src/locales/pl.json@@ -834,6 +834,10 @@"weekly": "Tygodniowo","yearly": "Rocznie","dayOfMonth": "Dzień miesiąca",+ "weekendAdjustment": "Korekta weekendowa",+ "weekendAdjustmentNone": "Bez korekty",+ "weekendAdjustmentPreviousFriday": "Piątek przed weekendem",+ "weekendAdjustmentNextMonday": "Poniedziałek po weekendzie","startDate": "Data rozpoczęcia","endDate": "Data zakończenia (opcjonalnie)","category": "Kategoria",diff --git a/frontend/src/locales/pt-BR.json b/frontend/src/locales/pt-BR.jsonindex f839b242..059272cf 100644--- a/frontend/src/locales/pt-BR.json+++ b/frontend/src/locales/pt-BR.json@@ -786,6 +786,10 @@"weekly": "Semanal","yearly": "Anual","dayOfMonth": "Dia do mês",+ "weekendAdjustment": "Ajuste de fim de semana",+ "weekendAdjustmentNone": "Sem ajuste",+ "weekendAdjustmentPreviousFriday": "Sexta-feira antes do fim de semana",+ "weekendAdjustmentNextMonday": "Segunda-feira depois do fim de semana","startDate": "Data de início","endDate": "Data de fim (opcional)","category": "Categoria",diff --git a/frontend/src/locales/pt-PT.json b/frontend/src/locales/pt-PT.jsonindex 98206d68..61f2bd8c 100644--- a/frontend/src/locales/pt-PT.json+++ b/frontend/src/locales/pt-PT.json@@ -786,6 +786,10 @@"weekly": "Semanal","yearly": "Anual","dayOfMonth": "Dia do mês",+ "weekendAdjustment": "Ajuste de fim de semana",+ "weekendAdjustmentNone": "Sem ajuste",+ "weekendAdjustmentPreviousFriday": "Sexta-feira antes do fim de semana",+ "weekendAdjustmentNextMonday": "Segunda-feira depois do fim de semana","startDate": "Data de início","endDate": "Data de fim (opcional)","category": "Categoria",diff --git a/frontend/src/locales/ru.json b/frontend/src/locales/ru.jsonindex 959093dd..bf2925f7 100644--- a/frontend/src/locales/ru.json+++ b/frontend/src/locales/ru.json@@ -792,6 +792,10 @@"weekly": "Еженедельно","yearly": "Ежегодно","dayOfMonth": "День месяца",+ "weekendAdjustment": "Корректировка на выходные",+ "weekendAdjustmentNone": "Без корректировки",+ "weekendAdjustmentPreviousFriday": "Пятница перед выходными",+ "weekendAdjustmentNextMonday": "Понедельник после выходных","startDate": "Дата начала","endDate": "Дата окончания (опционально)","category": "Категория",diff --git a/frontend/src/locales/uk.json b/frontend/src/locales/uk.jsonindex 2a03789a..efb863e4 100644--- a/frontend/src/locales/uk.json+++ b/frontend/src/locales/uk.json@@ -792,6 +792,10 @@"weekly": "Щотижня","yearly": "Щороку","dayOfMonth": "День місяця",+ "weekendAdjustment": "Коригування на вихідні",+ "weekendAdjustmentNone": "Без коригування",+ "weekendAdjustmentPreviousFriday": "П’ятниця перед вихідними",+ "weekendAdjustmentNextMonday": "Понеділок після вихідних","startDate": "Дата початку","endDate": "Дата закінчення (необов'язково)","category": "Категорія",diff --git a/frontend/src/pages/recurring.tsx b/frontend/src/pages/recurring.tsxindex d42837a5..1ddb286f 100644--- a/frontend/src/pages/recurring.tsx+++ b/frontend/src/pages/recurring.tsx@@ -300,6 +300,9 @@ function RecurringForm({const [currency, setCurrency] = useState(recurring?.currency ?? userCurrency)const [type, setType] = useState<'debit' | 'credit'>(recurring?.type ?? 'debit')const [frequency, setFrequency] = useState(recurring?.frequency ?? 'monthly')+ const [weekendAdjustment, setWeekendAdjustment] = useState<RecurringTransaction['weekend_adjustment']>(+ recurring?.weekend_adjustment ?? 'none'+ )const [dayOfMonth, setDayOfMonth] = useState(recurring?.day_of_month?.toString() ?? '')const [startDate, setStartDate] = useState(recurring?.start_date ?? localDateString())const [endDate, setEndDate] = useState(recurring?.end_date ?? '')@@ -320,6 +323,7 @@ function RecurringForm({currency,type,frequency,+ weekend_adjustment: weekendAdjustment,day_of_month: dayOfMonth ? parseInt(dayOfMonth) : null,start_date: startDate,end_date: endDate || null,@@ -373,6 +377,18 @@ function RecurringForm({</div>)}</div>+ <div className="space-y-2">+ <Label>{t('recurring.weekendAdjustment')}</Label>+ <select+ className={selectClass}+ value={weekendAdjustment}+ onChange={(e) => setWeekendAdjustment(e.target.value as RecurringTransaction['weekend_adjustment'])}+ >+ <option value="none">{t('recurring.weekendAdjustmentNone')}</option>+ <option value="previous_friday">{t('recurring.weekendAdjustmentPreviousFriday')}</option>+ <option value="next_monday">{t('recurring.weekendAdjustmentNextMonday')}</option>+ </select>+ </div><div className="grid grid-cols-2 gap-4"><div className="space-y-2"><Label>{t('recurring.startDate')}</Label>diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.tsindex 12687a81..d59ab650 100644--- a/frontend/src/types/index.ts+++ b/frontend/src/types/index.ts@@ -432,6 +432,7 @@ export interface RecurringTransaction {currency: stringtype: 'debit' | 'credit'frequency: 'monthly' | 'quarterly' | 'weekly' | 'yearly'+ weekend_adjustment: 'none' | 'previous_friday' | 'next_monday'day_of_month: number | nullstart_date: stringend_date: string | null