Skip to content

A local-first personal finance app

re-sort preview transactions after rule application (#7691)

Matt Fiddamand6fc3212b9e3
diff --git a/packages/desktop-client/src/hooks/usePreviewTransactions.ts b/packages/desktop-client/src/hooks/usePreviewTransactions.ts
index d5ed176a54..f0526e9bd5 100644
--- a/packages/desktop-client/src/hooks/usePreviewTransactions.ts
+++ b/packages/desktop-client/src/hooks/usePreviewTransactions.ts
@@ -1,6 +1,7 @@
import { useEffect, useMemo, useState } from 'react';
import { send } from '@actual-app/core/platform/client/connection';
+import * as monthUtils from '@actual-app/core/shared/months';
import { computeSchedulePreviewTransactions } from '@actual-app/core/shared/schedules';
import { ungroupTransactions } from '@actual-app/core/shared/transactions';
import type { IntegerAmount } from '@actual-app/core/shared/util';
@@ -100,6 +101,13 @@ export function usePreviewTransactions({
),
}));
+ // re-sort in case rule actions have changed the dates
+ withDefaults.sort(
+ (a, b) =>
+ monthUtils.parseDate(b.date).getTime() -
+ monthUtils.parseDate(a.date).getTime() || a.amount - b.amount,
+ );
+
const ungroupedTransactions = ungroupTransactions(withDefaults);
setPreviewTransactions(ungroupedTransactions);
diff --git a/upcoming-release-notes/7691.md b/upcoming-release-notes/7691.md
new file mode 100644
index 0000000000..838be50452
--- /dev/null
+++ b/upcoming-release-notes/7691.md
@@ -0,0 +1,6 @@
+---
+category: Bugfixes
+authors: [matt-fidd]
+---
+
+Fix schedules not appearing on the mobile view when the date is changed by rules