Replace native with primary where possible

This commit is contained in:
Sander Dorigo
2025-08-01 12:31:01 +02:00
parent 65dcad6898
commit 6278662014
59 changed files with 430 additions and 430 deletions

View File

@@ -182,7 +182,7 @@ trait AugumentData
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty($budget->id);
$cache->addProperty($this->convertToNative);
$cache->addProperty($this->convertToPrimary);
$cache->addProperty('get-limits');
if ($cache->has()) {
@@ -193,14 +193,14 @@ trait AugumentData
$budgetCollection = new Collection([$budget]);
// merge sets based on a key, in case of convert to native
// merge sets based on a key, in case of convert to primary currency
$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) {
if ($this->convertToPrimary) {
// the sumExpenses method already handles this.
$currency = $this->defaultCurrency;
}
@@ -213,10 +213,10 @@ trait AugumentData
$currentEnd = clone $currentStart;
$currentEnd->addMonth();
}
// native amount.
$expenses = $opsRepository->sumExpenses($currentStart, $currentEnd, null, $budgetCollection, $entry->transactionCurrency, $this->convertToNative);
// primary currency amount.
$expenses = $opsRepository->sumExpenses($currentStart, $currentEnd, null, $budgetCollection, $entry->transactionCurrency, $this->convertToPrimary);
$spent = $expenses[$currency->id]['sum'] ?? '0';
$entry->native_spent = $spent;
$entry->pc_spent = $spent;
// normal amount:
$expenses = $opsRepository->sumExpenses($currentStart, $currentEnd, null, $budgetCollection, $entry->transactionCurrency, false);