Removes parent-only accounts
Removes parent accounts from the database to simplify account management. Since the application exports to Beancount and doesn't directly interface with it, parent accounts for organizational hierarchy aren't necessary. The hierarchy is implicitly derived from the colon-separated account names. This change cleans the database and prevents accidental postings to parent accounts. Specifically removes "Assets:Bitcoin" and "Equity" accounts.
This commit is contained in:
parent
7752b41e06
commit
33c294de7f
2 changed files with 32 additions and 3 deletions
|
|
@ -191,7 +191,6 @@ def migrate_account_name(old_name: str, account_type: AccountType) -> str:
|
|||
DEFAULT_HIERARCHICAL_ACCOUNTS = [
|
||||
# Assets
|
||||
("Assets:Bank", AccountType.ASSET, "Bank account"),
|
||||
("Assets:Bitcoin", AccountType.ASSET, "Bitcoin holdings"),
|
||||
("Assets:Bitcoin:Lightning", AccountType.ASSET, "Lightning Network balance"),
|
||||
("Assets:Bitcoin:OnChain", AccountType.ASSET, "On-chain Bitcoin wallet"),
|
||||
("Assets:Cash", AccountType.ASSET, "Cash on hand"),
|
||||
|
|
@ -207,8 +206,8 @@ DEFAULT_HIERARCHICAL_ACCOUNTS = [
|
|||
# Liabilities
|
||||
("Liabilities:Payable", AccountType.LIABILITY, "Money owed by the Castle"),
|
||||
|
||||
# Equity
|
||||
("Equity", AccountType.EQUITY, "Owner's equity and member contributions"),
|
||||
# Equity - User equity accounts created dynamically as Equity:User-{user_id}
|
||||
# No parent "Equity" account needed - hierarchy is implicit in the name
|
||||
|
||||
# Revenue (Income in Beancount terminology)
|
||||
("Income:Accommodation:Guests", AccountType.REVENUE, "Revenue from guest accommodation"),
|
||||
|
|
|
|||
|
|
@ -486,3 +486,33 @@ async def m012_update_default_accounts(db):
|
|||
"description": description
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
async def m013_remove_parent_only_accounts(db):
|
||||
"""
|
||||
Remove parent-only accounts from the database.
|
||||
|
||||
Since Castle doesn't interface directly with Beancount (only exports to it),
|
||||
we don't need parent accounts that exist only for organizational hierarchy.
|
||||
The hierarchy is implicit in the colon-separated account names.
|
||||
|
||||
When exporting to Beancount, the parent accounts will be inferred from the
|
||||
hierarchical naming (e.g., "Assets:Bitcoin:Lightning" implies "Assets:Bitcoin" exists).
|
||||
|
||||
This keeps our database clean and prevents accidentally posting to parent accounts.
|
||||
|
||||
Removes:
|
||||
- Assets:Bitcoin (parent of Lightning and OnChain)
|
||||
- Equity (parent of user equity accounts like Equity:User-xxx)
|
||||
"""
|
||||
# Remove Assets:Bitcoin (parent account)
|
||||
await db.execute(
|
||||
"DELETE FROM accounts WHERE name = :name",
|
||||
{"name": "Assets:Bitcoin"}
|
||||
)
|
||||
|
||||
# Remove Equity (parent account)
|
||||
await db.execute(
|
||||
"DELETE FROM accounts WHERE name = :name",
|
||||
{"name": "Equity"}
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue