Expand some multi currency things.

This commit is contained in:
James Cole
2024-12-27 16:36:01 +01:00
parent 96493425d1
commit 3d49d81856
7 changed files with 199 additions and 160 deletions

View File

@@ -179,22 +179,26 @@ trait AugumentData
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty($budget->id);
$cache->addProperty($this->convertToNative);
$cache->addProperty('get-limits');
if ($cache->has()) {
return $cache->get();
// return $cache->get();
}
$set = $blRepository->getBudgetLimits($budget, $start, $end);
$limits = new Collection();
$budgetCollection = new Collection([$budget]);
// merge sets based on a key, in case of convert to native
$limits = new Collection();
/** @var BudgetLimit $entry */
foreach ($set as $entry) {
$currency = $entry->transactionCurrency;
if (null === $currency) {
$currency = app('amount')->getDefaultCurrency();
if($this->convertToNative) {
// the sumExpenses method already handles this.
$currency = $this->defaultCurrency;
}
// clone because these objects change each other.
@@ -214,7 +218,7 @@ trait AugumentData
}
$cache->store($limits);
return $set;
return $limits;
}
/**