web/penny/templates/reports/profitloss.html
{% if report_resource == 'entity': %}
{% set resource = entity %}
{% set resource_name = entity.name %}
{% elif report_resource == 'bankaccount': %}
{% set resource = bankaccount %}
{% set resource_name = bankaccount.bank %}
{% endif %}
{% extends "navbar.html" %}
{% block content %}
<div class="container-fluid flex-grow-1">
<h1 class="page-header">{{ resource_name }} Profit Loss</h1>
<div class="card shadow mb-4">
<div class="card-body">
<h2>{{ form.datepicker_start.data.strftime('%d/%m/%Y') }} to {{ form.datepicker_end.data.strftime('%d/%m/%Y') }}</h2>
<form action={{ url_for('reports.profitloss', id=resource.id, report_resource=report_resource) }} method="POST">
{{ form.hidden_tag() }}
{{ form.csrf_token }}
<div class="col-xs-12">
<div class="col-lg-2">
<input type="text" placeholder="dd/mm/yyyy" id="datepicker_start" name="datepicker_start" value="{{ form.datepicker_start.data.strftime('%d/%m/%Y') }}" class="form-control">
</div>
<div class="col-lg-2">
<input type="text" placeholder="dd/mm/yyyy" id="datepicker_end" name="datepicker_end" value="{{ form.datepicker_end.data.strftime('%d/%m/%Y') }}" class="form-control">
</div>
<div class="col-lg-2">
<input type="submit" class="btn btn-primary" name="submit" value="submit">
{{ form.submit }}
</div>
</div>
</form>
<h2>Income</h2>
<div class="col-lg-12">
<div class="table-responsive">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>{%if report_resource == 'entity'%}Bank Account{%elif report_resource == 'bankaccount'%}Entity{%endif%}</th>
<th>Account</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
{% for account_id, account in report.transactions.income.items()|sort() %}
<tr>
<td>{%if report_resource == 'entity' %}<a href="{{ url_for('bankaccounts.bankaccount', id=account.bankaccount_id) }}">{{ account.bankaccount_bank + ' ' + account.bankaccount_number }}</a>{%elif report_resource == 'bankaccount'%}{{ account.entity_name }}{%endif%}</td><td><a href="{{ url_for('accounts.account', id=account_id) }}">{{ account.account_name }}</a></td><td><a href="{{ url_for('transactions.account', id=account_id, start_date=start_date, end_date=end_date) }}">{{ account.amount|convert_to_float }}</a></td>
</tr>
{% endfor %}
<tr>
<td> </td>
<td><strong>Total Income</strong></td>
<td>{{ report.transactions.income_total_amount|convert_to_float }}</td>
</tr>
</tbody>
</table>
</div>
<!-- /.table-responsive -->
</div>
<!-- /.col-lg-12 -->
<h2>Expenses</h2>
<div class="col-lg-12">
<div class="table-responsive">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>{%if report_resource == 'entity'%}Bank Account{%elif report_resource == 'bankaccount'%}Entity{%endif%}</th>
<th>Account</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
{% for account_id, account in report.transactions.expenses.items()|sort(attribute='1.amount') %}
<tr>
<td>{%if report_resource == 'entity' %}<a href="{{ url_for('bankaccounts.bankaccount', id=account.bankaccount_id) }}">{{ account.bankaccount_bank + ' ' + account.bankaccount_number }}</a>{%elif report_resource == 'bankaccount'%}{{ account.entity_name }}{%endif%}</td><td><a href="{{ url_for('accounts.account', id=account_id) }}">{{ account.account_name }}</a></td><td><a href="{{ url_for('transactions.account', id=account_id, start_date=start_date, end_date=end_date) }}">{{ account.amount|convert_to_float }}</a></td>
</tr>
{% endfor %}
<tr>
<td> </td>
<td><strong>Total Expenses</strong></td>
<td>{{ report.transactions.expenses_total_amount|convert_to_float_positive }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
{% endblock %}