Rename "native" to "primary".

This commit is contained in:
James Cole
2025-08-01 06:12:36 +02:00
parent ea6addafe6
commit 084ce02c21
51 changed files with 296 additions and 296 deletions

View File

@@ -68,7 +68,7 @@ class BoxController extends Controller
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty($this->convertToNative);
$cache->addProperty($this->convertToPrimary);
$cache->addProperty('box-balance');
if ($cache->has()) {
return response()->json($cache->get());
@@ -77,7 +77,7 @@ class BoxController extends Controller
$incomes = [];
$expenses = [];
$sums = [];
$currency = $this->defaultCurrency;
$currency = $this->primaryCurrency;
// collect income of user:
/** @var GroupCollectorInterface $collector */
@@ -89,7 +89,7 @@ class BoxController extends Controller
/** @var array $journal */
foreach ($set as $journal) {
$currencyId = $this->convertToNative && $this->defaultCurrency->id !== (int) $journal['currency_id'] ? $this->defaultCurrency->id : (int) $journal['currency_id'];
$currencyId = $this->convertToPrimary && $this->primaryCurrency->id !== (int) $journal['currency_id'] ? $this->primaryCurrency->id : (int) $journal['currency_id'];
$amount = Amount::getAmountFromJournal($journal);
$incomes[$currencyId] ??= '0';
$incomes[$currencyId] = bcadd($incomes[$currencyId], (string) app('steam')->positive($amount));
@@ -107,7 +107,7 @@ class BoxController extends Controller
/** @var array $journal */
foreach ($set as $journal) {
$currencyId = $this->convertToNative ? $this->defaultCurrency->id : (int) $journal['currency_id'];
$currencyId = $this->convertToPrimary ? $this->primaryCurrency->id : (int) $journal['currency_id'];
$amount = Amount::getAmountFromJournal($journal);
$expenses[$currencyId] ??= '0';
$expenses[$currencyId] = bcadd($expenses[$currencyId], $amount);
@@ -124,10 +124,10 @@ class BoxController extends Controller
$expenses[$currencyId] = app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false);
}
if (0 === count($sums)) {
$currency = $this->defaultCurrency;
$sums[$this->defaultCurrency->id] = app('amount')->formatAnything($this->defaultCurrency, '0', false);
$incomes[$this->defaultCurrency->id] = app('amount')->formatAnything($this->defaultCurrency, '0', false);
$expenses[$this->defaultCurrency->id] = app('amount')->formatAnything($this->defaultCurrency, '0', false);
$currency = $this->primaryCurrency;
$sums[$this->primaryCurrency->id] = app('amount')->formatAnything($this->primaryCurrency, '0', false);
$incomes[$this->primaryCurrency->id] = app('amount')->formatAnything($this->primaryCurrency, '0', false);
$expenses[$this->primaryCurrency->id] = app('amount')->formatAnything($this->primaryCurrency, '0', false);
}
$response = [
@@ -182,7 +182,7 @@ class BoxController extends Controller
$netWorthSet = $netWorthHelper->byAccounts($filtered, $date);
$return = [];
foreach ($netWorthSet as $key => $data) {
if ('native' === $key) {
if ('primary' === $key) {
continue;
}
$return[$data['currency_id']] = app('amount')->formatFlat($data['currency_symbol'], $data['currency_decimal_places'], $data['balance'], false);