-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Problem
Converting monetary amounts to JavaScript Number can cause silent precision loss, which is unsafe for financial operations.
Current Implementation
In src/app/(dashboard)/s/[id]/_components/subscription-plan-preview.tsx (line ~97):
const recurringPaymentBody = {
payee: subscriptionPlan.recipient,
amount: Number(subscriptionPlan.amount), // ⚠️ Unsafe conversion
invoiceCurrency: subscriptionPlan.paymentCurrency as PayoutCurrency,
// ...
};Suggested Solution
Send atomic units (string or bigint) end-to-end to avoid precision loss:
const recurringPaymentBody = {
payee: subscriptionPlan.recipient,
amountAtomic: amount.toString(), // Send as string
invoiceCurrency: subscriptionPlan.paymentCurrency as PayoutCurrency,
// ...
};Required Changes
- Update the
recurringPaymentBodyto useamountAtomic: string(or bigint) - Update
useCreateRecurringPaymenthook to accept atomic units - Update API types and backend handlers to accept and validate atomic unit strings
- Compute human-readable display values from atomic units when needed
Context
- Originated in: PR feat: rework the layout to be more in line with dashboard designs #164
- Comment thread: feat: rework the layout to be more in line with dashboard designs #164 (comment)
- Requester: @bassgeta
- Acknowledgment: Carried-over technical debt
Impact
Priority: High - affects financial calculations and could lead to incorrect payment amounts.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
🎫 Backlog