mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-23 22:35:03 +00:00
Fix for #1667
This commit is contained in:
@@ -210,23 +210,25 @@ class AccountController extends Controller
|
|||||||
$budgetIds[] = $budgetId;
|
$budgetIds[] = $budgetId;
|
||||||
if (!isset($result[$combi])) {
|
if (!isset($result[$combi])) {
|
||||||
$result[$combi] = [
|
$result[$combi] = [
|
||||||
'total' => '0',
|
'total' => '0',
|
||||||
'budget_id' => $budgetId,
|
'budget_id' => $budgetId,
|
||||||
'currency' => $currencyName,
|
'currency' => $currencyName,
|
||||||
|
'currency_symbol' => $transaction->transaction_currency_symbol,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$result[$combi]['total'] = bcadd($transaction->transaction_amount, $result[$combi]['total']);
|
$result[$combi]['total'] = bcadd($transaction->transaction_amount, $result[$combi]['total']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$names = $this->getBudgetNames($budgetIds);
|
$names = $this->getBudgetNames($budgetIds);
|
||||||
|
|
||||||
foreach ($result as $row) {
|
foreach ($result as $row) {
|
||||||
$budgetId = $row['budget_id'];
|
$budgetId = $row['budget_id'];
|
||||||
$name = $names[$budgetId];
|
$name = $names[$budgetId];
|
||||||
$label = (string)trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency']]);
|
$label = (string)trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency']]);
|
||||||
$chartData[$label] = $row['total'];
|
$chartData[$label] = ['amount' => $row['total'], 'currency_symbol' => $row['currency_symbol']];
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->generator->pieChart($chartData);
|
$data = $this->generator->multiCurrencyPieChart($chartData);
|
||||||
$cache->store($data);
|
$cache->store($data);
|
||||||
|
|
||||||
return response()->json($data);
|
return response()->json($data);
|
||||||
@@ -276,6 +278,7 @@ class AccountController extends Controller
|
|||||||
$result = [];
|
$result = [];
|
||||||
$chartData = [];
|
$chartData = [];
|
||||||
$categoryIds = [];
|
$categoryIds = [];
|
||||||
|
|
||||||
/** @var Transaction $transaction */
|
/** @var Transaction $transaction */
|
||||||
foreach ($transactions as $transaction) {
|
foreach ($transactions as $transaction) {
|
||||||
$jrnlCatId = (int)$transaction->transaction_journal_category_id;
|
$jrnlCatId = (int)$transaction->transaction_journal_category_id;
|
||||||
@@ -286,24 +289,25 @@ class AccountController extends Controller
|
|||||||
$categoryIds[] = $categoryId;
|
$categoryIds[] = $categoryId;
|
||||||
if (!isset($result[$combi])) {
|
if (!isset($result[$combi])) {
|
||||||
$result[$combi] = [
|
$result[$combi] = [
|
||||||
'total' => '0',
|
'total' => '0',
|
||||||
'category_id' => $categoryId,
|
'category_id' => $categoryId,
|
||||||
'currency' => $currencyName,
|
'currency' => $currencyName,
|
||||||
|
'currency_symbol' => $transaction->transaction_currency_symbol,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$result[$combi]['total'] = bcadd($transaction->transaction_amount, $result[$combi]['total']);
|
$result[$combi]['total'] = bcadd($transaction->transaction_amount, $result[$combi]['total']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$names = $this->getCategoryNames(array_keys($result));
|
$names = $this->getCategoryNames($categoryIds);
|
||||||
|
|
||||||
foreach ($result as $row) {
|
foreach ($result as $row) {
|
||||||
$categoryId = $row['category_id'];
|
$categoryId = $row['category_id'];
|
||||||
$name = $names[$categoryId] ?? '(unknown)';
|
$name = $names[$categoryId] ?? '(unknown)';
|
||||||
$label = (string)trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency']]);
|
$label = (string)trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency']]);
|
||||||
$chartData[$label] = $row['total'];
|
$chartData[$label] = ['amount' => $row['total'], 'currency_symbol' => $row['currency_symbol']];
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->generator->pieChart($chartData);
|
$data = $this->generator->multiCurrencyPieChart($chartData);
|
||||||
$cache->store($data);
|
$cache->store($data);
|
||||||
|
|
||||||
return response()->json($data);
|
return response()->json($data);
|
||||||
@@ -371,7 +375,7 @@ class AccountController extends Controller
|
|||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
$cache->addProperty('chart.account.income-category');
|
$cache->addProperty('chart.account.income-category');
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
//return response()->json($cache->get()); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
// grab all journals:
|
// grab all journals:
|
||||||
@@ -381,6 +385,7 @@ class AccountController extends Controller
|
|||||||
$transactions = $collector->getTransactions();
|
$transactions = $collector->getTransactions();
|
||||||
$result = [];
|
$result = [];
|
||||||
$chartData = [];
|
$chartData = [];
|
||||||
|
$categoryIds = [];
|
||||||
/** @var Transaction $transaction */
|
/** @var Transaction $transaction */
|
||||||
foreach ($transactions as $transaction) {
|
foreach ($transactions as $transaction) {
|
||||||
$jrnlCatId = (int)$transaction->transaction_journal_category_id;
|
$jrnlCatId = (int)$transaction->transaction_journal_category_id;
|
||||||
@@ -391,22 +396,23 @@ class AccountController extends Controller
|
|||||||
$categoryIds[] = $categoryId;
|
$categoryIds[] = $categoryId;
|
||||||
if (!isset($result[$combi])) {
|
if (!isset($result[$combi])) {
|
||||||
$result[$combi] = [
|
$result[$combi] = [
|
||||||
'total' => '0',
|
'total' => '0',
|
||||||
'category_id' => $categoryId,
|
'category_id' => $categoryId,
|
||||||
'currency' => $currencyName,
|
'currency' => $currencyName,
|
||||||
|
'currency_symbol' => $transaction->transaction_currency_symbol,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$result[$combi]['total'] = bcadd($transaction->transaction_amount, $result[$combi]['total']);
|
$result[$combi]['total'] = bcadd($transaction->transaction_amount, $result[$combi]['total']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$names = $this->getCategoryNames(array_keys($result));
|
$names = $this->getCategoryNames($categoryIds);
|
||||||
foreach ($result as $row) {
|
foreach ($result as $row) {
|
||||||
$categoryId = $row['category_id'];
|
$categoryId = $row['category_id'];
|
||||||
$name = $names[$categoryId] ?? '(unknown)';
|
$name = $names[$categoryId] ?? '(unknown)';
|
||||||
$label = (string)trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency']]);
|
$label = (string)trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency']]);
|
||||||
$chartData[$label] = $row['total'];
|
$chartData[$label] = ['amount' => $row['total'], 'currency_symbol' => $row['currency_symbol']];
|
||||||
}
|
}
|
||||||
$data = $this->generator->pieChart($chartData);
|
$data = $this->generator->multiCurrencyPieChart($chartData);
|
||||||
$cache->store($data);
|
$cache->store($data);
|
||||||
|
|
||||||
return response()->json($data);
|
return response()->json($data);
|
||||||
|
6
public/js/ff/accounts/show.js
vendored
6
public/js/ff/accounts/show.js
vendored
@@ -35,9 +35,9 @@ $(function () {
|
|||||||
"use strict";
|
"use strict";
|
||||||
lineChart(chartUri, 'overview-chart');
|
lineChart(chartUri, 'overview-chart');
|
||||||
if (!showAll) {
|
if (!showAll) {
|
||||||
neutralPieChart(incomeCategoryUri, 'account-cat-in');
|
multiCurrencyPieChart(incomeCategoryUri, 'account-cat-in');
|
||||||
neutralPieChart(expenseCategoryUri, 'account-cat-out');
|
multiCurrencyPieChart(expenseCategoryUri, 'account-cat-out');
|
||||||
neutralPieChart(expenseBudgetUri, 'account-budget-out');
|
multiCurrencyPieChart(expenseBudgetUri, 'account-budget-out');
|
||||||
}
|
}
|
||||||
|
|
||||||
// sortable!
|
// sortable!
|
||||||
|
Reference in New Issue
Block a user