No description
Find a file
padreug ff27f7ba01 Submits Castle payments to Fava
Refactors the payment processing logic to submit journal entries directly to
Fava/Beancount instead of storing them in the Castle database. It queries
Fava to prevent duplicate entries. The changes include extracting fiat
metadata from the invoice, formatting the data as a Beancount transaction
using a dedicated formatting function, and submitting it to the Fava API.
2025-11-10 01:06:51 +01:00
core FInal commit before stripping down to use FAVA 2025-11-09 21:12:19 +01:00
docs Refactors journal entry lines to use single amount 2025-11-08 11:48:08 +01:00
helper feat: Add equity account support to transaction filtering and Beancount import 2025-11-09 21:09:43 +01:00
static feat: Add equity account support to transaction filtering and Beancount import 2025-11-09 21:09:43 +01:00
templates/castle feat: Add equity account support to transaction filtering and Beancount import 2025-11-09 21:09:43 +01:00
.gitignore initial commit 2025-10-22 12:33:45 +02:00
__init__.py Initializes Fava client on startup 2025-11-10 01:06:51 +01:00
account_utils.py Removes parent-only accounts 2025-11-07 23:24:11 +01:00
beancount_format.py Adds Beancount formatting utilities 2025-11-10 01:06:45 +01:00
CLAUDE.md Refactors journal entry lines to use single amount 2025-11-08 11:48:08 +01:00
config.json initial commit 2025-10-22 12:33:45 +02:00
crud.py Add receivable/payable filtering with database-level query optimization 2025-11-09 00:28:54 +01:00
description.md initial commit 2025-10-22 12:33:45 +02:00
fava_client.py Adds async client for Fava REST API 2025-11-10 01:06:37 +01:00
manifest.json initial commit 2025-10-22 12:33:45 +02:00
migrations.py REFACTOR Migrates to single 'amount' field for transactions 2025-11-08 10:33:17 +01:00
models.py Adds Fava/Beancount integration settings 2025-11-10 01:06:30 +01:00
README.md initial commit 2025-10-22 12:33:45 +02:00
services.py Creates default user accounts on wallet setup 2025-11-08 23:41:17 +01:00
tasks.py Submits Castle payments to Fava 2025-11-10 01:06:51 +01:00
views.py Adds admin permissions management page 2025-11-07 18:05:30 +01:00
views_api.py feat: Add equity account support to transaction filtering and Beancount import 2025-11-09 21:09:43 +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!