Skip to content

Add cancelReminder and getPendingReminders to invoiceReminderScheduler #616

Description

@Kingsman-99

Description

src/invoiceReminderScheduler.ts schedules reminders for invoice deadlines but provides no way to cancel a previously scheduled reminder. If an invoice is paid early or the deadline changes, the reminder fires anyway with no cancellation path.

Acceptance Criteria

  • scheduleReminder returns a reminderId: string (opaque unique identifier)
  • cancelReminder(reminderId: string): boolean exported — cancels the reminder and returns true; returns false if the ID is unknown or already fired
  • getPendingReminders(): Array<{ reminderId: string; invoiceId: string; remindAt: number }> exported — returns all not-yet-fired, not-cancelled reminders
  • Cancelled reminders do not fire even if their scheduled time passes
  • clearAllReminders(): void exported for test teardown
  • All exported from src/index.ts
  • Unit tests: cancel before fire prevents callback, cancel unknown ID returns false, cancel already-fired returns false, getPendingReminders excludes cancelled

Context

  • Target files: src/invoiceReminderScheduler.ts, src/index.ts
  • Use fake timers in tests (vi.useFakeTimers) to control time without real delays

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions