{# ledger-pyreport Copyright © 2020 Lee Yingtong Li (RunasSudo) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . #} {% extends 'base_report.html' %} {% macro print_rows(account, invert=False, level=0) %} {% if balance_sheets|length == 1 %} {% if account.name == config['current_year_earnings'] %} {% else %} {% endif %} {{ account.bits[-1] }} {% else %} {{ account.bits[-1] }} {% endif %} {% for balance_sheet in balance_sheets %} {% set amount = (-balance_sheet.get_balance(account) if invert else balance_sheet.get_balance(account)).exchange(report_currency, True) %} {% if amount != 0 %} {% if account.name == config['current_year_earnings'] %} {% else %} {% endif %} {{ amount|a }} {% endif %} {% endfor %} {% for child in account.children if child in accounts %} {{ print_rows(child, invert, level + 1) }} {% endfor %} {% endmacro %} {% macro do_accounts(root, label, invert, year_headers) %} {% for account_class in root.children if account_class in accounts %} {% if loop.first and year_headers %} {{ account_class.bits[-1] }} {{ label }} {% for balance_sheet in balance_sheets %}{{ balance_sheet.date.strftime('%Y') }} {% endfor %} {% else %} {{ account_class.bits[-1] }} {{ label }} {% endif %} {% for account in account_class.children if account in accounts %} {{ print_rows(account, invert=invert) }} {% endfor %} Total {{ account_class.bits[-1] }} {{ label }} {% for balance_sheet in balance_sheets %}{{ (-balance_sheet.get_total(account_class) if invert else balance_sheet.get_total(account_class)).exchange(report_currency, True)|a }}{% endfor %}   {% endfor %} Total {{ label }} {% for balance_sheet in balance_sheets %}{{ (-balance_sheet.get_total(root) if invert else balance_sheet.get_total(root)).exchange(report_currency, True)|a }}{% endfor %} {% endmacro %} {% block title %}Balance Sheet as at {{ balance_sheets[0].date.strftime('%d %B %Y') }}{% endblock %} {% block report %}

Balance Sheet

As at {{ balance_sheets[0].date.strftime('%d %B %Y') }}

{# Assets #} {{ do_accounts(ledger.get_account(config['assets_account']), 'Assets', False, True) }} {# Liabilities #} {{ do_accounts(ledger.get_account(config['liabilities_account']), 'Liabilities', True, False) }} {# Equity #} {% for account in ledger.get_account(config['equity_account']).children if account in accounts %} {{ print_rows(account, invert=True) }} {% endfor %} {% for balance_sheet in balance_sheets %}{% endfor %}
Assets
 
Liabilities
 
Equity
Total Equity{{ -balance_sheet.get_total(ledger.get_account(config['equity_account'])).exchange(report_currency, True)|a }}
{% endblock %}