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:
parent
116355b502
commit
55df2b36e0
1 changed files with 8 additions and 4 deletions
|
|
@ -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'
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue