Skip to content

Commit 778ccdc

Browse files
committed
fix: correct balance calculation in statsRoutes to reflect accurate credit/debit logic
1 parent cd24d05 commit 778ccdc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cloudflare-worker/src/routes/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,8 +2044,8 @@ const statsRoutes = (router: Router, env: Env) => {
20442044
// Calculate total refunded amount
20452045
const refundedAmount = userRefunds.reduce((total, refund) => total + refund.amount, 0);
20462046

2047-
// Calculate the balance (difference)
2048-
const balance = purchasedAmount - refundedAmount;
2047+
// Calculate the balance (difference) credit/debit credit means that the user has refunded more than they purchased
2048+
const balance = refundedAmount - purchasedAmount ;
20492049

20502050
return new Response(
20512051
JSON.stringify({

0 commit comments

Comments
 (0)