Exemplo n.º 1
0
 def _table_tree(self, real_account):
     """
     Renders real_account and it's children as a flat list to be used
     in rendering tables.
     """
     return [{
         'account': ra.account,
         'balances_children':
             serialize_inventory(realization.compute_balance(ra),
                                 at_cost=True),
         'balances': serialize_inventory(ra.balance, at_cost=True),
         'is_leaf': len(ra) == 0 or bool(ra.txn_postings),
         'postings_count': len(ra.txn_postings)
     } for ra in realization.iter_children(real_account)]
Exemplo n.º 2
0
 def _total_balance(self, names, begin_date, end_date):
     totals = [realization.compute_balance(
         self._real_account(account_name, self.entries, begin_date,
                            end_date))
               for account_name in names]
     return serialize_inventory(sum(totals, inventory.Inventory()),
                                at_cost=True)
Exemplo n.º 3
0
 def _total_balance(self, names, begin_date, end_date):
     totals = [realization.compute_balance(
         self._real_account(account_name, self.entries, begin_date,
                            end_date))
               for account_name in names]
     return serialize_inventory(sum(totals, inventory.Inventory()),
                                at_cost=True)
Exemplo n.º 4
0
    def linechart_data(self, account_name):
        journal = self.account_journal(account_name, True)

        return [
            {
                "date": entry.date,
                # when there's no holding for a commodity, it will be missing from
                # 'balance' field but appear in 'change' field. Use 0 for those
                # commodities.
                "balance": dict({curr: 0 for curr in list(change.currencies())}, **serialize_inventory(balance)),
            }
            for entry, _, change, balance in journal
            if len(change)
        ]