diff --git a/apps/dashboard/jobs/tasks/bank/notifications/transactions.ts b/apps/dashboard/jobs/tasks/bank/notifications/transactions.ts index d84fb9b971..1aadcd3457 100644 --- a/apps/dashboard/jobs/tasks/bank/notifications/transactions.ts +++ b/apps/dashboard/jobs/tasks/bank/notifications/transactions.ts @@ -36,10 +36,14 @@ export const transactionNotifications = schemaTask({ .eq("role", "owner") .throwOnError(); - if (transactionsData && transactionsData.length > 0) { - await handleTransactionNotifications(usersData, transactionsData); - await handleTransactionEmails(usersData, transactionsData); - await handleTransactionSlackNotifications(teamId, transactionsData); + const sortedTransactions = transactionsData?.sort((a, b) => { + return new Date(b.date).getTime() - new Date(a.date).getTime(); + }); + + if (sortedTransactions && sortedTransactions.length > 0) { + await handleTransactionNotifications(usersData, sortedTransactions); + await handleTransactionEmails(usersData, sortedTransactions); + await handleTransactionSlackNotifications(teamId, sortedTransactions); } } catch (error) { await logger.error("Transactions notification", { error }); diff --git a/apps/dashboard/jobs/tasks/bank/sync/connection.ts b/apps/dashboard/jobs/tasks/bank/sync/connection.ts index 123d108285..e0707ba6fc 100644 --- a/apps/dashboard/jobs/tasks/bank/sync/connection.ts +++ b/apps/dashboard/jobs/tasks/bank/sync/connection.ts @@ -157,9 +157,6 @@ export const syncConnection = schemaTask({ .from("bank_connections") .update({ status: "disconnected" }) .eq("id", connectionId); - - // Revalidate the bank cache (transactions, accounts, connections) - await revalidateCache({ tag: "bank", teamId: data.team_id }); } } catch (error) { logger.error("Failed to sync connection", { error }); diff --git a/apps/dashboard/jobs/utils/transaction-notifications.ts b/apps/dashboard/jobs/utils/transaction-notifications.ts index 9af91208c4..87f49e88ac 100644 --- a/apps/dashboard/jobs/utils/transaction-notifications.ts +++ b/apps/dashboard/jobs/utils/transaction-notifications.ts @@ -51,8 +51,8 @@ export async function handleTransactionNotifications( name: TriggerEvents.TransactionsNewInApp, payload: { type: NotificationTypes.Transactions, - from: transactions[0]?.date, - to: transactions[transactions.length - 1]?.date, + from: transactions[transactions.length - 1]?.date, + to: transactions[0]?.date, description: t("notifications.transactions", { numberOfTransactions: transactions.length, // For single transaction diff --git a/packages/email/emails/transactions.tsx b/packages/email/emails/transactions.tsx index 2ca7b3817f..f87f34a25b 100644 --- a/packages/email/emails/transactions.tsx +++ b/packages/email/emails/transactions.tsx @@ -291,7 +291,7 @@ export const TransactionsEmail = ({