diff --git a/accountant/api/models/accounts.py b/accountant/api/models/accounts.py index 1bb7d6c..0255b8d 100644 --- a/accountant/api/models/accounts.py +++ b/accountant/api/models/accounts.py @@ -44,3 +44,7 @@ class Account(db.Model): ).outerjoin(Entry).group_by(cls.id).order_by(cls.id) return query + + @classmethod + def get(cls, session, id): + return session.query(cls).filter(cls.id == id).one() diff --git a/accountant/api/models/entries.py b/accountant/api/models/entries.py index df64e8d..cd8e052 100644 --- a/accountant/api/models/entries.py +++ b/accountant/api/models/entries.py @@ -62,3 +62,7 @@ class Entry(db.Model): ).filter(cls.account_id == account_id).order_by("year", "month") return query + + @classmethod + def get(cls, session, id): + return session.query(cls).filter(cls.id == id).one() diff --git a/accountant/api/models/operations.py b/accountant/api/models/operations.py index 3b212fd..0fe296b 100644 --- a/accountant/api/models/operations.py +++ b/accountant/api/models/operations.py @@ -95,3 +95,7 @@ class Operation(db.Model): ).group_by(cls.account_id) return query + + @classmethod + def get(cls, session, id): + return session.query(cls).filter(cls.id == id).one() diff --git a/accountant/api/models/scheduled_operations.py b/accountant/api/models/scheduled_operations.py index 4eaad97..f8a2a51 100644 --- a/accountant/api/models/scheduled_operations.py +++ b/accountant/api/models/scheduled_operations.py @@ -67,3 +67,7 @@ class ScheduledOperation(db.Model): ) return query + + @classmethod + def get(cls, session, id): + return session.query(cls).filter(cls.id == id).one()