This commit is contained in:
James Cole 2018-08-12 10:06:20 +02:00
parent b95ca98be9
commit dd95776144
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
8 changed files with 24 additions and 18 deletions

View File

@ -200,7 +200,10 @@ class BillController extends Controller
/** @var Collection $bills */
$bills = $paginator->getCollection()->map(
function (Bill $bill) use ($transformer) {
return $transformer->transform($bill);
$return = $transformer->transform($bill);
$return['currency'] = $bill->transactionCurrency;
return $return;
}
);
$bills = $bills->sortBy(
@ -291,8 +294,9 @@ class BillController extends Controller
$parameters = new ParameterBag();
$parameters->set('start', $start);
$parameters->set('end', $end);
$resource = new Item($bill, new BillTransformer($parameters), 'bill');
$object = $manager->createData($resource)->toArray();
$resource = new Item($bill, new BillTransformer($parameters), 'bill');
$object = $manager->createData($resource)->toArray();
$object['data']['currency'] = $bill->transactionCurrency;
// use collector:
/** @var TransactionCollectorInterface $collector */

View File

@ -109,9 +109,9 @@ class BillController extends Controller
}
);
$chartData = [
['type' => 'bar', 'label' => (string)trans('firefly.min-amount'), 'entries' => []],
['type' => 'bar', 'label' => (string)trans('firefly.max-amount'), 'entries' => []],
['type' => 'line', 'label' => (string)trans('firefly.journal-amount'), 'entries' => []],
['type' => 'bar', 'label' => (string)trans('firefly.min-amount'),'currency_symbol' => $bill->transactionCurrency->symbol, 'entries' => []],
['type' => 'bar', 'label' => (string)trans('firefly.max-amount'),'currency_symbol' => $bill->transactionCurrency->symbol, 'entries' => []],
['type' => 'line', 'label' => (string)trans('firefly.journal-amount'),'currency_symbol' => $bill->transactionCurrency->symbol, 'entries' => []],
];
/** @var Transaction $entry */

View File

@ -174,6 +174,7 @@ class BillTransformer extends TransformerAbstract
'name' => $bill->name,
'currency_id' => $bill->transaction_currency_id,
'currency_code' => $bill->transactionCurrency->code,
'currency_symbol' => $bill->transactionCurrency->symbol,
'amount_min' => round((float)$bill->amount_min, 2),
'amount_max' => round((float)$bill->amount_max, 2),
'date' => $bill->date->format('Y-m-d'),

View File

@ -22,6 +22,7 @@
$(function () {
"use strict";
configAccounting(billCurrencySymbol);
columnChart(billUri, 'bill-overview');
}
);

View File

@ -85,7 +85,7 @@ var defaultChartOptions = {
display: false
},
ticks: {
// Include a dollar sign in the ticks
// break ticks when too long.
callback: function (value, index, values) {
return formatLabel(value, 20);
}

View File

@ -202,7 +202,6 @@ function columnChart(URI, container) {
var chartType = 'bar';
drawAChart(URI, container, chartType, options, colorData);
}
/**

View File

@ -27,7 +27,7 @@
<table class="table table-striped">
<tr>
<td colspan="2">
{{ trans('firefly.match_between_amounts', {low: object.data.amount_min|formatAmount, high: object.data.amount_max|formatAmount })|raw }}
{{ trans('firefly.match_between_amounts', {low: formatAmountByCurrency(object.data.currency,object.data.amount_min), high: formatAmountByCurrency(object.data.currency,object.data.amount_max) })|raw }}
{{ 'repeats'|_ }}
{{ trans('firefly.repeat_freq_' ~object.data.repeat_freq) }}.
</td>
@ -55,11 +55,11 @@
</tr>
<tr>
<td>{{ trans('firefly.average_bill_amount_year', {year: year}) }}</td>
<td>{{ yearAverage|formatAmount }}</td>
<td>{{ formatAmountByCurrency(object.data.currency,yearAverage) }}</td>
</tr>
<tr>
<td>{{ 'average_bill_amount_overall'|_ }}</td>
<td>{{ overallAverage|formatAmount }}</td>
<td>{{ formatAmountByCurrency(object.data.currency, overallAverage) }}</td>
</tr>
</table>
</div>
@ -174,6 +174,7 @@
{% block scripts %}
<script type="text/javascript">
var billCurrencySymbol = "{{ object.data.currency.symbol }}";
var billUri = '{{ route('chart.bill.single', [object.data.id]) }}';
</script>
<script type="text/javascript" src="js/lib/Chart.bundle.min.js?v={{ FF_VERSION }}"></script>

View File

@ -57,8 +57,8 @@
{% endif %}
</td>
<td data-value="{{ entry.amount_min }}" style="text-align: right;">
<span style="margin-right:5px;" title="{{ entry.amount_min|formatAmountPlain }} - {{ entry.amount_max|formatAmountPlain }}">
~ {{ ((entry.amount_max+ entry.amount_min)/2)|formatAmount }}
<span style="margin-right:5px;">
~ {{ formatAmountByCurrency(entry.currency, (entry.amount_max + entry.amount_min)/2) }}
</span>
</td>
@ -127,12 +127,12 @@
<td style="text-align:right;" colspan="3">{{ 'sum'|_ }} ({{ 'active_bills_only'|_ }})</td>
<td style="text-align:right;" colspan="1">
<span style="margin-right:5px;">
{{ sum_min|formatAmount }}
{{ formatAmountBySymbol(sum_min,'¤') }}
</span>
</td>
<td style="text-align:right;" colspan="1">
<span style="margin-right:5px;">
{{ sum_max|formatAmount }}
{{ formatAmountBySymbol(sum_max,'¤') }}
</span>
</td>
<td colspan="5">&nbsp;</td>
@ -151,12 +151,12 @@
<td style="text-align:right;" colspan="3">{{ 'average_per_bill'|_ }} ({{ 'active_bills_only'|_ }})</td>
<td style="text-align:right;" colspan="1">
<span style="margin-right:5px;">
{{ avg_min|formatAmount }}
{{ formatAmountBySymbol(avg_min,'¤') }}
</span>
</td>
<td style="text-align:right;" colspan="1">
<span style="margin-right:5px;">
{{ avg_max|formatAmount }}
{{ formatAmountBySymbol(avg_max,'¤') }}
</span>
</td>
<td colspan="6">&nbsp;</td>
@ -165,7 +165,7 @@
<td style="text-align:right;" colspan="3">{{ 'expected_total'|_ }} ({{ 'active_bills_only'|_ }})</td>
<td style="text-align:right;" colspan="1">
<span style="margin-right:5px;">
~ {{ expected_total|formatAmount }}
~ {{ formatAmountBySymbol(expected_total,'¤') }}
</span>
</td>
<td colspan="6">&nbsp;</td>