From 31abf8b8b642d70f665d7de046ad0e5b00479d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristia=CC=81n=20Feldsam?= Date: Sun, 28 Apr 2019 22:52:42 +0200 Subject: [PATCH] Dashboard totals - fix currency in chart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kristián Feldsam --- resources/views/dashboard.blade.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index e4d3c51e8d31..73c8f5ebc68f 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -49,7 +49,7 @@ var label = " {!! trans('texts.expenses') !!}: "; } - return label + formatMoney(item.yLabel, chartCurrencyId, account.country_id); + return label + formatMoney(item.yLabel, realCurrencyId, account.country_id); } } }, @@ -73,7 +73,7 @@ ticks: { beginAtZero: true, callback: function(label, index, labels) { - return formatMoney(label, chartCurrencyId, account.country_id); + return formatMoney(label, realCurrencyId, account.country_id); } }, }] @@ -85,6 +85,7 @@ var account = {!! $account !!}; var chartGroupBy = 'day'; + var realCurrencyId = {{ $account->getCurrencyId() }}; var chartCurrencyId = {{ $account->getCurrencyId() }}; var dateRanges = {!! $account->present()->dateRangeOptions !!}; var chartStartDate; @@ -160,10 +161,11 @@ t.addClass("active").siblings().removeClass("active"); if(t.attr("data-button") === "totals"){ - - chartCurrencyId = 'totals'; + realCurrencyId = account.currency.id; + chartCurrencyId = "totals"; }else { - chartCurrencyId = currencyMap[t.text()].id; + realCurrencyId = currencyMap[t.text()].id; + chartCurrencyId = realCurrencyId; } displayTotalsNote(); @@ -190,10 +192,6 @@ response = JSON.parse(response); loadChart(response.data); - var realCurrencyId = chartCurrencyId; - if(chartCurrencyId === "totals") realCurrencyId = account.currency.id; - - var totals = response.totals; $('.revenue-div').text(formatMoney(totals.revenue, realCurrencyId, account.country_id)); $('.outstanding-div').text(formatMoney(totals.balance, realCurrencyId, account.country_id));