Repository navigation
Fix: 2 issues (#878, #879) - #946
Open
GenesisPray wants to merge 1 commit into
Open
GenesisPray wants to merge 1 commit into
GenesisPray wants to merge 1 commit into
Conversation
Co-authored-by: Simple Agent <agent@simple.dev>
|
@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. |
|
@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! 🚀 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #878
Closes #879
Issues
#878 Implement payment export and reconciliation
#879 Add payment reminders and escalation system
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
src/lib/paymentExport.tsthat accepts a filter object{ startDate?: string; endDate?: string; statuses?: string[] }and serializes payment/invoice data to CSV, JSON, and PDF. ReusepaymentsToCSV/filterPaymentsByDateRangefromsrc/lib/csvExport.tsandbuildPaymentSummaryHtml/downloadPaymentSummaryPDFfromsrc/lib/paymentExportPdf.ts. Export aPaymentExportFormattype ('csv' | 'json' | 'pdf'), afilterPaymentshelper applying date-range and invoice-status filters, andexportPayments(payments, format, filters)that triggers the appropriate download. Also add agenerateReconciliationReport(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)src/lib/apiClient.ts:createAccountingExport(payload)(POST to/api/accounting/exports),listAccountingExports()(GET),getAccountingExport(id), andpushReconciliationReport(report)(POST to/api/accounting/reconciliations). Use the existingapiFetchwrapper 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)src/lib/exportHistory.tsthat persists export records (id, timestamp, format, filters used, record count, status) to localStorage under a stable key, withaddExportHistoryEntry,getExportHistory, andclearExportHistoryhelpers. This satisfies the export history tracking requirement for issue Implement payment export and reconciliation #878. (src/lib/exportHistory.ts)src/components/ExportModal.tsxto use the new unifiedpaymentExportmodule: add a format selector (CSV/JSON/PDF), keep the existing date-range and status filters, callexportPaymentswith the chosen format, record each export viaaddExportHistoryEntry, and render a recent export history list fromgetExportHistory. Surface errors from the export pipeline in the existing error state. (src/components/ExportModal.tsx)src/components/PaymentExport.tsxto add JSON as a third export format alongside CSV and PDF, delegating serialization to the newsrc/lib/paymentExport.tsmodule instead of callingpaymentsToCSV/buildPaymentSummaryHtmldirectly. Keep the existing column selection and date-range filter UI, and record each export in export history. (src/components/PaymentExport.tsx)src/lib/reminders.tswith the reminder scheduling and escalation engine: define escalation levels (e.g. gentle/urgent/final) keyed on invoice age relative to due date, acomputeReminderSchedule(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 (viapaymentReceiptEmailer), push (viapushNotifications), and in-app (vianotifications), and engagement event recording (recordReminderEventfor sent/opened/clicked/paid) with agetReminderMetricsaggregator. Keep existinggetReminders/setReminder/checkAndFireRemindersAPIs working. Add unit tests for scheduling, escalation thresholds, opt-out safety, channel selection, and metrics. (src/lib/reminders.ts)src/components/ReminderSender.tsxto use the new reminder engine: replace the localbuildReminderTextandscheduleReminderhelpers withcomputeReminderScheduleand the template renderer fromsrc/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)src/components/ReminderChecker.tsxto use the new reminder engine: filter due reminders throughisReminderSuppressedso opted-out invoices never fire, dispatch via the multi-channeldispatchReminderhelper (browser notification plus in-app), and callrecordReminderEventwith 'sent'/'opened' events so engagement metrics are tracked. (src/components/ReminderChecker.tsx)src/lib/notifications.ts: an in-app channel functionsendInAppReminder(invoiceId, message, level)that respects the existing notification preferences, and agetReminderChannelPreferences/setReminderChannelPreferencespair 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)