Commit graph

6 commits

Author SHA1 Message Date
4a3922895e Integrate account sync with API, background tasks, and user creation
Integration Components:
1. Manual API Endpoints (admin-only):
   - POST /api/v1/admin/accounts/sync (full sync)
   - POST /api/v1/admin/accounts/sync/{account_name} (single account)

2. Scheduled Background Sync:
   - Hourly background task (wait_for_account_sync)
   - Registered in castle_start() lifecycle
   - Automatically syncs new accounts from Beancount to Castle DB

3. Auto-sync on User Account Creation:
   - Updated get_or_create_user_account() in crud.py
   - Uses sync_single_account_from_beancount() for consistency
   - Ensures receivable/payable accounts are synced when users register

Flow:
- User associates wallet → creates receivable/payable in Beancount
  → syncs to Castle DB → permissions can be granted
- Admin manually syncs → all Beancount accounts added to Castle DB
- Hourly task → catches any accounts created directly in Beancount

This ensures Beancount remains the source of truth while Castle DB
maintains metadata for permissions and user associations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-11 01:28:59 +01:00
750692a2f0 Initializes Fava client on startup
Initializes the Fava client with default settings when the Castle extension starts.

This ensures the client is ready to interact with Fava immediately and provides feedback if Fava is not configured correctly.

The client is re-initialized if the admin updates settings later.
2025-11-10 01:06:51 +01:00
8f35788e1a Adds task cleanup on extension shutdown
Implements a mechanism to cancel pending background tasks
when the extension is stopped. This ensures proper cleanup and
prevents potential issues with lingering tasks.
2025-11-02 01:41:34 +01:00
cfa25cc61b Adds background task for invoice processing
Implements a background task that listens for paid invoices
and automatically records them in the accounting system. This
ensures payments are captured even if the user closes their
browser before the client-side polling detects the payment.

Introduces a new `get_journal_entry_by_reference` function to
improve idempotency when recording payments.
2025-11-02 01:40:40 +01:00
5589d813f0 Simplifies database queries and updates auth
Removes the `castle.` prefix from database table names in queries, streamlining data access.

Updates authentication to use `WalletTypeInfo` dependency injection for retrieving wallet information. This improves security and aligns with LNBits' authentication patterns. Also modifies the main router's tag to uppercase.
2025-10-22 12:52:52 +02:00
95b8af2360 initial commit 2025-10-22 12:33:45 +02:00