示例#1
0
    def render_real_htmldiv(self, real_root, options_map, file):
        account_types = options.get_account_types(options_map)
        for root in (account_types.assets, account_types.liabilities):
            oss = io.StringIO()
            table = tree_table.tree_table(oss,
                                          realization.get(real_root, root),
                                          None, ['Account', 'Last Entry'])
            num_cells = 0
            for real_account, cells, row_classes in table:
                if not isinstance(real_account, realization.RealAccount):
                    continue
                last_posting = realization.find_last_active_posting(
                    real_account.txn_postings)

                # Don't render updates to accounts that have been closed.
                # Note: this is O(N), maybe we can store this at realization.
                if last_posting is None or isinstance(last_posting,
                                                      data.Close):
                    continue

                last_date = data.get_entry(last_posting).date

                # Skip this posting if a cutoff date has been specified and the
                # account has been updated to at least the cutoff date.
                if self.args.cutoff and self.args.cutoff <= last_date:
                    continue

                # Okay, we need to render this. Append.
                cells.append(
                    data.get_entry(last_posting).date if real_account.
                    txn_postings else '-')
                num_cells += 1

            if num_cells:
                file.write(oss.getvalue())
示例#2
0
    def test_tree_table(self):
        oss = io.StringIO()
        for real_node, cells, classes in tree_table.tree_table(
                oss, self.real_root, None,
                header=['Account', 'Balance'],
                classes=['5cdc3b134179']):

            if real_node is tree_table.TOTALS_LINE:
                cells.append('THE_TOTAL')
                continue
            cells.append("<pre>{}</pre>".format(real_node.balance))
        html = oss.getvalue()
        self.assertRegex(html, '<table')
        self.assertRegex(html, '3000')
        self.assertRegex(html, '-3000')
        self.assertRegex(html, '5cdc3b134179')
        self.assertRegex(html, 'Assets:US:Checking')