From f0257e7c7fc9706d99c06079d1586cee68e79862 Mon Sep 17 00:00:00 2001 From: padreug Date: Thu, 23 Oct 2025 09:18:20 +0200 Subject: [PATCH] Improves receivable settlement and balance display. Enhances the receivable settlement dialog by providing a default description based on the selected payment method, improving clarity for users. Filters the user balance display to only show users with outstanding balances, making the interface cleaner and more focused for super users. --- static/js/index.js | 20 ++++++++++++++++++-- templates/castle/index.html | 16 +++++++++++----- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/static/js/index.js b/static/js/index.js index 2d76093..af998a4 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -203,6 +203,10 @@ window.app = Vue.createApp({ failedAssertions() { return this.balanceAssertions.filter(a => a.status === 'failed') }, + outstandingUserBalances() { + // Filter to only show users with non-zero balances + return this.allUserBalances.filter(user => user.balance !== 0) + }, passedAssertions() { return this.balanceAssertions.filter(a => a.status === 'passed') }, @@ -942,7 +946,7 @@ window.app = Vue.createApp({ fiatCurrency: fiatCurrency, // 'EUR', 'USD', etc. amount: fiatCurrency ? fiatAmount : Math.abs(userBalance.balance), // Default to fiat if available, otherwise sats payment_method: fiatCurrency ? 'cash' : 'lightning', // Default to cash if fiat balance exists - description: `Payment from ${userBalance.username}`, + description: '', // Will be auto-generated based on payment method if left empty reference: '', loading: false, invoice: null, @@ -1077,11 +1081,23 @@ window.app = Vue.createApp({ this.settleReceivableDialog.payment_method ) + // Create description with payment method + const paymentMethodLabels = { + 'cash': 'Cash payment', + 'bank_transfer': 'Bank transfer', + 'check': 'Check payment', + 'lightning': 'Lightning payment', + 'other': 'Payment' + } + const methodLabel = paymentMethodLabels[this.settleReceivableDialog.payment_method] || 'Payment' + const description = this.settleReceivableDialog.description || + `${methodLabel} from ${this.settleReceivableDialog.username}` + const payload = { user_id: this.settleReceivableDialog.user_id, amount: this.settleReceivableDialog.amount, payment_method: this.settleReceivableDialog.payment_method, - description: this.settleReceivableDialog.description, + description: description, reference: this.settleReceivableDialog.reference || null, } diff --git a/templates/castle/index.html b/templates/castle/index.html index a198d25..25bef59 100644 --- a/templates/castle/index.html +++ b/templates/castle/index.html @@ -154,12 +154,12 @@ - +
Outstanding Balances by User