From 55df2b36e0001ee0b0705c244fd740d66a88fef0 Mon Sep 17 00:00:00 2001 From: padreug Date: Mon, 15 Dec 2025 00:54:51 +0100 Subject: [PATCH] Fix Pay User dialog showing negative values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use Math.abs() to display liability amounts as positive values in the Pay User dialog. Liabilities are stored as negative (castle owes user) but should display as positive when framed as "Amount Castle Owes". 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- static/js/index.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/static/js/index.js b/static/js/index.js index 318483b..a0b38ba 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -1338,20 +1338,24 @@ window.app = Vue.createApp({ const fiatCurrency = Object.keys(fiatBalances)[0] || null const fiatAmount = fiatCurrency ? fiatBalances[fiatCurrency] : 0 + // Use absolute values since balance is negative (liability = castle owes user) + const maxAmountSats = Math.abs(userBalance.balance) + const maxAmountFiat = Math.abs(fiatAmount) + this.payUserDialog = { show: true, user_id: userBalance.user_id, username: userBalance.username, - maxAmount: userBalance.balance, // Positive sats amount castle owes - maxAmountFiat: fiatAmount, // EUR or other fiat amount + maxAmount: maxAmountSats, // Positive sats amount castle owes + maxAmountFiat: maxAmountFiat, // EUR or other fiat amount (positive) fiatCurrency: fiatCurrency, - amount: fiatCurrency ? fiatAmount : userBalance.balance, // Default to fiat if available + amount: fiatCurrency ? maxAmountFiat : maxAmountSats, // Default to fiat if available payment_method: 'lightning', // Default to lightning for paying description: '', reference: '', loading: false, paymentSuccess: false, - exchangeRate: fiatAmount > 0 ? userBalance.balance / fiatAmount : this.currentExchangeRate, + exchangeRate: maxAmountFiat > 0 ? maxAmountSats / maxAmountFiat : this.currentExchangeRate, originalCurrency: fiatCurrency || 'BTC' } },