Open-source personal finance manager. Self-hosted, privacy-first.
fix(transactions): preserve recurring calendar date in dialog (#1088)
Albert Dolkun1a6eff3f9e98
diff --git a/frontend/src/components/transaction-dialog.test.tsx b/frontend/src/components/transaction-dialog.test.tsxnew file mode 100644index 00000000..58da7f7c--- /dev/null+++ b/frontend/src/components/transaction-dialog.test.tsx@@ -0,0 +1,73 @@+import { screen } from '@testing-library/react'+import { afterEach, expect, it, vi } from 'vitest'++import { TransactionDialog } from '@/components/transaction-dialog'+import { currencies, groups, payees } from '@/lib/api'+import { renderWithProviders, t } from '@/test/utils'+import type { RecurringTransaction } from '@/types'++vi.mock('@/contexts/auth-context', () => ({+ useAuth: () => ({ user: { preferences: { currency_display: 'USD' } } }),+}))+vi.mock('@/hooks/use-display-locale', () => ({+ useDateLocale: () => 'en-US',+ useDisplayLocale: () => 'en-US',+}))++afterEach(() => vi.restoreAllMocks())++it.each(['America/Los_Angeles', 'Pacific/Kiritimati'])(+ 'keeps a recurring calendar date unchanged in %s',+ async (timezone) => {+ const originalTimezone = process.env.TZ+ const recurringMatch: RecurringTransaction = {+ id: 'recurring-rent',+ user_id: 'synthetic-user',+ account_id: null,+ category_id: null,+ description: 'Rent',+ amount: 100,+ currency: 'USD',+ type: 'debit',+ frequency: 'monthly',+ weekend_adjustment: 'none',+ day_of_month: 8,+ start_date: '2026-01-08',+ end_date: null,+ is_active: true,+ auto_generate: false,+ next_occurrence: '2026-03-08',+ amount_primary: null,+ fx_rate_used: null,+ }+ vi.spyOn(currencies, 'list').mockResolvedValue([])+ vi.spyOn(payees, 'list').mockResolvedValue([])+ vi.spyOn(groups, 'list').mockResolvedValue([])++ try {+ process.env.TZ = timezone+ renderWithProviders(+ <TransactionDialog+ open+ onClose={vi.fn()}+ transaction={null}+ categories={[]}+ categoryGroups={[]}+ accounts={[]}+ recurringMatch={recurringMatch}+ onSave={vi.fn()}+ loading={false}+ error={null}+ />,+ )++ expect(await screen.findByText(t('transactions.recurringInfo', {+ frequency: t('recurring.monthly'),+ next: '3/8/2026',+ }))).toBeInTheDocument()+ } finally {+ if (originalTimezone === undefined) delete process.env.TZ+ else process.env.TZ = originalTimezone+ }+ },+)diff --git a/frontend/src/components/transaction-dialog.tsx b/frontend/src/components/transaction-dialog.tsxindex 3ec6606a..3570a3a4 100644--- a/frontend/src/components/transaction-dialog.tsx+++ b/frontend/src/components/transaction-dialog.tsx@@ -935,7 +935,7 @@ function TransactionForm({<div className="flex items-center gap-2 p-3 text-sm bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-md"><span>{t('transactions.recurringInfo', {frequency: t(`recurring.${recurringMatch.frequency}`),- next: new Date(recurringMatch.next_occurrence).toLocaleDateString(dateLocale),+ next: new Date(recurringMatch.next_occurrence + 'T00:00:00').toLocaleDateString(dateLocale),})}</span></div>)}