{% extends "main/base.html" %}
{% load i18n main_extras statement_extras transaction_extras category %}
{% block title %}
  {{ statement }}
  – Nummi
{% endblock title %}
{% block link %}
  {{ block.super }}
  {% css "main/css/form.css" %}
  {% css "main/css/table.css" %}
  {% css "main/css/plot.css" %}
{% endblock link %}
{% block body %}
  <h2>{{ statement }}</h2>
  <p>
    <a href="{{ account.get_absolute_url }}">{{ account.icon|remix }}{{ account }}</a>
  </p>
  <p>
    <a href="{% url "edit_statement" statement.id %}">{{ "file-edit"|remix }}{% translate "Edit statement" %}</a>
  </p>
  <div class="statement-details">
    {% if statement.sum != statement.diff %}
      <span class="incons">
        {{ statement.sum|check:statement.diff }}
        <span class="ds">
          <span class="diff value">{{ statement.diff|pmvalue }}</span>
          <span class="sum value">{{ statement.sum|pmvalue }}</span>
        </span>
        <span class="links">
          <a class="edit" href="{% url "edit_statement" statement.id %}">{{ "file-edit"|remix }}{% translate "Edit statement" %}</a>
          <a href="{% url "new_transaction" statement=statement.id %}">{{ "add-circle"|remix }}{% translate "Add transaction" %}</a>
        </span>
      </span>
    {% endif %}
    {% if statement.file %}
      <span class="file">
        <a class="title" href="{{ statement.file.url }}">{{ "file"|remix }}{{ statement }} [{{ statement.file|extension }}]</a>
      </span>
    {% endif %}
    <span class="start">
      <span class="date">{{ statement.start_date|date:"Y-m-d" }}</span>
      <span class="value">{{ statement.start_value|value }}</span>
    </span>
    <span class="evolution">
      <span class="value">{{ statement.sum|pmvalue }}</span>
      {{ "funds"|remix }}
      {% if statement.diff != statement.sum %}
        <span class="value">{{ statement.diff|pmvalue }}</span>
      {% endif %}
    </span>
    <span class="end">
      <span class="date">{{ statement.date|date:"Y-m-d" }}</span>
      <span class="value">{{ statement.value|value }}</span>
    </span>
  </div>
  <section>
    <h3>{% translate "Transactions" %}</h3>
    {% url_get "transactions" account=account.id statement=statement.id as t_url %}
    <p>
      <a class="big-link"
         href="{% url "new_transaction" statement=statement.id %}">{{ "add-circle"|remix }}{% translate "Add transaction" %}</a>
      <a class="big-link" href="{{ t_url }}">{{ "list-check"|remixnl }}{% translate "View all transactions" %}</a>
    </p>
    {% transaction_table statement.transaction_set.all n_max=8 transactions_url=t_url %}
  </section>
  <section>
    <h3>{% translate "Categories" %}</h3>
    {% category_plot transactions statement=object %}
  </section>
{% endblock body %}
