feat: Add equity account support to transaction filtering and Beancount import
Improvements to equity account handling across the Castle extension: Transaction Categorization (views_api.py): - Prioritize equity accounts when enriching transaction entries - Use two-pass lookup: first search for equity accounts, then fall back to liability/asset accounts - Ensures transactions with Equity:User-<id> accounts are correctly categorized as equity UI Enhancements (index.html, index.js): - Add 'Equity' filter option to Recent Transactions table - Display blue "Equity" badge for equity entries (before receivable/payable badges) - Add isEquity() helper function to identify equity account entries Beancount Import (import_beancount.py): - Support importing Beancount Equity:<name> accounts - Map Beancount "Equity:Pat" to Castle "Equity:User-<id>" accounts - Update extract_user_from_user_account() to handle Equity: prefix - Improve error messages to include equity account examples - Add equity account lookup in get_account_id() with helpful error if equity not enabled These changes ensure equity accounts (representing user capital contributions) are properly distinguished from payables and receivables throughout the system.
This commit is contained in:
parent
6f1fa7203b
commit
0b64ffa54f
4 changed files with 74 additions and 11 deletions
|
|
@ -202,7 +202,8 @@ window.app = Vue.createApp({
|
|||
return [
|
||||
{ label: 'All Types', value: null },
|
||||
{ label: 'Receivable (User owes Castle)', value: 'asset' },
|
||||
{ label: 'Payable (Castle owes User)', value: 'liability' }
|
||||
{ label: 'Payable (Castle owes User)', value: 'liability' },
|
||||
{ label: 'Equity (User Balance)', value: 'equity' }
|
||||
]
|
||||
},
|
||||
expenseAccounts() {
|
||||
|
|
@ -1551,6 +1552,19 @@ window.app = Vue.createApp({
|
|||
}
|
||||
}
|
||||
return false
|
||||
},
|
||||
isEquity(entry) {
|
||||
// Check if this is an equity entry (user capital contribution/balance)
|
||||
if (!entry.lines || entry.lines.length === 0) return false
|
||||
|
||||
for (const line of entry.lines) {
|
||||
// Check if the account is an equity account
|
||||
const account = this.accounts.find(a => a.id === line.account_id)
|
||||
if (account && account.account_type === 'equity') {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue