Refactor category repositories.

This commit is contained in:
James Cole
2019-08-28 12:28:23 +02:00
parent e11af70f99
commit fa706d27d8
12 changed files with 713 additions and 919 deletions

View File

@@ -4,28 +4,29 @@
<th>{{ 'category'|_ }}</th>
<th style="text-align: right;">{{ 'spent'|_ }}</th>
<th style="text-align: right;">{{ 'earned'|_ }}</th>
<th style="text-align: right;">{{ 'sum'|_ }}</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
{% for index, category in report.categories %}
{% for category in report.categories %}
{% if loop.index > listLength %}
<tr class="overListLength">
{% else %}
<tr>
{% endif %}
<td>
<a href="{{ route('categories.show', category.id) }}">{{ category.name }}</a>
<a href="{{ route('categories.show', category.id) }}">{{ category.title }}</a>
</td>
<td style="text-align: right;">{{ formatAmountBySymbol(category.spent, category.currency_symbol, category.currency_decimal_places, true) }}</td>
<td style="text-align: right;">{{ formatAmountBySymbol(category.earned, category.currency_symbol, category.currency_decimal_places, true) }}</td>
<td style="text-align: right;">{{ formatAmountBySymbol(category.sum, category.currency_symbol, category.currency_decimal_places, true) }}</td>
<td style="width:20px;">
<i class="fa fa-fw fa-info-circle text-muted firefly-info-button"
data-location="category-entry" data-category-id="{{ category.id }}" data-currency-id="{{ category.currency_id }}"
></i>
</td>
</tr>
</tr>
{% endfor %}
</tbody>
<tfoot>
@@ -45,17 +46,10 @@
<td style="text-align: right;">
{{ formatAmountBySymbol(sum.earned, sum.currency_symbol, sum.currency_decimal_places) }}
</td>
<td></td>
<td style="text-align: right;">
{{ formatAmountBySymbol(sum.sum, sum.currency_symbol, sum.currency_decimal_places) }}
</td>
</tr>
{% endfor %}
{#
<tr>
<td><em>{{ 'sum'|_ }}</em></td>
<td style="text-align: right;">{{ sumEarned|formatAmount }}</td>
<td style="text-align: right;">{{ sumSpent|formatAmount }}</td>
<td>&nbsp;</td>
</tr>
TODO fix the sum here.
#}
</tfoot>
</table>

View File

@@ -9,27 +9,27 @@
</tr>
</thead>
<tbody>
{% for id, info in report %}
{% for info in report %}
<tr>
<td>
{% if id != 0 %}
<a class="btn btn-default btn-xs" href="{{ route('categories.show', [id]) }}"><i class="fa fa-external-link"></i></a>
{% if info.id != 0 %}
<a class="btn btn-default btn-xs" href="{{ route('categories.show', [info.id]) }}"><i class="fa fa-external-link"></i></a>
{% else %}
<a class="btn btn-default btn-xs" href="{{ route('categories.no-category') }}"><i class="fa fa-external-link"></i></a>
{% endif %}
</td>
<td data-value="{{ info.name }}">
<a title="{{ info.name }}" href="#" data-category="{{ id }}" class="category-chart-activate">{{ info.name }}</a>
<td data-value="{{ info.title }}">
<a title="{{ info.title }}" href="#" data-currency="{{ info.currency_id }}" data-category="{{ info.id }}" class="category-chart-activate">{{ info.title }}</a>
</td>
{% for key, period in periods %}
{# income first #}
{% if(info.entries[key]) %}
<td data-value="{{ info.entries[key] }}" style="text-align: right;">
{{ info.entries[key]|formatAmount }}
{{ formatAmountBySymbol(info.entries[key], info.currency_symbol, info.currency_decimal_places) }}
</td>
{% else %}
<td data-value="0" style="text-align: right;">
{{ 0|formatAmount }}
{{ formatAmountBySymbol(0, info.currency_symbol, info.currency_decimal_places) }}
</td>
{% endif %}
{% endfor %}
@@ -37,11 +37,11 @@
{# if sum of income, display: #}
{% if info.sum %}
<td data-value="{{ info.sum }}" style="text-align: right;">
{{ info.sum|formatAmount }}
{{ formatAmountBySymbol(info.sum, info.currency_symbol, info.currency_decimal_places) }}
</td>
{% else %}
<td data-value="0" style="text-align: right;">
{{ 0|formatAmount }}
{{ formatAmountBySymbol(0, info.currency_symbol, info.currency_decimal_places) }}
</td>
{% endif %}
</tr>