feat: commission tracking based on wallet balances with payment history

- Commission = 5% of total wallet balances (not sales)
- Track commission payments in commission_payments table (migration 007)
- Show 'Due Now' = current commission - last payment amount
- Record payment form with amount and optional note
- Payment history table with date, balances, commission, paid, delta
- Delta shows difference between consecutive payments (new users = more owed)
- Seed phrase unlock reminder shows the commission due amount
- Stat warning highlight when commission is due
This commit is contained in:
NW
2026-06-23 13:01:15 +01:00
parent 76daf07bb4
commit a6d81cfe83
5 changed files with 184 additions and 64 deletions

View File

@@ -0,0 +1,17 @@
import logger from '../utils/logger.js';
export default async function migration007(db) {
await db.runAsync(`
CREATE TABLE IF NOT EXISTS commission_payments (
id INTEGER PRIMARY KEY AUTOINCREMENT,
total_balance_usd REAL NOT NULL,
commission_rate REAL NOT NULL,
commission_amount_usd REAL NOT NULL,
paid_amount_usd REAL NOT NULL,
wallet_count INTEGER NOT NULL,
note TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
`);
logger.info('Migration 007: commission_payments table created');
}

View File

@@ -41,6 +41,7 @@ export async function runMigrations() {
(await import('./004_user_states.js')).default,
(await import('./005_audit_log.js')).default,
(await import('./006_subcategories.js')).default,
(await import('./007_commission_payments.js')).default,
];
for (let i = currentVersion; i < migrations.length; i++) {