Adding Equity Account Family
This commit is contained in:
@@ -17,7 +17,7 @@ class AccountBaseId(AccountBase):
|
||||
id: UUID | None = Field(default_factory=uuid4, primary_key=True)
|
||||
family: str = Field(index=True)
|
||||
type: str = Field(index=True)
|
||||
path: str = Field(index=True, unique=True)
|
||||
path: str = Field(index=True)
|
||||
|
||||
class Account(AccountBaseId, table=True):
|
||||
parent_account: Optional["Account"] = Relationship(
|
||||
@@ -104,6 +104,15 @@ class Account(AccountBaseId, table=True):
|
||||
|
||||
return account_db
|
||||
|
||||
@classmethod
|
||||
def create_equity_account(cls, session):
|
||||
account_db = Account(name="Equity", family="Equity", type="Equity", path="/Equity/")
|
||||
session.add(account_db)
|
||||
session.commit()
|
||||
session.refresh(account_db)
|
||||
|
||||
return account_db
|
||||
|
||||
@classmethod
|
||||
def list(cls, filters):
|
||||
return filters.sort(filters.filter(select(Account)))
|
||||
@@ -111,7 +120,7 @@ class Account(AccountBaseId, table=True):
|
||||
@classmethod
|
||||
def list_accounts(cls, filters):
|
||||
return cls.list(filters).where(
|
||||
Account.type.not_in([v.value for v in CategoryType])
|
||||
Account.family.in_(["Asset", "Liability"])
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@@ -125,7 +134,7 @@ class Account(AccountBaseId, table=True):
|
||||
@classmethod
|
||||
def list_categories(cls, filters):
|
||||
return cls.list(filters).where(
|
||||
Account.type.in_([v.value for v in CategoryType])
|
||||
Account.type.in_(["Expense", "Income"])
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@@ -175,11 +184,12 @@ class AccountType(Enum):
|
||||
Currency = "Currency" # < Denotes a currency trading account.
|
||||
AssetLoan = "AssetLoan" # < Denotes a loan (asset of the owner of this object)
|
||||
Stock = "Stock" # < Denotes an security account as sub-account for an investment
|
||||
Equity = "Equity" # < Denotes an equity account e.g. opening/closing balance
|
||||
|
||||
Income = "Income" # < Denotes an income account
|
||||
Expense = "Expense" # < Denotes an expense account
|
||||
|
||||
Equity = "Equity" # < Denotes an equity account e.g. opening/closing balance
|
||||
|
||||
class Asset(Enum):
|
||||
Asset = "Asset"
|
||||
Checkings = "Checkings"
|
||||
|
||||
Reference in New Issue
Block a user