2020-02-15 15:50:33 +11:00
|
|
|
{#
|
|
|
|
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 <https://www.gnu.org/licenses/>.
|
|
|
|
#}
|
|
|
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
2020-03-20 21:43:05 +11:00
|
|
|
<title>{% if account %}Account Transactions{% else %}General Ledger{% endif %} as at {{ date.strftime('%d %B %Y') }}</title>
|
2020-02-15 15:50:33 +11:00
|
|
|
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" integrity="sha256-l85OmPOjvil/SOvVt3HnSSjzF1TUMyT9eV0c2BzEGzU=" crossorigin="anonymous">
|
|
|
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='main.css') }}">
|
|
|
|
</head>
|
|
|
|
<body>
|
2020-03-20 21:43:05 +11:00
|
|
|
{% if account %}
|
|
|
|
<h1>Account Transactions</h1>
|
|
|
|
<h2 style="margin-bottom: 0;">For {{ account.name }}</h2>
|
|
|
|
{% else %}
|
|
|
|
<h1>General Ledger</h1>
|
|
|
|
{% endif %}
|
2020-02-15 15:50:33 +11:00
|
|
|
<h2>As at {{ date.strftime('%d %B %Y') }}</h2>
|
|
|
|
|
|
|
|
<table class="ledger">
|
|
|
|
<tr>
|
|
|
|
<th style="width: 5em;">Date</th>
|
|
|
|
<th>Description</th>
|
|
|
|
<th style="max-width: 8em;">Account</th>
|
|
|
|
<th class="h1" style="text-align: right; width: 5em;">Dr</th>
|
|
|
|
<th class="h1" style="text-align: right; width: 5em;">Cr</th>
|
2020-03-20 21:43:05 +11:00
|
|
|
{% if account %}<th class="h1" style="text-align: right; width: 6em;">Balance</th>{% endif %}
|
2020-02-15 15:50:33 +11:00
|
|
|
</tr>
|
2020-03-20 21:43:05 +11:00
|
|
|
|
|
|
|
{% set ns = namespace(balance=None) %}
|
|
|
|
{% if account %}
|
|
|
|
<tr class="total">
|
|
|
|
<td>{{ pstart.strftime('%Y-%m-%d') }}</td>
|
|
|
|
<td>Opening Balance</td>
|
|
|
|
<td></td>
|
|
|
|
<td style="text-align: right;"></td>
|
|
|
|
<td style="text-align: right;"></td>
|
|
|
|
<td style="text-align: right;">
|
|
|
|
{% if opening_balance >= 0 %}
|
|
|
|
{{ opening_balance|b }} Dr
|
|
|
|
{% else %}
|
|
|
|
{{ -opening_balance|b }} Cr
|
|
|
|
{% endif %}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{% set ns.balance = opening_balance %}
|
|
|
|
{% endif %}
|
|
|
|
|
2020-02-15 15:50:33 +11:00
|
|
|
{% for transaction in transactions %}
|
2020-03-20 21:43:05 +11:00
|
|
|
{% for posting in transaction.postings if (posting.amount.amount >= 0.05 or posting.amount.amount < -0.05) and posting.account != account %}
|
|
|
|
{% set amount = posting.exchange(report_currency, transaction.date) %}
|
|
|
|
{% set ns.balance = ns.balance - amount %}
|
2020-02-15 15:50:33 +11:00
|
|
|
<tr>
|
2020-03-20 18:54:01 +11:00
|
|
|
<td>{% if loop.first %}{{ transaction.date.strftime('%Y-%m-%d') }}{% endif %}</td>
|
2020-03-20 21:43:05 +11:00
|
|
|
<td>{% if loop.first %}{{ transaction.description }}{% endif %}</td>
|
|
|
|
<td><a href="/transactions?{{ {'date': date.strftime('%Y-%m-%d'), 'pstart': pstart.strftime('%Y-%m-%d'), 'account': posting.account.name}|urlencode }}">{{ (posting.account.name|e).__str__().replace(':', ':<wbr>')|safe }}</a></td>
|
|
|
|
{% if account %}
|
|
|
|
{# Reverse Dr/Cr so it's from the "perspective" of this account #}
|
|
|
|
<td style="text-align: right;">{% if amount < 0 %}<span title="{{ (-posting.amount).tostr(False) }}">{{ -amount|b }}</span>{% endif %}</td>
|
|
|
|
<td style="text-align: right;">{% if amount > 0 %}<span title="{{ posting.amount.tostr(False) }}">{{ amount|b }}</span>{% endif %}</td>
|
|
|
|
<td style="text-align: right;">
|
|
|
|
{% if loop.last %}
|
|
|
|
{% if ns.balance >= 0 %}
|
|
|
|
{{ ns.balance|b }} Dr
|
|
|
|
{% else %}
|
|
|
|
{{ -ns.balance|b }} Cr
|
|
|
|
{% endif %}
|
2020-03-20 18:54:01 +11:00
|
|
|
{% endif %}
|
2020-03-20 21:43:05 +11:00
|
|
|
</td>
|
|
|
|
{% else %}
|
|
|
|
<td style="text-align: right;">{% if amount > 0 %}<span title="{{ posting.amount.tostr(False) }}">{{ amount|b }}</span>{% endif %}</td>
|
|
|
|
<td style="text-align: right;">{% if amount < 0 %}<span title="{{ (-posting.amount).tostr(False) }}">{{ -amount|b }}</span>{% endif %}</td>
|
|
|
|
{% endif %}
|
2020-02-15 15:50:33 +11:00
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
2020-03-20 21:43:05 +11:00
|
|
|
|
|
|
|
{% if account %}
|
|
|
|
<tr class="total">
|
|
|
|
<td>{{ date.strftime('%Y-%m-%d') }}</td>
|
|
|
|
<td>Closing Balance</td>
|
|
|
|
<td></td>
|
|
|
|
<td style="text-align: right;"></td>
|
|
|
|
<td style="text-align: right;"></td>
|
|
|
|
<td style="text-align: right;">
|
|
|
|
{% if closing_balance >= 0 %}
|
|
|
|
{{ closing_balance|b }} Dr
|
|
|
|
{% else %}
|
|
|
|
{{ -closing_balance|b }} Cr
|
|
|
|
{% endif %}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{% else %}
|
|
|
|
<tr class="total">
|
|
|
|
<td>{{ date.strftime('%Y-%m-%d') }}</td>
|
|
|
|
<td>Total</td>
|
|
|
|
<td></td>
|
|
|
|
<td style="text-align: right;">{{ total_dr|b }}</td>
|
|
|
|
<td style="text-align: right;">{{ -total_cr|b }}</td>
|
|
|
|
</tr>
|
|
|
|
{% endif %}
|
2020-02-15 15:50:33 +11:00
|
|
|
</table>
|
|
|
|
</body>
|
|
|
|
</html>
|