No description
Find a file
padreug 5d38dc188b Fix loading state hang when user has no permissions
Fixed UI hanging indefinitely on "Loading..." when users have no
account permissions or when API calls fail.

Problem: When API calls failed (due to no permissions, timeout, or
other errors), the error handlers would show error notifications but
wouldn't clear the loading state. This left data properties as null
or undefined, causing v-if/v-else templates to show spinners forever.

Solution: Set default/empty values in error handlers to clear loading
states and allow UI to render properly:

- loadBalance(): Set balance to {balance: 0, fiat_balances: {}, accounts: []}
- loadTransactions(): Set transactions to [] and pagination.total to 0
- loadAccounts(): Set accounts to []

Now when API calls fail, users see:
- Error notification (existing behavior)
- Empty state UI instead of infinite spinner (new behavior)
- "No transactions yet" / "0 sats" instead of "Loading..."

Affected files:
- static/js/index.js (lines 326-331, 391-393, 434-435)

Co-Authored-By: Claude <noreply@anthropic.com>

Fix Chart of Accounts loading spinner stuck issue

Fixed the Chart of Accounts section showing "Loading accounts..."
indefinitely when user has no account permissions.

Problem: The previous commit set accounts = [] in error handler to
clear loading state. However, the template logic was:
- v-if="accounts.length > 0" → show accounts list
- v-else → show loading spinner

When accounts = [] (empty array), it triggered v-else and showed
the spinner forever.

Solution: Changed the v-else block from loading spinner to empty
state message "No accounts available" with grey text styling.

Now when loadAccounts() fails or returns empty:
- Shows "No accounts available" instead of infinite spinner
- Consistent with other empty states (transactions, balances)
- User sees informative message instead of fake loading state

Affected: templates/castle/index.html (line 792-794)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-11 23:03:05 +01:00
core Removes core balance calculation logic 2025-11-10 01:06:51 +01:00
docs Add UI improvements plan for bulk permission features 2025-11-11 00:05:57 +01:00
helper HELPER FILE TO DELETE/REVISE 2025-11-10 21:44:43 +01:00
static Fix loading state hang when user has no permissions 2025-11-11 23:03:05 +01:00
templates/castle Fix loading state hang when user has no permissions 2025-11-11 23:03:05 +01:00
.gitignore initial commit 2025-10-22 12:33:45 +02:00
__init__.py Integrate account sync with API, background tasks, and user creation 2025-11-11 01:28:59 +01:00
account_sync.py Fix virtual parent detection by refreshing account list 2025-11-11 02:53:41 +01:00
account_utils.py Update default expense accounts to optimized structure 2025-11-11 03:09:44 +01:00
beancount_format.py Implement hybrid approach for balance assertions 2025-11-10 20:46:12 +01:00
CLAUDE.md update CLAUDE.md 2025-11-10 19:32:00 +01:00
config.json initial commit 2025-10-22 12:33:45 +02:00
crud.py Fix UNIQUE constraint error in get_or_create_user_account 2025-11-11 19:47:17 +01:00
description.md initial commit 2025-10-22 12:33:45 +02:00
fava_client.py Optimize recent transactions with 30-day date filter 2025-11-11 22:39:22 +01:00
manifest.json initial commit 2025-10-22 12:33:45 +02:00
MIGRATION_SQUASH_SUMMARY.md Squash 16 migrations into single clean initial migration 2025-11-10 21:51:11 +01:00
migrations.py FIX: add fava extension settings with default values 2025-11-11 19:04:55 +01:00
migrations_old.py.bak Squash 16 migrations into single clean initial migration 2025-11-10 21:51:11 +01:00
models.py Add virtual parent accounts for permission inheritance 2025-11-11 02:41:05 +01:00
permission_management.py Add account sync and bulk permission management 2025-11-10 23:55:26 +01:00
README.md initial commit 2025-10-22 12:33:45 +02:00
services.py Fixes user account creation in Fava/Beancount 2025-11-10 21:22:02 +01:00
tasks.py Integrate account sync with API, background tasks, and user creation 2025-11-11 01:28:59 +01:00
views.py Adds admin permissions management page 2025-11-07 18:05:30 +01:00
views_api.py Add user-selectable date range filters for Recent Transactions 2025-11-11 22:54:14 +01:00

Castle Accounting Extension for LNbits

A full-featured double-entry accounting system for collective projects, integrated with LNbits Lightning payments.

Overview

Castle Accounting enables collectives like co-living spaces, makerspaces, and community projects to:

  • Track expenses and revenue with proper accounting
  • Manage individual member balances
  • Record contributions as equity or reimbursable expenses
  • Track accounts receivable (what members owe)
  • Generate Lightning invoices for settlements

Installation

This extension is designed to be installed in the lnbits/extensions/ directory.

cd lnbits/extensions/
# Copy or clone the castle directory here

Enable the extension through the LNbits admin interface or by adding it to your configuration.

Usage

For Members

  1. Add an Expense: Record money you spent on behalf of the collective

    • Choose "Liability" if you want reimbursement
    • Choose "Equity" if it's a contribution
  2. View Your Balance: See if the Castle owes you money or vice versa

  3. Pay Outstanding Balance: Generate a Lightning invoice to settle what you owe

For Admins

  1. Create Accounts Receivable: Record when someone owes the collective money

  2. Record Revenue: Track income received by the collective

  3. View All Transactions: See complete accounting history

  4. Make Payments: Record payments to members

Architecture

Data Models

  • Account: Individual accounts in the chart of accounts
  • JournalEntry: Transaction header with description and date
  • EntryLine: Individual debit/credit lines (always balanced)

Account Types

  • Assets: Things the Castle owns (Cash, Bank, Accounts Receivable)
  • Liabilities: What the Castle owes (Accounts Payable to members)
  • Equity: Member contributions and retained earnings
  • Revenue: Income streams
  • Expenses: Operating costs

Database Schema

The extension creates three tables:

  • castle.accounts - Chart of accounts
  • castle.journal_entries - Transaction headers
  • castle.entry_lines - Debit/credit lines

API Reference

See description.md for full API documentation.

Development

To modify this extension:

  1. Edit models in models.py
  2. Add database migrations in migrations.py
  3. Implement business logic in crud.py
  4. Create API endpoints in views_api.py
  5. Update UI in templates/castle/index.html

Contributing

Contributions welcome! Please ensure:

  • Journal entries always balance
  • User permissions are properly checked
  • Database transactions are atomic

License

MIT License - feel free to use and modify for your collective!