mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-10 14:44:26 +00:00
Merge branch 'develop' into codearena/agent-a-6398119d-1759907698909
This commit is contained in:
@@ -374,14 +374,14 @@ class Steam
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* Returns the balance for the given account in the range, with daily precision.
|
||||||
*/
|
*/
|
||||||
public function finalAccountBalanceInRange(Account $account, Carbon $start, Carbon $end, bool $convertToPrimary): array
|
public function finalAccountBalanceInRange(Account $account, Carbon $start, Carbon $end, bool $convertToPrimary): array
|
||||||
{
|
{
|
||||||
// expand period.
|
// expand period.
|
||||||
$start->startOfDay();
|
$start->startOfDay();
|
||||||
$end->endOfDay();
|
$end->endOfDay();
|
||||||
Log::debug(sprintf('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
|
// set up cache
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
@@ -391,28 +391,21 @@ class Steam
|
|||||||
$cache->addProperty($convertToPrimary);
|
$cache->addProperty($convertToPrimary);
|
||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return $cache->get();
|
Log::debug('Return cached finalAccountBalanceInRange');
|
||||||
|
// return $cache->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
$balances = [];
|
$balances = [];
|
||||||
$formatted = $start->format('Y-m-d');
|
$formatted = $start->format('Y-m-d');
|
||||||
/*
|
|
||||||
* To make sure the start balance is correct, we need to get the balance at the exact end of the previous day.
|
|
||||||
* Since we just did "startOfDay" we can do subDay()->endOfDay() to get the correct moment.
|
|
||||||
* THAT will be the start balance.
|
|
||||||
*/
|
|
||||||
$request = clone $start;
|
|
||||||
$request->subDay()->endOfDay();
|
|
||||||
Log::debug('Get first balance to start.');
|
Log::debug('Get first balance to start.');
|
||||||
Log::debug(sprintf('finalAccountBalanceInRange: Call finalAccountBalance with date/time "%s"', $request->toIso8601String()));
|
// 2025-10-08 replaced finalAccountBalance with accountsBalancesOptimized:
|
||||||
$startBalance = $this->finalAccountBalance($account, $request);
|
|
||||||
$primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
$primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||||
|
$startBalance = $this->accountsBalancesOptimized(new Collection()->push($account), $start, $primaryCurrency, $convertToPrimary, false)[$account->id];
|
||||||
$accountCurrency = $this->getAccountCurrency($account);
|
$accountCurrency = $this->getAccountCurrency($account);
|
||||||
$hasCurrency = $accountCurrency instanceof TransactionCurrency;
|
$hasCurrency = $accountCurrency instanceof TransactionCurrency;
|
||||||
$currency = $accountCurrency ?? $primaryCurrency;
|
$currency = $accountCurrency ?? $primaryCurrency;
|
||||||
Log::debug(sprintf('Currency is %s', $currency->code));
|
Log::debug(sprintf('Currency is %s', $currency->code));
|
||||||
|
|
||||||
|
|
||||||
// set start balances:
|
// set start balances:
|
||||||
$startBalance[$currency->code] ??= '0';
|
$startBalance[$currency->code] ??= '0';
|
||||||
if ($hasCurrency) {
|
if ($hasCurrency) {
|
||||||
|
Reference in New Issue
Block a user