Make some parts of the budget repository multi-currency

This commit is contained in:
James Cole
2019-09-02 16:52:35 +02:00
parent 8246d901e7
commit 0fd7e4363d
10 changed files with 408 additions and 185 deletions

View File

@@ -887,6 +887,7 @@ return [
'cannot_edit_other_fields' => 'You cannot mass-edit other fields than the ones here, because there is no room to show them. Please follow the link and edit them by one-by-one, if you need to edit these fields.',
'cannot_change_amount_reconciled' => 'You can\'t change the amount of reconciled transactions.',
'no_budget' => '(no budget)',
'account_per_budget' => 'Account per budget',
'no_budget_squared' => '(no budget)',
'perm-delete-many' => 'Deleting many items in one go can be very disruptive. Please be cautious. You can delete part of a split transaction from this page, so take care.',
'mass_deleted_transactions_success' => 'Deleted :amount transaction(s).',
@@ -1434,7 +1435,7 @@ return [
'box_balance_in_currency' => 'Balance (:currency)',
'box_spent_in_currency' => 'Spent (:currency)',
'box_earned_in_currency' => 'Earned (:currency)',
'box_budgeted_in_currency' => 'Budgeted (:currency)',
'box_budgeted_in_currency' => 'Budgeted (:currency)',
'box_sum_in_currency' => 'Sum (:currency)',
'box_bill_paid_in_currency' => 'Bills paid (:currency)',
'box_bill_unpaid_in_currency' => 'Bills unpaid (:currency)',

View File

@@ -7,83 +7,50 @@
{% block content %}
<div class="row">
<div class="col-lg-4 col-md-6">
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
{# spent in these budgets per account, per currency.#}
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'accounts'|_ }}</h3>
</div>
<div class="box-body table-responsive no-padding">
<table class="table table-hover sortable">
<thead>
<tr>
<th data-defaultsign="az">{{ 'name'|_ }}</th>
<th data-defaultsign="_19" style="text-align: right;">{{ 'spent'|_ }}</th>
</tr>
</thead>
<tbody>
{% set sum = 0 %}
{% for account in accounts %}
<tr>
<td data-value="{{ account.name }}">
<a href="{{ route('accounts.show', account.id) }}" title="{{ account.name }}">{{ account.name }}</a>
</td>
{% if accountSummary[account.id] %}
{% set sum = sum + accountSummary[account.id] %}
<td data-value="{{ accountSummary[account.id] }}"
style="text-align: right;">{{ accountSummary[account.id]|formatAmount }}</td>
{% else %}
<td data-value="0" style="text-align: right;">{{ 0|formatAmount }}</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td>{{ 'sum'|_ }}</td>
<td style="text-align: right;">{{ sum|formatAmount }}</td>
</tr>
</tfoot>
</table>
<div class="box-body table-responsive no-padding" id="accountsHolder">
</div>
{# loading indicator #}
<div class="overlay">
<i class="fa fa-refresh fa-spin"></i>
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'budgets'|_ }}</h3>
</div>
<div class="box-body table-responsive no-padding">
<table class="table table-hover sortable">
<thead>
<tr>
<th data-defaultsign="az">{{ 'name'|_ }}</th>
<th data-defaultsign="_19" style="text-align: right;">{{ 'spent'|_ }}</th>
</tr>
</thead>
<tbody>
{% for budget in budgets %}
<tr>
<td data-value="{{ budget.name }}">
<a href="{{ route('budgets.show', budget.id) }}" title="{{ budget.name }}">{{ budget.name }}</a>
</td>
{% if budgetSummary[budget.id] %}
<td data-value="{{ budgetSummary[budget.id] }}" style="text-align: right;">{{ budgetSummary[budget.id]|formatAmount }}</td>
{% else %}
<td data-value="0" style="text-align: right;">{{ 0|formatAmount }}</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td>{{ 'sum'|_ }}</td>
<td style="text-align: right;">{{ budgetSummary.sum|formatAmount }}</td>
</tr>
</tfoot>
</table>
<div class="box-body table-responsive no-padding" id="budgetsHolder">
</div>
{# loading indicator #}
<div class="overlay">
<i class="fa fa-refresh fa-spin"></i>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'account_per_budget'|_ }}</h3>
</div>
<div class="box-body table-responsive no-padding" id="accountPerbudgetHolder">
</div>
{# loading indicator #}
<div class="overlay">
<i class="fa fa-refresh fa-spin"></i>
</div>
</div>
</div>
</div>
<div class="row">
{% if budgets.count > 1 %}
<div class="col-lg-4 col-md-6">
<div class="box">
@@ -145,6 +112,12 @@
<h3 class="box-title">{{ 'average_spending_per_account'|_ }}</h3>
</div>
<div class="box-body table-responsive no-padding">
</div>
{# loading indicator #}
<div class="overlay">
<i class="fa fa-refresh fa-spin"></i>
</div>
{#
<table class="table table-hover sortable">
<thead>
<tr>
@@ -198,6 +171,7 @@
</tfoot>
</table>
</div>
#}
</div>
</div>
{% endif %}
@@ -208,7 +182,14 @@
<div class="box-header with-border">
<h3 class="box-title">{{ 'expenses'|_ }} ({{ trans('firefly.topX', {number: listLength}) }})</h3>
</div>
<div class="box-body">
<div class="box-body table-responsive no-padding">
</div>
{# loading indicator #}
<div class="overlay">
<i class="fa fa-refresh fa-spin"></i>
</div>
{#
<table class="table table-hover sortable">
<thead>
<tr>
@@ -249,7 +230,7 @@
</td>
<td data-value="{{ row.amount}}" style="text-align: right;">
<td data-value="{{ row.amount }}" style="text-align: right;">
{{ formatAmountBySymbol(row.amount, row.currency_symbol, row.currency_decimal_places) }}
</td>
@@ -273,6 +254,7 @@
</tfoot>
</table>
</div>
#}
</div>
</div>
{% endif %}
@@ -293,6 +275,11 @@
var accountIds = '{{ accountIds }}';
var budgetIds = '{{ budgetIds }}';
// html block URI's:
var accountsUri = '{{ route('report-data.budget.accounts', [accountIds, budgetIds, start.format('Ymd'), end.format('Ymd')]) }}';
var budgetsUri = '{{ route('report-data.budget.budgets', [accountIds, budgetIds, start.format('Ymd'), end.format('Ymd')]) }}';
var accountPerBudgetUri = '{{ route('report-data.budget.account-per-budget', [accountIds, budgetIds, start.format('Ymd'), end.format('Ymd')]) }}';
// chart uri's
var budgetExpenseUri = '{{ route('chart.budget.budget-expense', [accountIds, budgetIds, start.format('Ymd'), end.format('Ymd'),'OTHERS']) }}';
var accountExpenseUri = '{{ route('chart.budget.account-expense', [accountIds, budgetIds, start.format('Ymd'), end.format('Ymd'),'OTHERS']) }}';

View File

@@ -0,0 +1,30 @@
<table class="table table-hover sortable">
<thead>
<tr>
<th data-defaultsign="az">{{ 'name'|_ }}</th>
{% for budget in budgets %}
<th data-defaultsign="_19" style="text-align: right;">{{ budget.name }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for account in report %}
{% for currency in account.currencies %}
<tr>
<td data-value="{{ account.name }} ({{ currency.currency_name }})">
<a href="{{ route('accounts.show', account.id) }}" title="{{ account.iban }}">{{ account.name }} ({{ currency.currency_name }})</a>
</td>
{% for budget in budgets %}
<td style="text-align: right;">
{% if currency.budgets[budget.id] %}
{{ formatAmountBySymbol(currency.budgets[budget.id], currency.currency_symbol, currency.currency_decimal_places) }}
{% else %}
&mdash;
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>

View File

@@ -0,0 +1,32 @@
<table class="table table-hover sortable">
<thead>
<tr>
<th data-defaultsign="az">{{ 'name'|_ }}</th>
<th data-defaultsign="_19" style="text-align: right;">{{ 'spent'|_ }}</th>
</tr>
</thead>
<tbody>
{% for account in report %}
{% for currency in account.currencies %}
<tr>
<td data-value="{{ account.name }} ({{ currency.currency_name }})">
<a href="{{ route('accounts.show', account.id) }}" title="{{ account.iban }}">{{ account.name }} ({{ currency.currency_name }})</a>
</td>
<td data-value="{{ currency.sum }}" style="text-align: right;">
{{ formatAmountBySymbol(currency.sum, currency.currency_symbol, currency.currency_decimal_places) }}
</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
<tfoot>
{% for sum in sums %}
<tr>
<td>{{ 'sum'|_ }} ({{ sum.currency_name }})</td>
<td style="text-align: right;">
{{ formatAmountBySymbol(sum.sum, sum.currency_symbol, sum.currency_decimal_places) }}
</td>
</tr>
{% endfor %}
</tfoot>
</table>

View File

@@ -0,0 +1,40 @@
<table class="table table-hover sortable">
<thead>
<tr>
<th data-defaultsign="az">{{ 'name'|_ }}</th>
<th data-defaultsign="_19" style="text-align: right;">{{ 'spent'|_ }}</th>
</tr>
</thead>
<tbody>
{% for budget in report %}
{% if budget.currencies|length == 0 %}
<tr>
<td data-value="{{ budget.name }}">
<a href="{{ route('budgets.show', budget.id) }}" title="{{ budget.name }}">{{ budget.name }}</a>
</td>
<td style="text-align: right;">&mdash;</td>
</tr>
{% endif %}
{% for currency in budget.currencies %}
<tr>
<td data-value="{{ budget.name }} ({{ currency.currency_name }})">
<a href="{{ route('budgets.show', budget.id) }}" title="{{ budget.name }}">{{ budget.name }} ({{ currency.currency_name }})</a>
</td>
<td data-value="{{ currency.sym }}" style="text-align: right;">
{{ formatAmountBySymbol(currency.sum, currency.currency_symbol, currency.currency_decimal_places) }}
</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
<tfoot>
{% for sum in sums %}
<tr>
<td>{{ 'sum'|_ }} ({{ sum.currency_name }})</td>
<td style="text-align: right;">
{{ formatAmountBySymbol(sum.sum, sum.currency_symbol, sum.currency_decimal_places) }}
</td>
</tr>
{% endfor %}
</tfoot>
</table>