{# 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' %} {% block title %}{% if account %}Account Transactions{% else %}General Ledger{% endif %} for the {{ period }}{% endblock %} {% block links %} {{ super() }} {% if account %}Show commodity detail{% endif %} {% endblock %} {% block report %} {% if account %}

Account Transactions

For {{ account.name }}

{% else %}

General Ledger

{% endif %}

For the {{ period }}

{% if account %}{% endif %} {% set ns = namespace(balance=None) %} {% if account %} {% set prevlink = '/transactions?' + {'date_end': (date_beg - timedelta(days=1)).strftime('%Y-%m-%d'), 'date_beg': date_beg.replace(year=date_beg.year-1).strftime('%Y-%m-%d'), 'account': account.name, 'cash': 'on' if cash else ''}|urlencode %} {% set ns.balance = opening_balance %} {% endif %} {% for transaction in transactions %} {% set trn_url = '/transaction?' + {'uuid': transaction.uuid, 'cash': 'on' if cash else ''}|urlencode %} {% if transaction.has_comment_detail %} {% if account %} {% else %} {% endif %} {# This account's comment #} {% if account %} {% for posting in transaction.postings if posting.account == account and posting.comment %} {% endfor %} {% endif %} {% endif %} {% for posting in transaction.exchange(report_commodity).postings if posting.account != account %} {% set trn_first = not transaction.has_comment_detail and loop.first %} {% set trn_last = loop.last %} {% if trn_first %} {% elif transaction.has_comment_detail and posting.comment %} {% else %} {% endif %} {% if account %} {# Reverse Dr/Cr so it's from the "perspective" of this account #} {% set ns.balance = ns.balance - posting.amount %} {% else %} {% endif %} {% endfor %} {% endfor %} {% if account %} {% else %} {% endif %}
Date Description {% if account %}Related {% endif %}Account Dr CrBalance
{{ date_beg.strftime('%Y-%m-%d') }} Opening Balance {% if opening_balance >= 0 %} {{ opening_balance|b }} Dr {% else %} {{ -opening_balance|b }} Cr {% endif %}
{% if transaction.id %}{% endif %}{{ transaction.date.strftime('%Y-%m-%d') }}{% if transaction.id %}{% endif %} {% if transaction.id %}{% endif %}{{ transaction.description }}{% if transaction.id %}{% endif %}
{{ posting.comment }}
{% if trn_first %}{% if transaction.id %}{% endif %}{{ transaction.date.strftime('%Y-%m-%d') }}{% if transaction.id %}{% endif %}{% endif %}{% if transaction.id %}{% endif %}{{ transaction.description }}{% if transaction.id %}{% endif %}{{ posting.comment }}{{ (posting.account.name|e).__str__().replace(':', ':')|safe }}{% if posting.amount < 0 %}{{ -posting.amount|b }}{% endif %} {% if posting.amount > 0 %}{{ posting.amount|b }}{% endif %} {% if loop.last %} {% if ns.balance >= 0 %} {{ ns.balance|b }} Dr {% else %} {{ -ns.balance|b }} Cr {% endif %} {% endif %} {% if posting.amount > 0 %}{{ posting.amount|b }}{% endif %} {% if posting.amount < 0 %}{{ -posting.amount|b }}{% endif %}
{{ date_end.strftime('%Y-%m-%d') }} Closing Balance {% if closing_balance >= 0 %} {{ closing_balance|b }} Dr {% else %} {{ -closing_balance|b }} Cr {% endif %}
{{ date_end.strftime('%Y-%m-%d') }} Total {{ total_dr|b }} {{ -total_cr|b }}
{% endblock %}