示例#1
0
def journal_(account_name=None):
    "A list of all the entries for this account realization."
    account_name = app.account_xform.parse(account_name)

    # Figure out which account to render this from.
    real_accounts = request.view.real_accounts
    if account_name:
        if account_name and account_types.is_balance_sheet_account(
                account_name, app.account_types):
            real_accounts = request.view.closing_real_accounts

    # Render the report.
    args = []
    if account_name:
        args.append('--account={}'.format(account_name))

    render_postings = request.params.get('postings', True)
    if isinstance(render_postings, str):
        render_postings = render_postings.lower() in ('1', 'true')
    if render_postings:
        args.append('--verbose')

    try:
        html_journal = render_real_report(journal_reports.JournalReport,
                                          real_accounts,
                                          app.price_map,
                                          request.view.price_date,
                                          args,
                                          leaf_only=False)
    except KeyError as e:
        raise bottle.HTTPError(404, '{}'.format(e))

    return render_view(pagetitle='{}'.format(
        account_name or 'General Ledger (All Accounts)'),
                       contents=html_journal)
示例#2
0
def find_accounts(entries: data.Entries, options_map: data.Options,
                  start_date: Optional[Date]) -> List[Account]:
    """Return a list of account names from the balance sheet which either aren't
    closed or are closed now but were still open at the given start date.
    """
    commodities = getters.get_commodity_directives(entries)
    open_close_map = getters.get_account_open_close(entries)
    atypes = options.get_account_types(options_map)
    return sorted(
        account for account, (_open, _close) in open_close_map.items()
        if (accountlib.leaf(account) in commodities
            and acctypes.is_balance_sheet_account(account, atypes)
            and not acctypes.is_equity_account(account, atypes) and (
                _close is None or (start_date and _close.date > start_date))))
    def test_is_account_categories(self):
        for account_name, expected in [
            ("Assets:US:RBS:Savings", True),
            ("Liabilities:US:RBS:MortgageLoan", True),
            ("Equity:Opening-Balances", True),
            ("Income:US:ETrade:Dividends", False),
            ("Expenses:Toys:Computer", False),
        ]:
            self.assertEqual(
                expected,
                account_types.is_balance_sheet_account(
                    account_name, account_types.DEFAULT_ACCOUNT_TYPES))

            self.assertEqual(
                not expected,
                account_types.is_income_statement_account(
                    account_name, account_types.DEFAULT_ACCOUNT_TYPES))
示例#4
0
def find_institutions(entries, options_map):
    """Gather all the institutions and valid accounts from the list of entries.

    Args:
      entries: A list of entries.
      options_map: A dict of options, as per the parser.
    Returns:
      See group_accounts_by_metadata().
    """
    acc_types = options.get_account_types(options_map)

    # Filter out accounts that are closed or that are income accounts.
    open_close_map = getters.get_account_open_close(entries)
    accounts_map = {acc: open_entry
                    for acc, (open_entry, close_entry) in open_close_map.items()
                    if (account_types.is_balance_sheet_account(acc, acc_types) and
                        close_entry is None)}

    # Group the accounts using groups defined implicitly by metadata.
    return group_accounts_by_metadata(accounts_map, 'institution')
示例#5
0
文件: web.py 项目: zhzy0077/beancount
def journal_(account_name=None):
    "A list of all the entries for this account realization."

    # Ensure we support slashes and colons equally.
    # Old style used to be slashes; now we're using colons, it works everywhere.
    account_name = account_name.strip('/').replace('/', account.sep)

    # Figure out which account to render this from.
    real_accounts = request.view.real_accounts
    if account_name:
        if account_name and account_types.is_balance_sheet_account(
                account_name, app.account_types):
            real_accounts = request.view.closing_real_accounts

    # Render the report.
    args = []
    if account_name:
        args.append('--account={}'.format(account_name))

    render_postings = request.params.get('postings', True)
    if isinstance(render_postings, str):
        render_postings = render_postings.lower() in ('1', 'true')
    if render_postings:
        args.append('--verbose')

    try:
        html_journal = render_real_report(journal_reports.JournalReport,
                                          real_accounts,
                                          args,
                                          leaf_only=False)
    except KeyError as e:
        raise bottle.HTTPError(404, '{}'.format(e))

    return render_view(pagetitle='{}'.format(
        account_name or 'General Ledger (All Accounts)'),
                       contents=html_journal)