def get_years(cls, grid_class, company_id=None): query = DBSESSION().query(distinct(grid_class.year)) if company_id is not None: query = query.filter_by(company_id=company_id) result = [a[0] for a in query.all()] result.sort() return result
def get_years(cls, grid_class, company_id=None): query = DBSESSION().query(distinct(grid_class.year)) if company_id is not None: query = query.filter_by(company_id=company_id) result = [a[0] for a in query.all()] result.sort() return result
def get_categories(cls, active=True, keys=()): """ :param bool active: Only load active categories :param tuple keys: The keys to load (list of str) :returns: IncomeStatementMeasureTypeCategory ordered by order key :rtype: list """ query = DBSESSION().query(cls) if keys: query = query.options(load_only(*keys)) query = query.filter_by(active=active).order_by(cls.order) return query.all()
def get_categories(cls, active=True, keys=()): """ :param bool active: Only load active categories :param tuple keys: The keys to load (list of str) :returns: IncomeStatementMeasureTypeCategory ordered by order key :rtype: list """ query = DBSESSION().query(cls) if keys: query = query.options(load_only(*keys)) query = query.filter_by(active=active).order_by(cls.order) return query.all()
def get_by_category(cls, category_id, key=None): """ Collect IncomeStatementMeasureType associated to the given category :param int category_id: The id to check for :param str key: The key to load (if we want to restrict the query :rtype: list """ query = DBSESSION().query(cls) if key is not None: query = query.options(load_only(key)) query = query.filter_by(category_id=category_id) return query.all()
def get_by_category(cls, category_id, key=None): """ Collect IncomeStatementMeasureType associated to the given category :param int category_id: The id to check for :param str key: The key to load (if we want to restrict the query :rtype: list """ query = DBSESSION().query(cls) if key is not None: query = query.options(load_only(key)) query = query.filter_by(category_id=category_id) return query.all()
def get_years(cls, grid_class): query = DBSESSION().query(distinct(extract('year', grid_class.date))) result = [a[0] for a in query.all()] result.sort() return result
def get_years(cls, grid_class): query = DBSESSION().query(distinct(extract('year', grid_class.date))) result = [a[0] for a in query.all()] result.sort() return result