2020-03-23 17:17:10 +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/>.
|
|
|
|
#}
|
|
|
|
|
|
|
|
{% extends 'base_report.html' %}
|
|
|
|
|
2020-04-01 11:58:35 +11:00
|
|
|
{% block title %}Account Transactions for the {{ period }}{% endblock %}
|
2020-03-23 17:17:10 +11:00
|
|
|
|
|
|
|
{% block report %}
|
|
|
|
<h1>Account Transactions</h1>
|
|
|
|
<h2 style="margin-bottom: 0;">For {{ account.name }}</h2>
|
|
|
|
<h2>For the {{ period }}</h2>
|
|
|
|
|
|
|
|
<table class="ledger">
|
|
|
|
<tr>
|
2020-03-31 03:01:27 +11:00
|
|
|
<th style="min-width: 5em;">Date</th>
|
|
|
|
<th style="width: 100%;">Description</th>
|
|
|
|
<th style="min-width: 1em;"></th> {# Dr/Cr #}
|
|
|
|
<th style="text-align: right; min-width: 4em;">Amount</th>
|
2020-04-04 04:15:32 +11:00
|
|
|
<th style="min-width: 2em;"></th> {# Commodity #}
|
2020-03-31 03:01:27 +11:00
|
|
|
<th style="text-align: right; min-width: 4em;">Balance</th>
|
2020-04-04 04:15:32 +11:00
|
|
|
<th style="min-width: 2em;"></th> {# Commodity #}
|
2020-03-31 03:01:27 +11:00
|
|
|
<th style="min-width: 2em;"></th> {# Price #}
|
|
|
|
<th style="min-width: 1em;"></th>
|
2020-03-23 17:17:10 +11:00
|
|
|
</tr>
|
|
|
|
|
|
|
|
{% set ns = namespace(balance=None) %}
|
2020-04-01 11:58:35 +11:00
|
|
|
{% 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 '', 'commodity': 'on'}|urlencode %}
|
2020-03-23 17:17:10 +11:00
|
|
|
{% for amount in opening_balance.amounts %}
|
2020-05-08 23:20:18 +10:00
|
|
|
<tr class="total{% if loop.first %} trn-first{% endif %}{% if loop.last %} trn-last{% endif %}">
|
2020-04-01 11:58:35 +11:00
|
|
|
<td>{% if loop.first %}<a href="{{ prevlink }}">{{ date_beg.strftime('%Y-%m-%d') }}</a>{% endif %}</td>
|
2020-03-23 17:17:10 +11:00
|
|
|
<td>{% if loop.first %}<a href="{{ prevlink }}">Opening Balance</a>{% endif %}</td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
2020-03-30 19:51:02 +11:00
|
|
|
<td></td>
|
2020-04-03 19:33:59 +11:00
|
|
|
{{ amount|abs|bt(True, prevlink) }}
|
2020-03-23 17:17:10 +11:00
|
|
|
<td>{% if amount >= 0 %}Dr{% else %}Cr{% endif %}</td>
|
|
|
|
</tr>
|
2020-03-30 19:26:14 +11:00
|
|
|
{% else %}
|
2020-05-08 23:20:18 +10:00
|
|
|
<tr class="total trn-first trn-last">
|
2020-04-01 11:58:35 +11:00
|
|
|
<td><a href="{{ prevlink }}">{{ date_beg.strftime('%Y-%m-%d') }}</a></td>
|
2020-03-30 19:26:14 +11:00
|
|
|
<td><a href="{{ prevlink }}">Opening Balance</a></td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
2020-03-30 19:51:02 +11:00
|
|
|
<td></td>
|
2020-03-30 19:26:14 +11:00
|
|
|
<td style="text-align: right;"><a href="{{ prevlink }}">0.00</a></td>
|
|
|
|
<td></td>
|
2020-03-30 19:51:02 +11:00
|
|
|
<td></td>
|
2020-03-30 19:26:14 +11:00
|
|
|
<td>Dr</td>
|
|
|
|
</tr>
|
2020-03-23 17:17:10 +11:00
|
|
|
{% endfor %}
|
|
|
|
{% set ns.balance = opening_balance %}
|
|
|
|
|
|
|
|
{% for transaction in transactions %}
|
2020-07-17 11:31:35 +10:00
|
|
|
{% set trn_url = '/transaction?' + {'date': date_end.strftime('%Y-%m-%d'), 'pstart': date_beg.strftime('%Y-%m-%d'), 'uuid': transaction.uuid, 'cash': 'on' if cash else ''}|urlencode %}
|
2020-03-23 17:17:10 +11:00
|
|
|
{% for posting in transaction.postings if posting.account == account %}
|
|
|
|
{% set ns.balance = ns.balance + posting.amount %}
|
|
|
|
{% endfor %}
|
|
|
|
{% for amount in ns.balance.amounts %}
|
|
|
|
{% set posting = matching_posting(transaction, amount) %}
|
2020-05-08 23:20:18 +10:00
|
|
|
<tr{% if loop.first and loop.last %} class="trn-first trn-last"{% elif loop.first %} class="trn-first"{% elif loop.last %} class="trn-last"{% endif %}>
|
2020-03-29 21:46:55 +11:00
|
|
|
<td>{% if loop.first %}{% if transaction.id %}<a href="{{ trn_url }}">{% endif %}{{ transaction.date.strftime('%Y-%m-%d') }}{% if transaction.id %}</a>{% endif %}{% endif %}</td>
|
|
|
|
<td>{% if loop.first %}{% if transaction.id %}<a href="{{ trn_url }}">{% endif %}{{ transaction.description }}{% if transaction.id %}</a>{% endif %}{% endif %}</td>
|
2020-03-23 17:17:10 +11:00
|
|
|
{% if posting %}
|
|
|
|
<td>{% if posting.amount >= 0 %}Dr{% else %}Cr{% endif %}</td>
|
2020-03-30 19:51:02 +11:00
|
|
|
{{ posting.amount|abs|bt(False) }}
|
2020-03-23 17:17:10 +11:00
|
|
|
{% else %}
|
2020-03-30 19:51:02 +11:00
|
|
|
<td colspan="3"></td>
|
2020-03-23 17:17:10 +11:00
|
|
|
{% endif %}
|
2020-03-30 19:51:02 +11:00
|
|
|
{{ amount|abs|bt(True) }}
|
2020-03-23 17:17:10 +11:00
|
|
|
<td>{% if amount >= 0 %}Dr{% else %}Cr{% endif %}</td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
{% set ns.balance = ns.balance.clean() %}
|
2021-01-24 02:23:04 +11:00
|
|
|
|
|
|
|
{# This account's comment #}
|
|
|
|
{% for posting in transaction.postings if posting.account == account and posting.comment %}
|
|
|
|
<tr>
|
|
|
|
<td></td>
|
|
|
|
<td style="padding-left: 0.75em;">{{ posting.comment }}</td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
2020-03-23 17:17:10 +11:00
|
|
|
{% endfor %}
|
|
|
|
|
2020-07-17 11:32:49 +10:00
|
|
|
{% set nextlink = '/transactions?' + {'date_beg': (date_end + timedelta(days=1)).strftime('%Y-%m-%d'), 'date_end': date_end.replace(year=date_end.year+1).strftime('%Y-%m-%d'), 'account': account.name, 'cash': 'on' if cash else ''}|urlencode %}
|
2020-03-23 17:17:10 +11:00
|
|
|
{% for amount in closing_balance.amounts %}
|
2020-05-08 23:20:18 +10:00
|
|
|
<tr class="total explicit-rules{% if loop.first %} trn-first{% endif %}{% if loop.last %} trn-last{% endif %}" style="{% if loop.first %}border-top: 1pt solid black;{% endif %}{% if loop.last %}border-bottom: 1pt solid black;{% endif %}">
|
2020-07-17 11:32:49 +10:00
|
|
|
<td>{% if loop.first %}<a href="{{ nextlink }}">{{ date_end.strftime('%Y-%m-%d') }}</a>{% endif %}</td>
|
|
|
|
<td>{% if loop.first %}<a href="{{ nextlink }}">Closing Balance</a>{% endif %}</td>
|
2020-03-23 17:17:10 +11:00
|
|
|
<td></td>
|
|
|
|
<td></td>
|
2020-03-30 19:51:02 +11:00
|
|
|
<td></td>
|
2020-04-03 19:33:59 +11:00
|
|
|
{{ amount|abs|bt(True) }}
|
2020-03-23 17:17:10 +11:00
|
|
|
<td>{% if amount >= 0 %}Dr{% else %}Cr{% endif %}</td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
2020-03-30 19:20:28 +11:00
|
|
|
|
2020-05-11 00:20:54 +10:00
|
|
|
{% for amount in closing_balance.strip_prices().amounts %}
|
|
|
|
<tr class="total explicit-rules{% if loop.first %} trn-first{% endif %}{% if loop.last %} trn-last{% endif %}" style="{% if loop.first %}border-top: 1pt solid black;{% endif %}{% if loop.last %}border-bottom: 1pt solid black;{% endif %}">
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
{{ amount|abs|bt(True) }}
|
|
|
|
<td>{% if amount >= 0 %}Dr{% else %}Cr{% endif %}</td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
|
2020-05-08 23:20:18 +10:00
|
|
|
<tr class="total trn-first trn-last">
|
2020-03-30 19:20:28 +11:00
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
2020-04-04 04:15:32 +11:00
|
|
|
{% set closing_balance = closing_balance.exchange(report_commodity, True) %}
|
2020-04-03 19:33:59 +11:00
|
|
|
{{ closing_balance|abs|bt(True) }}
|
2020-03-30 19:20:28 +11:00
|
|
|
<td>{% if closing_balance >= 0 %}Dr{% else %}Cr{% endif %}</td>
|
|
|
|
</tr>
|
2020-03-23 17:17:10 +11:00
|
|
|
</table>
|
|
|
|
{% endblock %}
|