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