Skip to content

Conversation

@krokosik
Copy link
Collaborator

@krokosik krokosik commented Oct 7, 2025

Closes #160

This is a big one. I didn't really like pg-boss and opted for a more resilient solution of pg_cron. We use it anyway for cache cleaning now, so it's better that we do not add another dependency.

It is also a bit limiting, so for now balances are not updated in DB, as we will remove them in release 1.6 after all. To further support this decision we already introduce major DB migrations in the form of migrating expense cuids to native PG uuids, which is required for recurring expenses to be insertable using SQL procedures (that pg_cron uses).

The scheduling itself is of course cron based, I spent a lot of time polishing it, but feedback is welcome.

Logic wise, each expense with a defined schedule:

  • gets an associated pg_cron job
  • gets a duplicate once the job is triggered
  • each expense share an N-1 relation with the cron job
  • upon editing the cron job is recreated => editing is global, no new scheduling jobs are spawned
  • upon deleting the cron job stays until there are no more expenses => delete job ONLY when all expenses are deleted

There is a new recurrence view at the activity tab.

PLease note that it is not deploy ready yet. We still require #247
@FriesischScott I guess now is the time for us to finish it up if you're still up to it ;)

screenrecording-2025-10-07_21-47-50.mp4

@krokosik krokosik requested a review from Copilot October 7, 2025 19:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements recurring expense functionality, allowing users to schedule expenses to repeat automatically using cron expressions. The implementation replaces pg-boss with pg_cron for better database-native job scheduling and migrates expense IDs from CUIDs to PostgreSQL UUIDs to support SQL procedures.

  • Adds a comprehensive cron builder UI with timezone handling and internationalization
  • Implements database schema changes for recurring expenses with pg_cron integration
  • Creates a new recurring expenses page and navigation integration

Reviewed Changes

Copilot reviewed 40 out of 43 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/types/expense.types.ts Adds recurrenceId field to expense creation type and cronExpression to schema
src/store/addStore.ts Updates expense store with recurring expense fields and improved state management
src/server/api/services/splitService.ts Adds cron job cleanup logic for expense deletion and editing
src/server/api/services/scheduleService.ts Implements recurring expense job creation function
src/server/api/routers/expense.ts Adds recurring expense creation, retrieval, and cron schedule handling
src/pages/recurring.tsx New page displaying user's recurring expenses
src/lib/cron.ts Comprehensive cron expression timezone conversion utilities
src/components/ui/cron-builder.tsx Full-featured cron expression builder component
src/components/AddExpense/RecurrenceInput.tsx Integration component for recurring expense input
prisma/schema.prisma Major schema changes including UUID migration and pg_cron tables
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@krokosik krokosik merged commit 33e8c23 into main Oct 8, 2025
1 check passed
@krokosik krokosik deleted the 160-recurring-expense branch October 8, 2025 19:14
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.

Feature Request: Recurring expense

2 participants