mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Fix #10114
This commit is contained in:
@@ -38,6 +38,7 @@ use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Trait AugumentData
|
||||
@@ -167,6 +168,7 @@ trait AugumentData
|
||||
*/
|
||||
protected function getLimits(Budget $budget, Carbon $start, Carbon $end): Collection // get data + augment with info
|
||||
{
|
||||
Log::debug('In getLimits');
|
||||
/** @var OperationsRepositoryInterface $opsRepository */
|
||||
$opsRepository = app(OperationsRepositoryInterface::class);
|
||||
|
||||
@@ -183,7 +185,7 @@ trait AugumentData
|
||||
$cache->addProperty('get-limits');
|
||||
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
return $cache->get();
|
||||
}
|
||||
|
||||
$set = $blRepository->getBudgetLimits($budget, $start, $end);
|
||||
@@ -192,13 +194,13 @@ trait AugumentData
|
||||
|
||||
// merge sets based on a key, in case of convert to native
|
||||
$limits = new Collection();
|
||||
|
||||
/** @var BudgetLimit $entry */
|
||||
foreach ($set as $entry) {
|
||||
Log::debug(sprintf('Now at budget limit #%d', $entry->id));
|
||||
$currency = $entry->transactionCurrency;
|
||||
if ($this->convertToNative) {
|
||||
// the sumExpenses method already handles this.
|
||||
$currency = $this->defaultCurrency;
|
||||
$currency = $this->defaultCurrency;
|
||||
}
|
||||
|
||||
// clone because these objects change each other.
|
||||
@@ -209,9 +211,14 @@ trait AugumentData
|
||||
$currentEnd = clone $currentStart;
|
||||
$currentEnd->addMonth();
|
||||
}
|
||||
|
||||
$expenses = $opsRepository->sumExpenses($currentStart, $currentEnd, null, $budgetCollection, $currency);
|
||||
// native amount.
|
||||
$expenses = $opsRepository->sumExpenses($currentStart, $currentEnd, null, $budgetCollection, $entry->transactionCurrency, $this->convertToNative);
|
||||
$spent = $expenses[$currency->id]['sum'] ?? '0';
|
||||
$entry->native_spent = $spent;
|
||||
|
||||
// normal amount:
|
||||
$expenses = $opsRepository->sumExpenses($currentStart, $currentEnd, null, $budgetCollection, $entry->transactionCurrency, false);
|
||||
$spent = $expenses[$entry->transactionCurrency->id]['sum'] ?? '0';
|
||||
$entry->spent = $spent;
|
||||
|
||||
$limits->push($entry);
|
||||
|
Reference in New Issue
Block a user