From 900ddb553b1e6e36066ddc6e29ce8e15822f5afa Mon Sep 17 00:00:00 2001 From: padreug Date: Wed, 22 Oct 2025 18:46:41 +0200 Subject: [PATCH] Adds payable/receivable badges to entries Improves clarity by displaying "Payable" or "Receivable" badges on entries in the transaction list. The badge color depends on whether the user is a superuser, indicating the direction of the transaction from the user's perspective. This helps users quickly understand which transactions are owed to them and which they owe. --- static/js/index.js | 17 +++++++++++++++++ templates/castle/index.html | 17 ++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/static/js/index.js b/static/js/index.js index cee8e08..3735438 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -646,6 +646,23 @@ window.app = Vue.createApp({ } } return false + }, + isPayable(entry) { + // Check if this is a payable entry (castle owes user) + // Payables have a credit to an "Accounts Payable" account with the user's ID + if (!entry.lines || entry.lines.length === 0) return false + + for (const line of entry.lines) { + // Look for a line with positive credit on an accounts payable account + if (line.credit > 0) { + // Check if the account is associated with this user's payables + const account = this.accounts.find(a => a.id === line.account_id) + if (account && account.name && account.name.includes('Accounts Payable') && account.account_type === 'liability') { + return true + } + } + } + return false } }, async created() { diff --git a/templates/castle/index.html b/templates/castle/index.html index 771cb06..68ef696 100644 --- a/templates/castle/index.html +++ b/templates/castle/index.html @@ -76,7 +76,7 @@
-
+
{% raw %}{{ formatSats(Math.abs(balance.balance)) }} sats{% endraw %}
@@ -254,8 +254,19 @@ {% raw %}{{ entry.description }}{% endraw %} - - Pending Payment + + + Receivable + + + Payable + + + + Payable + + + Receivable