Adds super user balance overview
Implements functionality for super users to view a breakdown of outstanding balances for all users. This includes: - Adding an API endpoint to fetch all user balances. - Updating the frontend to display these balances in a table, accessible only to super users. - Modifying the balance calculation for the current user to reflect the total owed by or to the castle for super users. This provides super users with a comprehensive view of the castle's financial position.
This commit is contained in:
parent
cb7e4ee555
commit
b7e4e05469
4 changed files with 117 additions and 4 deletions
|
|
@ -76,14 +76,17 @@
|
|||
</div>
|
||||
</div>
|
||||
<div v-if="balance !== null">
|
||||
<div class="text-h4" :class="balance.balance >= 0 ? 'text-positive' : 'text-negative'">
|
||||
<div class="text-h4" :class="balance.balance >= 0 ? 'text-negative' : 'text-positive'">
|
||||
{% raw %}{{ formatSats(Math.abs(balance.balance)) }} sats{% endraw %}
|
||||
</div>
|
||||
<div class="text-subtitle2">
|
||||
<div class="text-subtitle2" v-if="isSuperUser">
|
||||
{% raw %}{{ balance.balance > 0 ? 'Total you owe' : balance.balance < 0 ? 'Total owed to you' : 'No outstanding balances' }}{% endraw %}
|
||||
</div>
|
||||
<div class="text-subtitle2" v-else>
|
||||
{% raw %}{{ balance.balance >= 0 ? 'Castle owes you' : 'You owe Castle' }}{% endraw %}
|
||||
</div>
|
||||
<q-btn
|
||||
v-if="balance.balance < 0"
|
||||
v-if="balance.balance < 0 && !isSuperUser"
|
||||
color="primary"
|
||||
class="q-mt-md"
|
||||
@click="showPayBalanceDialog"
|
||||
|
|
@ -98,6 +101,40 @@
|
|||
</q-card-section>
|
||||
</q-card>
|
||||
|
||||
<!-- User Balances Breakdown (Super User Only) -->
|
||||
<q-card v-if="isSuperUser && allUserBalances.length > 0">
|
||||
<q-card-section>
|
||||
<h6 class="q-my-none q-mb-md">Outstanding Balances by User</h6>
|
||||
<q-table
|
||||
flat
|
||||
:rows="allUserBalances"
|
||||
:columns="[
|
||||
{name: 'user', label: 'User ID', field: 'user_id', align: 'left'},
|
||||
{name: 'balance', label: 'Amount Owed', field: 'balance', align: 'right'}
|
||||
]"
|
||||
row-key="user_id"
|
||||
hide-pagination
|
||||
:rows-per-page-options="[0]"
|
||||
>
|
||||
<template v-slot:body-cell-user="props">
|
||||
<q-td :props="props">
|
||||
<div class="text-caption">{% raw %}{{ props.row.user_id.substring(0, 16) }}...{% endraw %}</div>
|
||||
</q-td>
|
||||
</template>
|
||||
<template v-slot:body-cell-balance="props">
|
||||
<q-td :props="props">
|
||||
<div :class="props.row.balance > 0 ? 'text-negative' : 'text-positive'">
|
||||
{% raw %}{{ formatSats(Math.abs(props.row.balance)) }} sats{% endraw %}
|
||||
</div>
|
||||
<div class="text-caption text-grey">
|
||||
{% raw %}{{ props.row.balance > 0 ? 'You owe' : 'Owes you' }}{% endraw %}
|
||||
</div>
|
||||
</q-td>
|
||||
</template>
|
||||
</q-table>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
||||
<!-- Quick Actions -->
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue