Skip to content

Invoice Due-Date Reminder Scheduler #542

Description

@Kingsman-99

Description

The SDK creates invoices with due dates but provides no mechanism to trigger reminder notifications at configurable intervals before the due date (e.g. 7 days, 1 day, 1 hour). Integrators implement ad-hoc setTimeout calls that break on process restarts. A due-date reminder scheduler should persist reminder schedules and fire callbacks reliably, including recovering missed reminders after a restart.

Technical Context

Add src/invoiceReminderScheduler.ts. Extends src/scheduler.ts. Persists scheduled reminders in src/snapshot.ts keyed by invoiceId. Reads InvoiceRecord.dueAt from src/types.ts. Adds ReminderSchedule and ReminderEvent to src/types.ts. Emits invoiceReminderDue via src/events.ts. On startup, loads persisted schedules and fires any that are past-due within a configurable grace period.

Acceptance Criteria

  • InvoiceReminderScheduler.schedule(invoiceId, offsets: number[]) registers reminders at each offset ms before the invoice due date
  • Persists the schedule to src/snapshot.ts so reminders survive process restarts
  • On SDK init, loads persisted schedules and immediately fires any reminder whose scheduled time is in the past but within gracePeriodMs (default 60 000 ms)
  • Emits invoiceReminderDue with { invoiceId, offsetMs, dueAt } for each triggered reminder
  • InvoiceReminderScheduler.cancel(invoiceId) removes all pending reminders for an invoice from the store
  • All CI checks (npm test, npm run build, ESLint/TypeScript) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions