Chart no longer as a line chart.

This commit is contained in:
James Cole
2024-12-23 07:13:59 +01:00
parent 3c65b46aa5
commit 25a56d9f72

View File

@@ -102,7 +102,7 @@ class AccountController extends Controller
$tempData = [];
// grab all accounts and names
$accounts = $this->accountRepository->getAccountsByType([AccountType::EXPENSE]);
$accounts = $this->accountRepository->getAccountsByType([AccountTypeEnum::EXPENSE->value]);
$accountNames = $this->extractNames($accounts);
// grab all balances
@@ -133,6 +133,14 @@ class AccountController extends Controller
}
}
}
// recreate currencies, but on ID instead of code.
$newCurrencies = [];
foreach($currencies as $currency) {
$newCurrencies[$currency->id] = $currency;
}
$currencies = $newCurrencies;
// sort temp array by amount.
$amounts = array_column($tempData, 'diff_float');
@@ -159,7 +167,7 @@ class AccountController extends Controller
foreach ($tempData as $entry) {
$currencyId = $entry['currency_id'];
$name = $entry['name'];
$chartData[$currencyId]['entries'][$name] = $entry['difference'];
$chartData[$currencyId]['entries'][$name] = (float) $entry['difference'];
}
$data = $this->generator->multiSet($chartData);
@@ -511,6 +519,8 @@ class AccountController extends Controller
$startBalances = app('steam')->finalAccountsBalance($accounts, $start);
$endBalances = app('steam')->finalAccountsBalance($accounts, $end);
// loop the end balances. This is an array for each account ($expenses)
foreach ($endBalances as $accountId => $expenses) {
$accountId = (int) $accountId;
@@ -537,6 +547,13 @@ class AccountController extends Controller
}
}
// recreate currencies, but on ID instead of code.
$newCurrencies = [];
foreach($currencies as $currency) {
$newCurrencies[$currency->id] = $currency;
}
$currencies = $newCurrencies;
// sort temp array by amount.
$amounts = array_column($tempData, 'diff_float');
array_multisort($amounts, SORT_ASC, $tempData);