Add POST /api/v1/admin/accounts for chart-of-accounts entries
Companion to the fava ledger split (aiolabs/server-deploy#4). Super-user endpoint that adds a new Open directive to accounts/chart.beancount via fava_client.add_account (explicit target_file), then mirrors the account into Libra's DB via sync_single_account_from_beancount so permissions can be granted on it. Validates the account name against the five Beancount top-level prefixes (Assets:/Liabilities:/Equity:/Income:/Expenses:) and returns 400 on a bad prefix. Per-user accounts (matching :User-xxxxxxxx) keep their existing code path via crud.get_or_create_user_account, which inherits the inferred target_file (accounts/users.beancount) from the add_account default. Backend only -- the LNbits admin UI on top is tracked separately as aiolabs/libra#30. Refs: aiolabs/libra#29
This commit is contained in:
parent
894de72953
commit
34ecb3f249
2 changed files with 63 additions and 0 deletions
|
|
@ -48,6 +48,13 @@ class CreateAccount(BaseModel):
|
|||
is_virtual: bool = False # Set to True to create virtual parent account
|
||||
|
||||
|
||||
class CreateChartAccount(BaseModel):
|
||||
"""Admin-created chart-of-accounts entry written to accounts/chart.beancount."""
|
||||
name: str # Full hierarchical account name, e.g. "Expenses:Services:Domain"
|
||||
currencies: list[str] = ["EUR", "SATS", "USD"]
|
||||
description: Optional[str] = None
|
||||
|
||||
|
||||
class EntryLine(BaseModel):
|
||||
id: str
|
||||
journal_entry_id: str
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue