Skip to content

Fix: 2 issues (#878, #879) - #946

Open
GenesisPray wants to merge 1 commit into
Stellar-split:mainfrom
GenesisPray:simple/878-879
Open

GenesisPray wants to merge 1 commit into
Stellar-split:mainfrom
GenesisPray:simple/878-879

Conversation

@GenesisPray

Copy link
Copy Markdown
Contributor

Closes #878
Closes #879

Issues

#878 Implement payment export and reconciliation

Overview

Export payment data in multiple formats for accounting integration and reconciliation.

Requirements

  • Add export format support (CSV, JSON, PDF)
  • Implement date range filtering
  • Add invoice status filtering
  • Create reconciliation report generation
  • Implement accounting integration APIs
  • Add export history tracking

Acceptance Criteria

[ ] Exports available in multiple formats
[ ] Filtered exports work correctly
[ ] Reconciliation reports accurate
[ ] Accounting integrations functional
[ ] Export history tracked

Definition of Done

All CI checks must pass before the PR is reviewed.

#879 Add payment reminders and escalation system

Overview

Automatically send payment reminders with escalating urgency based on invoice age.

Requirements

  • Design reminder schedule logic
  • Implement template-based reminder messages
  • Add escalation level system
  • Create suppression/opt-out mechanism
  • Implement reminder delivery channels
  • Track reminder engagement metrics

Acceptance Criteria

[ ] Reminders sent on schedule
[ ] Escalation increases with invoice age
[ ] Recipients can opt-out safely
[ ] Multiple delivery channels supported
[ ] Engagement metrics tracked

Definition of Done

All CI checks must pass before the PR is reviewed.

Summary

Issue #878: keep the existing ExportModal server-side export path working; the new unified module should be additive and reuse csvExport/paymentExportPdf rather than duplicating logic. Reconciliation matching should be tolerant of payments lacking an invoice id by grouping on txHash/payer. Issue #879: escalation thresholds should be configurable constants (e.g. 0/7/14/30 days past due) so tests can pin them. Suppression must be checked before any channel dispatch to guarantee opt-out safety. All new modules need unit tests and must pass lint, typecheck, and build before the PR is reviewed.

Changes

  • Create a unified payment export module src/lib/paymentExport.ts that accepts a filter object { startDate?: string; endDate?: string; statuses?: string[] } and serializes payment/invoice data to CSV, JSON, and PDF. Reuse paymentsToCSV/filterPaymentsByDateRange from src/lib/csvExport.ts and buildPaymentSummaryHtml/downloadPaymentSummaryPDF from src/lib/paymentExportPdf.ts. Export a PaymentExportFormat type ('csv' | 'json' | 'pdf'), a filterPayments helper applying date-range and invoice-status filters, and exportPayments(payments, format, filters) that triggers the appropriate download. Also add a generateReconciliationReport(payments, invoices) function that matches payments to invoices by invoice id, computes expected vs received totals per invoice, and returns a summary with totals and discrepancies. Add unit tests covering filters, each format, and reconciliation accuracy. (src/lib/paymentExport.ts)
  • Add accounting integration API client functions to src/lib/apiClient.ts: createAccountingExport(payload) (POST to /api/accounting/exports), listAccountingExports() (GET), getAccountingExport(id), and pushReconciliationReport(report) (POST to /api/accounting/reconciliations). Use the existing apiFetch wrapper so CSRF tokens are attached to mutating calls. These functions back the accounting integration APIs required by issue Implement payment export and reconciliation #878. (src/lib/apiClient.ts)
  • Create an export history store src/lib/exportHistory.ts that persists export records (id, timestamp, format, filters used, record count, status) to localStorage under a stable key, with addExportHistoryEntry, getExportHistory, and clearExportHistory helpers. This satisfies the export history tracking requirement for issue Implement payment export and reconciliation #878. (src/lib/exportHistory.ts)
  • Update src/components/ExportModal.tsx to use the new unified paymentExport module: add a format selector (CSV/JSON/PDF), keep the existing date-range and status filters, call exportPayments with the chosen format, record each export via addExportHistoryEntry, and render a recent export history list from getExportHistory. Surface errors from the export pipeline in the existing error state. (src/components/ExportModal.tsx)
  • Update src/components/PaymentExport.tsx to add JSON as a third export format alongside CSV and PDF, delegating serialization to the new src/lib/paymentExport.ts module instead of calling paymentsToCSV/buildPaymentSummaryHtml directly. Keep the existing column selection and date-range filter UI, and record each export in export history. (src/components/PaymentExport.tsx)
  • Extend src/lib/reminders.ts with the reminder scheduling and escalation engine: define escalation levels (e.g. gentle/urgent/final) keyed on invoice age relative to due date, a computeReminderSchedule(invoice) function returning the next reminder date and escalation level, template-based message rendering per level, a suppression/opt-out store (isReminderSuppressed, suppressReminder, unsuppressReminder) persisted in localStorage, a channel dispatch function that routes to email (via paymentReceiptEmailer), push (via pushNotifications), and in-app (via notifications), and engagement event recording (recordReminderEvent for sent/opened/clicked/paid) with a getReminderMetrics aggregator. Keep existing getReminders/setReminder/checkAndFireReminders APIs working. Add unit tests for scheduling, escalation thresholds, opt-out safety, channel selection, and metrics. (src/lib/reminders.ts)
  • Update src/components/ReminderSender.tsx to use the new reminder engine: replace the local buildReminderText and scheduleReminder helpers with computeReminderSchedule and the template renderer from src/lib/reminders.ts, show the current escalation level and next scheduled reminder, respect the suppression/opt-out store (hide send controls when suppressed and offer an opt-out toggle), and record a 'sent' engagement event when a reminder is dispatched. (src/components/ReminderSender.tsx)
  • Update src/components/ReminderChecker.tsx to use the new reminder engine: filter due reminders through isReminderSuppressed so opted-out invoices never fire, dispatch via the multi-channel dispatchReminder helper (browser notification plus in-app), and call recordReminderEvent with 'sent'/'opened' events so engagement metrics are tracked. (src/components/ReminderChecker.tsx)
  • Add reminder delivery channel helpers to src/lib/notifications.ts: an in-app channel function sendInAppReminder(invoiceId, message, level) that respects the existing notification preferences, and a getReminderChannelPreferences/setReminderChannelPreferences pair so users can enable/disable email, push, and in-app reminder channels. This supports the multiple delivery channels requirement for issue Add payment reminders and escalation system #879. (src/lib/notifications.ts)

Co-authored-by: Simple Agent <agent@simple.dev>
@vercel

vercel Bot commented Oct 17, 2026

Copy link
Copy Markdown

@GenesisPray is attempting to deploy a commit to the kingsman-99's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@GenesisPray Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

This branch has not been deployed

No deployments
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.

Add payment reminders and escalation system Implement payment export and reconciliation

1 participant