Returns the Accounts aggregate
499449
def accounts(self) -> AccountsAggregate:
        
        if not self.__accounts_aggregate:
            self.__accounts_aggregate = AccountsAggregate(self.book)
        return self.__accounts_aggregate
1059550
def get_item_balances(self, acc: Account) -> list:
        
        items = []
        entries = self.get_entries(acc)
        for item in entries.filter(source_invoice=self).order_by('id'):
            assert isinstance(item, AccountEntry)
            settlements = sum_queryset(entries.filter(settled_item=item))
            bal = item.amount + settlements if item.amount is not None else settlements
            items.append((item, bal))
        return items
632152
def aggregate(self, start, end):
        '''
        
        '''
        last = self.objects(
            level='daily', date__lte=self.iso(end),
            date__gte=self.iso(start)).order_by('-date').first()
        return last.values[self.name]
1011829
def accounts(self):
        
        if self._accounts is None:
            from twilio.rest.accounts import Accounts
            self._accounts = Accounts(self)
        return self._accounts
704319
def receivables_account(self) -> Account:
        
        row = AccountEntry.objects.filter(source_invoice=self).order_by('id').first()
        return row.account if row else None
672411
def get_income_accounts(self) -> List[Account]:
        
        # trading = self.book.trading_account(self.security)
        # log(DEBUG, "trading account = %s, %s", trading.fullname, trading.guid)

        # Example on how to self-link, i.e. parent account, using alias.
        # parent_alias = aliased(Account)
            # .join(parent_alias, Account.parent)
        # parent_alias.parent_guid != trading.guid

        query = (
            self.book.session.query(Account)
            .join(Commodity)
            .filter(Account.name == self.security.mnemonic)
            .filter(Commodity.namespace == "CURRENCY")
            # .filter(Account.type != "TRADING")
            .filter(Account.type == AccountType.income.value)
        )
        # generic.print_sql(query)
        return query.all()
649958
def transactions(self) -> TransactionsAggregate:
        
        if not self.__transactions_aggregate:
            self.__transactions_aggregate = TransactionsAggregate(self.book)
        return self.__transactions_aggregate
416824
def __get_all_child_accounts_as_array(self, account: Account) -> List[Account]:
        
        result = []
        # ignore placeholders ? - what if a brokerage account has cash/stocks division?
        # if not account.placeholder:
        # continue
        result.append(account)

        for child in account.children:
            sub_accounts = self.__get_all_child_accounts_as_array(child)
            result += sub_accounts

        return result
153138
def balance(ctx, accounts):
    
    t = [["Account", "Amount"]]
    for a in accounts:
        account = Account(a, bitshares_instance=ctx.bitshares)
        for b in account.balances:
            t.append([str(a), str(b)])
    print_table(t)
152992
def get_accounts(self, **params):
        """"""
        response = self._get('v2', 'accounts', params=params)
        return self._make_api_object(response, Account)
144446
def accounts(self):
        
        if self._accounts is None:
            self._accounts = AccountList(self)
        return self._accounts
499794
def listtransactions(self, account="", many=999, since=0):
        """"""
        return self.req("listtransactions", [account, many, since])
915133
def get_aggregate(self):
        
        return dict([(aggregate.find('query').text, [(ET.tostring(data).lstrip('<data xmlns:cps="www.clusterpoint.com" xmlns:cpse="www.clusterpoint.com">').strip().rstrip("</data>")) for data in aggregate.findall('data')])
                   for aggregate in self._content.findall('aggregate')])
802391
def GetAccounts(alias=None):
		""""""
		if alias is not None:  payload = {'AccountAlias': alias}
		else:  payload = {}
		r = clc.v1.API.Call('post','Account/GetAccounts',payload)
		if int(r['StatusCode']) == 0:  
			# Assume first response is always the original account.  Not sure if this is reliable
			if not clc.ALIAS:  clc.ALIAS = r['Accounts'][0]['AccountAlias']
			if not clc.LOCATION:  clc.LOCATION = r['Accounts'][0]['Location']

			return(r['Accounts'])
147172
def get_aggregation(self):
        
        agg = A(self.agg_type, **self._params)
        if self._metric:
            agg.metric('metric', self._metric)
        return agg
967162
def get_balance_context(self):
        """"""
        bank_account = Account.objects.get(name='Bank')

        return dict(
            bank=bank_account,
            retained_earnings_accounts=Account.objects.filter(parent__name='Retained Earnings'),
        )
1124912
def get_all(cls, include_disabled=True):
        
        if cls == BaseAccount:
            raise InquisitorError('get_all on BaseAccount is not supported')

        account_type_id = db.AccountType.find_one(account_type=cls.account_type).account_type_id
        qry = db.Account.order_by(desc(Account.enabled), Account.account_type_id, Account.account_name)

        if not include_disabled:
            qry = qry.filter(Account.enabled == 1)

        accounts = qry.find(Account.account_type_id == account_type_id)

        return {res.account_id: cls(res) for res in accounts}