This commit is contained in:
James Cole
2018-08-12 10:06:20 +02:00
parent b95ca98be9
commit dd95776144
8 changed files with 24 additions and 18 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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