Fix array bug.

This commit is contained in:
James Cole
2024-12-23 06:55:14 +01:00
parent d90ac519f7
commit 1cf9c76329
4 changed files with 15 additions and 9 deletions

View File

@@ -282,10 +282,10 @@ class Steam
->where('transactions.transaction_currency_id', $currency->id)
->get(['transactions.amount'])->toArray();
$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:
$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(
if ($native->id !== $currency->id) {
@@ -294,9 +294,9 @@ class Steam
->where('transaction_journals.date', '<=', $date->format('Y-m-d H:i:s'))
->get(['transactions.native_amount'])->toArray();
$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']);
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.
@@ -306,7 +306,7 @@ class Steam
->where('transaction_journals.date', '<=', $date->format('Y-m-d H:i:s'))
->get(['transaction_currencies.code', 'transactions.amount'])->toArray();
$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);
}
@@ -356,7 +356,7 @@ class Steam
foreach ($set as $entry) {
$date = new Carbon($entry->max_date, config('app.timezone'));
$date->setTimezone(config('app.timezone'));
$list[$entry->account_id] = $date;
$list[(int)$entry->account_id] = $date;
}
return $list;