mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-23 04:46:44 +00:00
Fix array bug.
This commit is contained in:
@@ -93,6 +93,8 @@ class IndexController extends Controller
|
|||||||
$endBalances = app('steam')->finalAccountsBalance($accounts, $end);
|
$endBalances = app('steam')->finalAccountsBalance($accounts, $end);
|
||||||
$activities = app('steam')->getLastActivities($ids);
|
$activities = app('steam')->getLastActivities($ids);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$accounts->each(
|
$accounts->each(
|
||||||
function (Account $account) use ($activities, $startBalances, $endBalances): void {
|
function (Account $account) use ($activities, $startBalances, $endBalances): void {
|
||||||
$account->lastActivityDate = $this->isInArrayDate($activities, $account->id);
|
$account->lastActivityDate = $this->isInArrayDate($activities, $account->id);
|
||||||
@@ -152,7 +154,6 @@ class IndexController extends Controller
|
|||||||
$startBalances = app('steam')->finalAccountsBalance($accounts, $start);
|
$startBalances = app('steam')->finalAccountsBalance($accounts, $start);
|
||||||
$endBalances = app('steam')->finalAccountsBalance($accounts, $end);
|
$endBalances = app('steam')->finalAccountsBalance($accounts, $end);
|
||||||
$activities = app('steam')->getLastActivities($ids);
|
$activities = app('steam')->getLastActivities($ids);
|
||||||
|
|
||||||
$accounts->each(
|
$accounts->each(
|
||||||
function (Account $account) use ($activities, $startBalances, $endBalances): void {
|
function (Account $account) use ($activities, $startBalances, $endBalances): void {
|
||||||
$interest = (string) $this->repository->getMetaValue($account, 'interest');
|
$interest = (string) $this->repository->getMetaValue($account, 'interest');
|
||||||
|
@@ -114,7 +114,9 @@ class AccountController extends Controller
|
|||||||
$accountId = (int) $accountId;
|
$accountId = (int) $accountId;
|
||||||
// loop each expense entry (each entry can be a different currency).
|
// loop each expense entry (each entry can be a different currency).
|
||||||
foreach ($expenses as $currencyCode => $endAmount) {
|
foreach ($expenses as $currencyCode => $endAmount) {
|
||||||
|
if(3 !== strlen($currencyCode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// see if there is an accompanying start amount.
|
// see if there is an accompanying start amount.
|
||||||
// grab the difference and find the currency.
|
// grab the difference and find the currency.
|
||||||
$startAmount = (string) ($startBalances[$accountId][$currencyCode] ?? '0');
|
$startAmount = (string) ($startBalances[$accountId][$currencyCode] ?? '0');
|
||||||
@@ -514,6 +516,9 @@ class AccountController extends Controller
|
|||||||
$accountId = (int) $accountId;
|
$accountId = (int) $accountId;
|
||||||
// loop each expense entry (each entry can be a different currency).
|
// loop each expense entry (each entry can be a different currency).
|
||||||
foreach ($expenses as $currencyCode => $endAmount) {
|
foreach ($expenses as $currencyCode => $endAmount) {
|
||||||
|
if(3 !== strlen($currencyCode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// see if there is an accompanying start amount.
|
// see if there is an accompanying start amount.
|
||||||
// grab the difference and find the currency.
|
// grab the difference and find the currency.
|
||||||
|
@@ -46,6 +46,6 @@ trait BasicDataSupport
|
|||||||
*/
|
*/
|
||||||
protected function isInArrayDate(array $array, int $entryId): ?Carbon
|
protected function isInArrayDate(array $array, int $entryId): ?Carbon
|
||||||
{
|
{
|
||||||
return $array[$entryId]['balance'] ?? null;
|
return $array[$entryId] ?? null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -282,10 +282,10 @@ class Steam
|
|||||||
->where('transactions.transaction_currency_id', $currency->id)
|
->where('transactions.transaction_currency_id', $currency->id)
|
||||||
->get(['transactions.amount'])->toArray();
|
->get(['transactions.amount'])->toArray();
|
||||||
$return['balance'] = $this->sumTransactions($array, 'amount');
|
$return['balance'] = $this->sumTransactions($array, 'amount');
|
||||||
Log::debug(sprintf('balance is %s', $return['balance']));
|
//Log::debug(sprintf('balance is %s', $return['balance']));
|
||||||
// add virtual balance:
|
// add virtual balance:
|
||||||
$return['balance'] = bcadd('' === (string) $account->virtual_balance ? '0' : $account->virtual_balance, $return['balance']);
|
$return['balance'] = bcadd('' === (string) $account->virtual_balance ? '0' : $account->virtual_balance, $return['balance']);
|
||||||
Log::debug(sprintf('balance is %s (with virtual balance)', $return['balance']));
|
//Log::debug(sprintf('balance is %s (with virtual balance)', $return['balance']));
|
||||||
|
|
||||||
// then, native balance (if necessary(
|
// then, native balance (if necessary(
|
||||||
if ($native->id !== $currency->id) {
|
if ($native->id !== $currency->id) {
|
||||||
@@ -294,9 +294,9 @@ class Steam
|
|||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d H:i:s'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d H:i:s'))
|
||||||
->get(['transactions.native_amount'])->toArray();
|
->get(['transactions.native_amount'])->toArray();
|
||||||
$return['native_balance'] = $this->sumTransactions($array, 'native_amount');
|
$return['native_balance'] = $this->sumTransactions($array, 'native_amount');
|
||||||
Log::debug(sprintf('native_balance is %s', $return['native_balance']));
|
// Log::debug(sprintf('native_balance is %s', $return['native_balance']));
|
||||||
$return['native_balance'] = bcadd('' === (string) $account->native_virtual_balance ? '0' : $account->native_virtual_balance, $return['balance']);
|
$return['native_balance'] = bcadd('' === (string) $account->native_virtual_balance ? '0' : $account->native_virtual_balance, $return['balance']);
|
||||||
Log::debug(sprintf('native_balance is %s (with virtual balance)', $return['native_balance']));
|
// Log::debug(sprintf('native_balance is %s (with virtual balance)', $return['native_balance']));
|
||||||
}
|
}
|
||||||
|
|
||||||
// balance(s) in other currencies.
|
// balance(s) in other currencies.
|
||||||
@@ -306,7 +306,7 @@ class Steam
|
|||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d H:i:s'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d H:i:s'))
|
||||||
->get(['transaction_currencies.code', 'transactions.amount'])->toArray();
|
->get(['transaction_currencies.code', 'transactions.amount'])->toArray();
|
||||||
$others = $this->groupAndSumTransactions($array, 'code', 'amount');
|
$others = $this->groupAndSumTransactions($array, 'code', 'amount');
|
||||||
Log::debug('All others are (joined)', $others);
|
// Log::debug('All others are (joined)', $others);
|
||||||
return array_merge($return, $others);
|
return array_merge($return, $others);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,7 +356,7 @@ class Steam
|
|||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
$date = new Carbon($entry->max_date, config('app.timezone'));
|
$date = new Carbon($entry->max_date, config('app.timezone'));
|
||||||
$date->setTimezone(config('app.timezone'));
|
$date->setTimezone(config('app.timezone'));
|
||||||
$list[$entry->account_id] = $date;
|
$list[(int)$entry->account_id] = $date;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $list;
|
return $list;
|
||||||
|
Reference in New Issue
Block a user