From 8fb5c58f9a61308ce4360a15d0ec857da27a7e43 Mon Sep 17 00:00:00 2001 From: jwinterm Date: Tue, 13 Jan 2026 19:13:11 -0500 Subject: [PATCH] Fix: History payments --- html/index.html | 6 +++--- html/js/ui/transactionHistory.js | 4 ++-- src/index.js | 8 +++++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/html/index.html b/html/index.html index 793da9a..443cbea 100644 --- a/html/index.html +++ b/html/index.html @@ -153,12 +153,12 @@
-
Total Received
+
Total Rewards
0 WOW
-
Total Payments
-
0
+
Total Paid
+
0 WOW
diff --git a/html/js/ui/transactionHistory.js b/html/js/ui/transactionHistory.js index 9b5fa68..78e8918 100644 --- a/html/js/ui/transactionHistory.js +++ b/html/js/ui/transactionHistory.js @@ -107,10 +107,10 @@ const TransactionHistory = { const currency = payouts.currency || payments.currency || 'WOW'; const totalReceived = payouts.totalReceivedFormatted || '0'; - const totalPayments = payments.total || 0; + const totalPaid = payments.totalPaidFormatted || '0'; $('#total-received').text(totalReceived + ' ' + currency); - $('#total-payments').text(totalPayments); + $('#total-payments').text(totalPaid + ' ' + currency); }, _renderPayouts: function() { diff --git a/src/index.js b/src/index.js index 448161a..c80dd2e 100644 --- a/src/index.js +++ b/src/index.js @@ -308,10 +308,14 @@ app.get('/api/user/:socketId/payments', asyncHandler(async (req, res) => { `, [user.id, limit, offset]); const countResult = await db.query( - `SELECT COUNT(*) as total FROM payments WHERE user_id = $1`, + `SELECT COUNT(*) as total, + COALESCE(SUM(CASE WHEN status = 'confirmed' THEN expected_amount ELSE 0 END), 0) as total_paid + FROM payments WHERE user_id = $1`, [user.id] ); + const totalPaid = parseInt(countResult.rows[0].total_paid, 10) || 0; + res.json({ payments: result.rows.map(row => ({ id: row.id, @@ -325,6 +329,8 @@ app.get('/api/user/:socketId/payments', asyncHandler(async (req, res) => { description: row.description })), total: parseInt(countResult.rows[0].total, 10), + totalPaid: totalPaid, + totalPaidFormatted: gameModeManager.formatAtomicHuman(totalPaid, 4), limit, offset, currency: gameModeManager.cryptoType