Fix Pay User dialog showing negative values

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 <noreply@anthropic.com>
This commit is contained in:
padreug 2025-12-15 00:54:51 +01:00
parent 116355b502
commit 55df2b36e0

View file

@ -1338,20 +1338,24 @@ window.app = Vue.createApp({
const fiatCurrency = Object.keys(fiatBalances)[0] || null const fiatCurrency = Object.keys(fiatBalances)[0] || null
const fiatAmount = fiatCurrency ? fiatBalances[fiatCurrency] : 0 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 = { this.payUserDialog = {
show: true, show: true,
user_id: userBalance.user_id, user_id: userBalance.user_id,
username: userBalance.username, username: userBalance.username,
maxAmount: userBalance.balance, // Positive sats amount castle owes maxAmount: maxAmountSats, // Positive sats amount castle owes
maxAmountFiat: fiatAmount, // EUR or other fiat amount maxAmountFiat: maxAmountFiat, // EUR or other fiat amount (positive)
fiatCurrency: fiatCurrency, 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 payment_method: 'lightning', // Default to lightning for paying
description: '', description: '',
reference: '', reference: '',
loading: false, loading: false,
paymentSuccess: false, paymentSuccess: false,
exchangeRate: fiatAmount > 0 ? userBalance.balance / fiatAmount : this.currentExchangeRate, exchangeRate: maxAmountFiat > 0 ? maxAmountSats / maxAmountFiat : this.currentExchangeRate,
originalCurrency: fiatCurrency || 'BTC' originalCurrency: fiatCurrency || 'BTC'
} }
}, },