aboutsummaryrefslogtreecommitdiffstats
path: root/src/expense/templates/macros.html
blob: 2d831558c94dad5f2461858fcc0efeeb286c2d66 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{% macro label_field(label) -%}
{% for error in label.errors %}
<span>{{ error }}</span>
{% endfor %}
{{ label.label }}
{{ label() }}
{%- endmacro %}

{% macro expense_table(data, total) -%}
<table>
  <thead>
    <tr>
      <th></th>
      <th>Date</th>
      <th>Category</th>
      <th>Description</th>
      <th>Amount</th>
    </tr>
  </thead>
  <tbody>
    {% for row in data %}
      <tr>
          <td><a href="{{ url_for("tracker.trans", id=row.id ) }}">Edit</a></td>
          <td><time datetime="{{ row.date.strftime("%Y-%m-%d") }}">{{ row.date.strftime("%d/%m/%Y") }}<time></td>
          <td><a href="{{ url_for("tracker.cat", id=row.category.id ) }}">{{ row.category.name }}</a></td>
          <td>{{ row.description }}</td>
          <td>{{ "%.2f"|format(row.amount) }}</td>
      </tr>
    {% endfor %}
      <tfoot>
          <td colspan="4">Overall</td>
          <td>{{ "%.2f"|format(total) }}</td>
      </tfoot>
  </tbody>
</table>
{%- endmacro %}