Adding sorting to Accounts
This commit is contained in:
@@ -105,36 +105,36 @@ class Account(AccountBaseId, table=True):
|
||||
return account_db
|
||||
|
||||
@classmethod
|
||||
def list(cls):
|
||||
return select(Account)
|
||||
def list(cls, filters):
|
||||
return filters.sort(filters.filter(select(Account)))
|
||||
|
||||
@classmethod
|
||||
def list_accounts(cls):
|
||||
return cls.list().where(
|
||||
def list_accounts(cls, filters):
|
||||
return cls.list(filters).where(
|
||||
Account.type.not_in([v.value for v in CategoryType])
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def list_assets(cls):
|
||||
return cls.list().where(Account.family == "Asset")
|
||||
def list_assets(cls, filters):
|
||||
return cls.list(filters).where(Account.family == "Asset")
|
||||
|
||||
@classmethod
|
||||
def list_liabilities(cls):
|
||||
return cls.list().where(Account.family == "Liability")
|
||||
def list_liabilities(cls, filters):
|
||||
return cls.list(filters).where(Account.family == "Liability")
|
||||
|
||||
@classmethod
|
||||
def list_categories(cls):
|
||||
return cls.list().where(
|
||||
def list_categories(cls, filters):
|
||||
return cls.list(filters).where(
|
||||
Account.type.in_([v.value for v in CategoryType])
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def list_expenses(cls):
|
||||
return cls.list().where(Account.family == "Expense")
|
||||
def list_expenses(cls, filters):
|
||||
return cls.list(filters).where(Account.family == "Expense")
|
||||
|
||||
@classmethod
|
||||
def list_incomes(cls):
|
||||
return cls.list().where(Account.family == "Income")
|
||||
def list_incomes(cls, filters):
|
||||
return cls.list(filters).where(Account.family == "Income")
|
||||
|
||||
@classmethod
|
||||
def get(cls, session, account_id):
|
||||
@@ -227,8 +227,9 @@ class CategoryCreate(CategoryWrite):
|
||||
class CategoryUpdate(CategoryWrite):
|
||||
pass
|
||||
|
||||
class AccountFilter(Filter):
|
||||
class AccountFilters(Filter):
|
||||
name__like: Optional[str] = None
|
||||
order_by: Optional[list[str]] = None
|
||||
|
||||
class Constants(Filter.Constants):
|
||||
model = Account
|
||||
|
||||
Reference in New Issue
Block a user