Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Remove loggin.
James Cole04d59bf5fb5e
diff --git a/app/Support/Steam.php b/app/Support/Steam.phpindex 12f54b1cdc..5022809f1a 100644--- a/app/Support/Steam.php+++ b/app/Support/Steam.php@@ -159,19 +159,19 @@ class Steam// $return['pc_balance'] = bcadd($pcVirtualBalance, $return['pc_balance']);$sumsByCode[$primary->code] = bcadd($pcVirtualBalance, $sumsByCode[$primary->code] ?? '0');- Log::debug(sprintf('Primary virtual balance (%s) makes the primary total %s', $pcVirtualBalance, $sumsByCode[$primary->code]));+// Log::debug(sprintf('Primary virtual balance (%s) makes the primary total %s', $pcVirtualBalance, $sumsByCode[$primary->code]));}if (!$convertToPrimary) {// if not, also increase the balance + primary balance for consistency.// $return['balance'] = bcadd($return['balance'], $virtualBalance);$sumsByCode[$currency->code] = bcadd($virtualBalance, $sumsByCode[$currency->code] ?? '0');- Log::debug(sprintf('Virtual balance (%s) makes the (primary currency) total %s', $virtualBalance, $sumsByCode[$currency->code]));+// Log::debug(sprintf('Virtual balance (%s) makes the (primary currency) total %s', $virtualBalance, $sumsByCode[$currency->code]));}$final = array_merge($return, $sumsByCode);$result[$account->id] = $final;- Log::debug(sprintf('Final balance for account #%d is', $account->id), $final);+// Log::debug(sprintf('Final balance for account #%d is', $account->id), $final);}return $result;@@ -220,7 +220,7 @@ class Steampublic function filterAccountBalance(array $set, Account $account, bool $convertToPrimary, ?TransactionCurrency $currency = null): array{- Log::debug(sprintf('filterAccountBalance(#%d)', $account->id), $set);+// Log::debug(sprintf('filterAccountBalance(#%d)', $account->id), $set);if (0 === count($set)) {Log::debug(sprintf('Return empty array for account #%d', $account->id));@@ -229,30 +229,30 @@ class Steam$primaryCurrency = Amount::getPrimaryCurrency();if ($convertToPrimary) {if ($primaryCurrency->id === $currency?->id) {- Log::debug(sprintf('Unset [%s] for account #%d (no longer unset "pc_balance")', $primaryCurrency->code, $account->id));+// Log::debug(sprintf('Unset [%s] for account #%d (no longer unset "pc_balance")', $primaryCurrency->code, $account->id));unset($set[$primaryCurrency->code]);}// todo rethink this logic.if ($currency instanceof TransactionCurrency && $primaryCurrency->id !== $currency->id) {- Log::debug(sprintf('Unset balance for account #%d', $account->id));+// Log::debug(sprintf('Unset balance for account #%d', $account->id));unset($set['balance']);}if (!$currency instanceof TransactionCurrency) {- Log::debug(sprintf('Unset balance for account #%d', $account->id));+// Log::debug(sprintf('Unset balance for account #%d', $account->id));unset($set['balance']);}}if (!$convertToPrimary) {if (!$currency instanceof TransactionCurrency) {- Log::debug(sprintf('Unset pc_balance and make primaryCurrency balance the balance for account #%d', $account->id));+// Log::debug(sprintf('Unset pc_balance and make primaryCurrency balance the balance for account #%d', $account->id));$set['balance'] = $set[$primaryCurrency->code] ?? '0';unset($set[$primaryCurrency->code]);}if ($currency instanceof TransactionCurrency) {- Log::debug(sprintf('Unset [%s] + [%s] balance for account #%d', $primaryCurrency->code, $currency->code, $account->id));+// Log::debug(sprintf('Unset [%s] + [%s] balance for account #%d', $primaryCurrency->code, $currency->code, $account->id));unset($set[$primaryCurrency->code], $set[$currency->code]);}}@@ -264,19 +264,19 @@ class Steamif (array_key_exists('balance', $set)) {$set = ['balance' => $set['balance']] + $set;}- Log::debug(sprintf('Return #%d', $account->id), $set);+// Log::debug(sprintf('Return #%d', $account->id), $set);return $set;}public function filterAccountBalances(array $total, Account $account, bool $convertToPrimary, ?TransactionCurrency $currency = null): array{- Log::debug(sprintf('filterAccountBalances(#%d)', $account->id));+// Log::debug(sprintf('filterAccountBalances(#%d)', $account->id));$return = [];foreach ($total as $key => $value) {$return[$key] = $this->filterAccountBalance($value, $account, $convertToPrimary, $currency);}- Log::debug(sprintf('end of filterAccountBalances(#%d)', $account->id));+// Log::debug(sprintf('end of filterAccountBalances(#%d)', $account->id));return $return;}@@ -366,11 +366,11 @@ class Steam$cache->addProperty($account->id);$cache->addProperty($date);if ($cache->has()) {- Log::debug(sprintf('CACHED finalAccountBalance(#%d, %s, inclusive:%s)', $account->id, $date->format('Y-m-d H:i:s'), var_export($inclusive, true)));+// Log::debug(sprintf('CACHED finalAccountBalance(#%d, %s, inclusive:%s)', $account->id, $date->format('Y-m-d H:i:s'), var_export($inclusive, true)));return $cache->get();}- Log::debug(sprintf('finalAccountBalance(#%d, %s)', $account->id, $date->format('Y-m-d H:i:s')));+// Log::debug(sprintf('finalAccountBalance(#%d, %s)', $account->id, $date->format('Y-m-d H:i:s')));if (null === $convertToPrimary) {$convertToPrimary = Amount::convertToPrimary($account->user);}@@ -398,7 +398,7 @@ class Steam->toArray();$others = $this->groupAndSumTransactions($array, 'code', 'amount');- Log::debug('All balances are (joined)', $others);+// Log::debug('All balances are (joined)', $others);// if there is no request to convert, take this as "balance" and "pc_balance".$return['balance'] = $others[$currency->code] ?? '0';if (!$convertToPrimary) {@@ -431,7 +431,7 @@ class Steam// Log::debug(sprintf('Virtual balance makes the (primary currency) total %s', $return['balance']));}$final = array_merge($return, $others);- Log::debug('Final balance is', $final);+// Log::debug('Final balance is', $final);$cache->store($final);return $final;@@ -445,7 +445,7 @@ class Steam// expand period.$start->startOfDay();$end->endOfDay();- Log::debug(sprintf('called finalAccountBalanceInRange(#%d, %s, %s)', $account->id, $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));+// Log::debug(sprintf('called finalAccountBalanceInRange(#%d, %s, %s)', $account->id, $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));// set up cache$cache = new CacheProperties();@@ -455,56 +455,56 @@ class Steam$cache->addProperty($convertToPrimary);$cache->addProperty($end);if ($cache->has()) {- Log::debug('Return cached finalAccountBalanceInRange');+// Log::debug('Return cached finalAccountBalanceInRange');return $cache->get();}$balances = [];$formatted = $start->format('Y-m-d');- Log::debug('Get first balance to start.');+// Log::debug('Get first balance to start.');// 2025-10-08 replaced finalAccountBalance with accountsBalancesOptimized:$primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);$startBalance = $this->accountsBalancesOptimized(new Collection()->push($account), $start, $primaryCurrency, $convertToPrimary, false)[$account->id];$accountCurrency = $this->getAccountCurrency($account);$hasCurrency = $accountCurrency instanceof TransactionCurrency;$currency = $accountCurrency ?? $primaryCurrency;- Log::debug(sprintf('Currency is %s', $currency->code));+// Log::debug(sprintf('Currency is %s', $currency->code));// set start balances:if (!array_key_exists($currency->code, $startBalance)) {// set first balance to 0 or the virtual balance of the account.$startBalance[$currency->code] = (string) ('' === (string) $account->virtual_balance ? '0' : $account->virtual_balance);- Log::debug(sprintf('[a] Start balance in %s is %s', $currency->code, $startBalance[$currency->code]));+// Log::debug(sprintf('[a] Start balance in %s is %s', $currency->code, $startBalance[$currency->code]));}if ($hasCurrency && !array_key_exists($accountCurrency->code, $startBalance)) {$startBalance[$currency->code] = (string) ('' === (string) $account->virtual_balance ? '0' : $account->virtual_balance);- Log::debug(sprintf('[b] Start balance in %s is %s', $currency->code, $startBalance[$currency->code]));+// Log::debug(sprintf('[b] Start balance in %s is %s', $currency->code, $startBalance[$currency->code]));}if ($hasCurrency && !array_key_exists($primaryCurrency->code, $startBalance)) {if ($accountCurrency->id !== $primaryCurrency->id && $convertToPrimary) {$converter = new ExchangeRateConverter();$converted = $converter->convert($accountCurrency, $primaryCurrency, $start, $startBalance[$accountCurrency->code]);$startBalance[$primaryCurrency->code] = $converted;- Log::debug(sprintf('[c] Also set start balance in %s to %s', $primaryCurrency->code, $converted));+// Log::debug(sprintf('[c] Also set start balance in %s to %s', $primaryCurrency->code, $converted));}if ($accountCurrency->id !== $primaryCurrency->id && !$convertToPrimary) {$startBalance[$primaryCurrency->code] = (string) ('' === (string) $account->virtual_balance ? '0' : $account->virtual_balance);- Log::debug(sprintf('[d] Also set start balance in %s to %s', $primaryCurrency->code, $startBalance[$primaryCurrency->code]));+// Log::debug(sprintf('[d] Also set start balance in %s to %s', $primaryCurrency->code, $startBalance[$primaryCurrency->code]));}}if (!$hasCurrency) {- Log::debug(sprintf('[e] Also set start balance in %s', $primaryCurrency->code));+// Log::debug(sprintf('[e] Also set start balance in %s', $primaryCurrency->code));$startBalance[$primaryCurrency->code] = (string) ('' === (string) $account->virtual_balance ? '0' : $account->virtual_balance);}$currencies = [$currency->id => $currency, $primaryCurrency->id => $primaryCurrency];$balances[$formatted] = $startBalance;- Log::debug('Final start balance: ', $startBalance);+// Log::debug('Final start balance: ', $startBalance);// sums up the balance changes per day.- Log::debug(sprintf('Date >= %s and <= %s', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));+// Log::debug(sprintf('Date >= %s and <= %s', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));$set = $account->transactions()->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')@@ -537,7 +537,7 @@ class Steam/** @var TransactionCurrency $entryCurrency */$entryCurrency = $currencies[$entry->transaction_currency_id];- Log::debug(sprintf('Processing transaction(s) on moment %s', $carbon->format('Y-m-d H:i:s')));+// Log::debug(sprintf('Processing transaction(s) on moment %s', $carbon->format('Y-m-d H:i:s')));// add amount to current balance in currency code.$currentBalance[$entryCurrency->code] ??= '0';@@ -559,10 +559,10 @@ class Steam}// add to final array.$balances[$carbonKey] = $currentBalance;- Log::debug(sprintf('Updated entry [%s]', $carbonKey), $currentBalance);+// Log::debug(sprintf('Updated entry [%s]', $carbonKey), $currentBalance);}$cache->store($balances);- Log::debug('End of method finalAccountBalanceInRange');+// Log::debug('End of method finalAccountBalanceInRange');return $balances;}@@ -579,7 +579,7 @@ class Steamif (!str_contains($value, 'E')) {return $value;}- Log::debug(sprintf('Floatalizing %s', $value));+// Log::debug(sprintf('Floatalizing %s', $value));$number = substr($value, 0, (int) strpos($value, 'E'));if (str_contains($number, '.')) {@@ -759,7 +759,7 @@ class Steampublic function getSafePreviousUrl(): string{$res = $this->getSafeUrl(session()->previousUrl() ?? route('index'), route('index'));- Log::debug(sprintf('getSafePreviousUrl: "%s"', $res));+// Log::debug(sprintf('getSafePreviousUrl: "%s"', $res));return $res;}@@ -892,7 +892,7 @@ class Steam$current = $amount;if ($currency->id !== $primary->id) {$current = $converter->convert($currency, $primary, $date, $amount);- Log::debug(sprintf('Convert %s %s to %s %s', $currency->code, $amount, $primary->code, $current));+// Log::debug(sprintf('Convert %s %s to %s %s', $currency->code, $amount, $primary->code, $current));}$total = bcadd((string) $current, $total);}