Skip to content

fix(recurring): keep start date and allow clearing end date on edit - #547

Open
robitec97 wants to merge 1 commit into
RIP-Comm:mainfrom
robitec97:fix/recurring-edit-dates
Open

robitec97 wants to merge 1 commit into
RIP-Comm:mainfrom
robitec97:fix/recurring-edit-dates

Conversation

@robitec97

Copy link
Copy Markdown

🎯 Description

Editing a recurring transaction changed its start date to whatever selectedDateProvider held: today, or the date of the last transaction opened in the add page. That also moved the day of the month future payments are inserted on. Selecting "Never" as end date was ignored, so the old end date was kept.

Closes: #545

📱 Changes

  • RecurringTransactionsNotifier.updateTransaction no longer sets fromDate. The start date is read-only on the edit page, so the stored value is kept.
  • RecurringTransaction.copy() can now set toDate to null, using the same _unset sentinel Transaction.copy() already uses for id.
  • New provider test test/providers/recurring_transactions_provider_test.dart that runs the real edit flow (transactionSelect → updateTransaction) against the test DB. On current main both tests fail:
    • start date: expected 2024-01-01, actual 2025-05-20 (the stale selectedDateProvider value)
    • "Never": expected null, actual 2027-01-01

🧪 Testing Instructions

Behaviour

  1. Create a monthly recurring transaction with a start date in the past (e.g. the 1st of last month) and an end date.
  2. Open it from Planning, change only the amount, press UPDATE TRANSACTION.
  3. Reopen it: "Date Start" is unchanged (before: today).
  4. Edit it again, set the end date to "Never", update, reopen: the end date is "Never" (before: the old date came back).

dart format, flutter analyze and flutter test --concurrency=1 all pass locally (Flutter 3.38.8).

🔍 Checklist for reviewers

  • Code is formatted correctly
  • Tests are passing
  • New tests are added (if needed)
  • Style matches the figma/designer requests
  • Tested on:
    • iOS
    • Android

Editing a recurring transaction overwrote its start date with whatever
selectedDateProvider held (today, or the date of the last transaction
opened in the add page), since transactionSelect never sets it and the
edit page shows the start date as read-only. For monthly recurrences this
also shifted the day of the month future payments are inserted on.

Selecting "Never" as end date was also ignored, because
RecurringTransaction.copy() treated a null toDate as "keep the current
value". Use the same _unset sentinel already used by Transaction.copy().

@mikev-cw mikev-cw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch, thank you!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Editing a recurring transaction changes its start date and ignores "Never" end date

2 participants