{% extends 'dashboard/layout.html' %}
{% load url from future %}
{% load currency_filters %}
{% load i18n %}

{% block title %}
{{ title }} | {% trans "Accounts" %} | {{ block.super }}
{% endblock %}

{% block breadcrumbs %}
<ul class="breadcrumb">
    <li>
		<a href="{% url 'dashboard:index' %}">{% trans "Dashboard" %}</a>
        <span class="divider">/</span>
    </li>
    <li>
		<a href="{% url 'accounts-list' %}">{% trans "Accounts" %}</a>
        <span class="divider">/</span>
    </li>
	<li class="active">{{ title }}</li>
</ul>
{% endblock %}

{% block headertext %}{{ title }}{% endblock %}

{% block dashboard_content %}

<form class="well form-horizontal" action="." method="get">
	{% include 'partials/form_fields.html' %}
	<button type="submit" class="btn btn-primary">{% trans "Fetch report" %}</button>
</form>

{% if show_report %}
<h2>{% trans "Transactions between" %} {{ start_date }} {% trans "and" %} {{ end_date }}</h2>
<table class="table">
	<tbody>
		<tr>
			<th colspan="2">{% trans "INCREASES IN DEFERRED INCOME LIABILITY" %}</th>
		</tr>
		<tr>
			<th colspan="2">{% trans "Sales" %}</th>
		</tr>
		{% for row in cash_rows %}
		<tr>
			<td>{{ row.name }}</td>
			<td>{{ row.total|currency }}</td>
		</tr>
		{% endfor %}
		<tr>
			<th></th>
			<th>{{ cash_total|currency }}</th>
		</tr>
		<tr>
			<th colspan="2">{% trans "Unpaid sources" %}</th>
		</tr>
		{% for row in unpaid_rows %}
		<tr>
			<td>{{ row.name }}</td>
			<td>{{ row.total|currency }}</td>
		</tr>
		<tr>
			<th></th>
			<th>{{ unpaid_total|currency }}</th>
		</tr>
		{% endfor %}
		<tr>
			<th colspan="2">{% trans "Refunds" %}</th>
		</tr>
		{% for row in refund_rows %}
		<tr>
			<td>{{ row.name }}</td>
			<td>{{ row.total|currency }}</td>
		</tr>
		{% endfor %}
		<tr>
			<th></th>
			<th>{{ refund_total|currency }}</th>
		</tr>
		<tr>
			<th>{% trans "TOTAL" %}</th>
			<th>{{ increase_total|currency }}</th>
		</tr>
		<tr>
			<th>&nbsp;</th>
			<th></th>
		</tr>
		<tr>
			<th colspan="2">{% trans "REDUCTIONS IN DEFERRED INCOME LIABILITY" %}</th>
		</tr>
		<tr>
			<th colspan="2">{% trans "Redemptions" %}</th>
		</tr>
		{% for row in redeem_rows %}
		<tr>
			<td>{{ row.name }}</td>
			<td>{{ row.total|currency }}</td>
		</tr>
		{% endfor %}
		<tr>
			<th></th>
			<th>{{ redeem_total|currency }}</th>
		</tr>
		<tr>
			<th colspan="2">{% trans "Expired" %}</th>
		</tr>
		{% for row in closure_rows %}
		<tr>
			<td>{{ row.name }}</td>
			<td>{{ row.total|currency }}</td>
		</tr>
		{% endfor %}
		<tr>
			<th></th>
			<th>{{ closure_total|currency }}</th>
		</tr>
		<tr>
			<th>{% trans "TOTAL" %}</th>
			<th>{{ reduction_total|currency }}</th>
		</tr>
		<tr>
			<th>&nbsp;</th>
			<th></th>
		</tr>
		<tr>
			<th>{% trans "DIFFERENCE IN POSITION" %}</th>
			<th>{{ position_difference|currency }}</th>
		</tr>
</table>
{% endif %}

{% endblock dashboard_content %}
