Add comments about floats

This commit is contained in:
James Cole
2022-10-16 14:44:11 +02:00
parent 39654249e4
commit e472c3520d
12 changed files with 36 additions and 32 deletions

View File

@@ -76,7 +76,7 @@ class NetWorth implements NetWorthInterface
$netWorth = [];
$result = [];
//Log::debug(sprintf('Now in getNetWorthByCurrency(%s)', $date->format('Y-m-d')));
Log::debug(sprintf('Now in getNetWorthByCurrency(%s)', $date->format('Y-m-d')));
// get default currency
$default = app('amount')->getDefaultCurrencyByUser($this->user);
@@ -87,16 +87,16 @@ class NetWorth implements NetWorthInterface
// get the preferred currency for this account
/** @var Account $account */
foreach ($accounts as $account) {
//Log::debug(sprintf('Now at account #%d: "%s"', $account->id, $account->name));
Log::debug(sprintf('Now at account #%d: "%s"', $account->id, $account->name));
$currencyId = (int) $this->accountRepository->getMetaValue($account, 'currency_id');
$currencyId = 0 === $currencyId ? $default->id : $currencyId;
//Log::debug(sprintf('Currency ID is #%d', $currencyId));
Log::debug(sprintf('Currency ID is #%d', $currencyId));
// balance in array:
$balance = $balances[$account->id] ?? '0';
//Log::debug(sprintf('Balance is %s', $balance));
Log::debug(sprintf('Balance for %s is %s', $date->format('Y-m-d'), $balance));
// always subtract virtual balance.
$virtualBalance = (string) $account->virtual_balance;
@@ -104,14 +104,14 @@ class NetWorth implements NetWorthInterface
$balance = bcsub($balance, $virtualBalance);
}
//Log::debug(sprintf('Balance corrected to %s because of virtual balance (%s)', $balance, $virtualBalance));
Log::debug(sprintf('Balance corrected to %s because of virtual balance (%s)', $balance, $virtualBalance));
if (!array_key_exists($currencyId, $netWorth)) {
$netWorth[$currencyId] = '0';
}
$netWorth[$currencyId] = bcadd($balance, $netWorth[$currencyId]);
//Log::debug(sprintf('Total net worth for currency #%d is %s', $currencyId, $netWorth[$currencyId]));
Log::debug(sprintf('Total net worth for currency #%d is %s', $currencyId, $netWorth[$currencyId]));
}
ksort($netWorth);