A local-first personal finance app
Fix schedule actions not applying and schedules paid the same day not showing (#4171)
Matt Fiddaman2a275b382119
diff --git a/packages/desktop-client/e2e/page-models/schedules-page.js b/packages/desktop-client/e2e/page-models/schedules-page.jsindex 6ddb001193..3166b96509 100644--- a/packages/desktop-client/e2e/page-models/schedules-page.js+++ b/packages/desktop-client/e2e/page-models/schedules-page.js@@ -48,7 +48,7 @@ export class SchedulesPage {* 0-based index*/async postNthSchedule(index) {- await this._performNthAction(index, 'Post transaction');+ await this._performNthAction(index, 'Post transaction today');await this.page.waitForTimeout(1000);}diff --git a/packages/desktop-client/src/components/modals/ScheduledTransactionMenuModal.tsx b/packages/desktop-client/src/components/modals/ScheduledTransactionMenuModal.tsxindex 2866152c14..ceec684cbf 100644--- a/packages/desktop-client/src/components/modals/ScheduledTransactionMenuModal.tsx+++ b/packages/desktop-client/src/components/modals/ScheduledTransactionMenuModal.tsx@@ -117,7 +117,7 @@ function ScheduledTransactionMenu({items={[{name: 'post',- text: t('Post transaction'),+ text: t('Post transaction today'),},{name: 'skip',diff --git a/packages/desktop-client/src/components/schedules/PostsOfflineNotification.tsx b/packages/desktop-client/src/components/schedules/PostsOfflineNotification.tsxindex 47e9e70c4f..c3b163c723 100644--- a/packages/desktop-client/src/components/schedules/PostsOfflineNotification.tsx+++ b/packages/desktop-client/src/components/schedules/PostsOfflineNotification.tsx@@ -78,8 +78,8 @@ export function PostsOfflineNotification() {<Paragraph><Trans>You can always manually post a transaction later for a due- schedule by selecting the schedule and clicking “Post transaction”- in the action menu.+ schedule by selecting the schedule and clicking “Post transaction+ today” in the action menu.</Trans></Paragraph><Stackdiff --git a/packages/desktop-client/src/components/schedules/SchedulesTable.tsx b/packages/desktop-client/src/components/schedules/SchedulesTable.tsxindex e3a1782db6..b902c581ca 100644--- a/packages/desktop-client/src/components/schedules/SchedulesTable.tsx+++ b/packages/desktop-client/src/components/schedules/SchedulesTable.tsx@@ -71,7 +71,7 @@ function OverflowMenu({menuItems.push({name: 'post-transaction',- text: t('Post transaction'),+ text: t('Post transaction today'),});if (status === 'completed') {@@ -83,7 +83,7 @@ function OverflowMenu({menuItems.push({name: 'skip',- text: t('Skip next date'),+ text: t('Skip next scheduled date'),},{name: 'complete',diff --git a/packages/desktop-client/src/components/transactions/SelectedTransactionsButton.tsx b/packages/desktop-client/src/components/transactions/SelectedTransactionsButton.tsxindex 77a6966b17..d6779e717f 100644--- a/packages/desktop-client/src/components/transactions/SelectedTransactionsButton.tsx+++ b/packages/desktop-client/src/components/transactions/SelectedTransactionsButton.tsx@@ -220,9 +220,9 @@ export function SelectedTransactionsButton({} as const,{name: 'post-transaction',- text: t('Post transaction'),+ text: t('Post transaction today'),} as const,- { name: 'skip', text: t('Skip scheduled date') } as const,+ { name: 'skip', text: t('Skip next scheduled date') } as const,]: [{ name: 'show', text: t('Show'), key: 'F' } as const,diff --git a/packages/desktop-client/src/components/transactions/TransactionMenu.tsx b/packages/desktop-client/src/components/transactions/TransactionMenu.tsxindex 1d87d30a4d..b5c0c42d81 100644--- a/packages/desktop-client/src/components/transactions/TransactionMenu.tsx+++ b/packages/desktop-client/src/components/transactions/TransactionMenu.tsx@@ -97,8 +97,8 @@ export function TransactionMenu({isPreview? [{ name: 'view-schedule', text: t('View schedule') },- { name: 'post-transaction', text: t('Post transaction') },- { name: 'skip', text: t('Skip scheduled date') },+ { name: 'post-transaction', text: t('Post transaction today') },+ { name: 'skip', text: t('Skip next scheduled date') },]: [{diff --git a/packages/loot-core/src/client/data-hooks/transactions.ts b/packages/loot-core/src/client/data-hooks/transactions.tsindex 1d298888ad..a0336c9295 100644--- a/packages/loot-core/src/client/data-hooks/transactions.ts+++ b/packages/loot-core/src/client/data-hooks/transactions.ts@@ -167,17 +167,24 @@ export function usePreviewTransactions(): UsePreviewTransactionsResult {const { date: dateConditions } = extractScheduleConds(schedule._conditions,);- let day = parseDate(schedule.next_date);+ let day = d.startOfDay(parseDate(schedule.next_date));++ const status = statuses.get(schedule.id);const dates: Set<string> = new Set();while (day <= upcomingPeriodEnd) {const nextDate = getNextDate(dateConditions, day);- day = parseDate(addDays(nextDate, 1));++ if (status === 'paid' && day.getTime() === today.getTime()) {+ day = parseDate(addDays(nextDate, 1));+ continue;+ }if (dates.has(nextDate)) break;if (parseDate(nextDate) > upcomingPeriodEnd) break;dates.add(nextDate);+ day = parseDate(addDays(nextDate, 1));}const schedules: {@@ -191,13 +198,13 @@ export function usePreviewTransactions(): UsePreviewTransactionsResult {}[] = [];dates.forEach(date => {schedules.push({- id: 'preview/' + schedule.id + date,+ id: 'preview/' + schedule.id + `/${date}`,payee: schedule._payee,account: schedule._account,amount: getScheduledAmount(schedule._amount),date,schedule: schedule.id,- forceUpcoming: schedules.length > 0,+ forceUpcoming: schedules.length > 0 || status === 'paid',});});@@ -314,6 +321,6 @@ function isForPreview(schedule: ScheduleEntity, statuses: ScheduleStatuses) {const status = statuses.get(schedule.id);return (!schedule.completed &&- (status === 'due' || status === 'upcoming' || status === 'missed')+ ['due', 'upcoming', 'missed', 'paid'].includes(status!));}diff --git a/upcoming-release-notes/4171.md b/upcoming-release-notes/4171.mdnew file mode 100644index 0000000000..f7dd41d5ce--- /dev/null+++ b/upcoming-release-notes/4171.md@@ -0,0 +1,6 @@+---+category: Bugfix+authors: [matt-fidd]+---++Fix schedule actions not applying and schedules paid today not showing