{# 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 cashflows|length == 1 %} {{ account.bits[-1] }} {% else %} {{ account.bits[-1] }} {% endif %} {% for cashflow in cashflows %} {% set amount = (-cashflow.get_balance(account) if invert else cashflow.get_balance(account)).exchange(report_commodity, True) %} {% if not amount.near_zero %}{{ amount|a('/transactions?' + {'date': cashflow.date.strftime('%Y-%m-%d'), 'pstart': cashflow.pstart.strftime('%Y-%m-%d'), 'account': account.name, 'cash': 'on' if cash else ''}|urlencode) }}{% endif %} {% endfor %} {% for child in account.children|sort(attribute='name') if child in accounts %} {{ print_rows(child, invert, level + 1) }} {% endfor %} {% endmacro %} {% block title %}Cash Flow Statement for the {{ period }}{% endblock %} {% block report %}

Cash Flow Statement

For the {{ period }}

{# Cash flows #} {% for cashflow in cashflows %}{% endfor %} {% for account in ledger.root_account.children|sort(attribute='name') if account in accounts %} {{ print_rows(account, invert=invert) }} {% endfor %} {% for cashflow in cashflows %}{% endfor %} {# Summary #} {% for opening_balance in opening_balances %}{% endfor %} {% for cashflow in cashflows %}{% endfor %} {% for closing_balance in closing_balances %}{% endfor %}
Cash Inflows (Outflows){{ cashflow.date.strftime('%Y') }} 
Net Cash Inflow (Outflow){{ cashflow.get_total(ledger.root_account).exchange(report_commodity, True)|a }}
 
Opening Cash{{ opening_balance|a }}
Net Cash Inflow (Outflow){{ cashflow.get_total(ledger.root_account).exchange(report_commodity, True)|a }}
Closing Cash{{ closing_balance|a }}
{% endblock %}