Fix balance sign interpretation on Castle balance page
Castle API returns positive = user owes castle, negative = castle owes user. The display was inverted, showing "you owe" after submitting an expense when it should show "owed to you". Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b0729ea23d
commit
bac9fd091e
1 changed files with 6 additions and 5 deletions
|
|
@ -42,7 +42,8 @@ const pendingFiatCurrency = computed(() => {
|
|||
return tx?.fiat_currency ?? null
|
||||
})
|
||||
|
||||
const balanceIsPositive = computed(() => (balance.value ?? 0) >= 0)
|
||||
// Castle API: positive = user owes castle, negative = castle owes user
|
||||
const castleOwesUser = computed(() => (balance.value ?? 0) <= 0)
|
||||
|
||||
async function loadData() {
|
||||
if (!walletKey.value) return
|
||||
|
|
@ -120,17 +121,17 @@ function formatFiat(amount: number, currency: string): string {
|
|||
<div v-if="balance !== null" class="space-y-1">
|
||||
<div class="flex items-center gap-2">
|
||||
<component
|
||||
:is="balanceIsPositive ? ArrowDown : ArrowUp"
|
||||
:is="castleOwesUser ? ArrowDown : ArrowUp"
|
||||
class="w-5 h-5"
|
||||
:class="balanceIsPositive ? 'text-green-500' : 'text-red-500'"
|
||||
:class="castleOwesUser ? 'text-green-500' : 'text-red-500'"
|
||||
/>
|
||||
<span class="text-3xl font-bold text-foreground">
|
||||
{{ formatAmount(balance) }}
|
||||
</span>
|
||||
<span class="text-lg text-muted-foreground">{{ balanceCurrency }}</span>
|
||||
</div>
|
||||
<p class="text-sm" :class="balanceIsPositive ? 'text-green-600 dark:text-green-400' : 'text-red-600 dark:text-red-400'">
|
||||
{{ balanceIsPositive ? t('castle.balance.owedToYou') : t('castle.balance.youOwe') }}
|
||||
<p class="text-sm" :class="castleOwesUser ? 'text-green-600 dark:text-green-400' : 'text-red-600 dark:text-red-400'">
|
||||
{{ castleOwesUser ? t('castle.balance.owedToYou') : t('castle.balance.youOwe') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue