Rename references to "native".

This commit is contained in:
James Cole
2025-07-31 20:38:57 +02:00
parent 73d2621255
commit d6d9f665c7
17 changed files with 84 additions and 84 deletions

View File

@@ -93,14 +93,14 @@ class AccountController extends Controller
/** @var Account $account */ /** @var Account $account */
foreach ($result as $account) { foreach ($result as $account) {
$nameWithBalance = $account->name; $nameWithBalance = $account->name;
$currency = $this->repository->getAccountCurrency($account) ?? $this->nativeCurrency; $currency = $this->repository->getAccountCurrency($account) ?? $this->primaryCurrency;
$useCurrency = $currency; $useCurrency = $currency;
if (in_array($account->accountType->type, $this->balanceTypes, true)) { if (in_array($account->accountType->type, $this->balanceTypes, true)) {
// this one is correct. // this one is correct.
Log::debug(sprintf('accounts: Call finalAccountBalance with date/time "%s"', $date->toIso8601String())); Log::debug(sprintf('accounts: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
$balance = Steam::finalAccountBalance($account, $date); $balance = Steam::finalAccountBalance($account, $date);
$key = $this->convertToNative && $currency->id !== $this->nativeCurrency->id ? 'native_balance' : 'balance'; $key = $this->convertToPrimary && $currency->id !== $this->primaryCurrency->id ? 'native_balance' : 'balance';
$useCurrency = $this->convertToNative && $currency->id !== $this->nativeCurrency->id ? $this->nativeCurrency : $currency; $useCurrency = $this->convertToPrimary && $currency->id !== $this->primaryCurrency->id ? $this->primaryCurrency : $currency;
$amount = $balance[$key] ?? '0'; $amount = $balance[$key] ?? '0';
$nameWithBalance = sprintf( $nameWithBalance = sprintf(
'%s (%s)', '%s (%s)',

View File

@@ -87,7 +87,7 @@ class AccountController extends Controller
// move date to end of day // move date to end of day
$queryParameters['start']->startOfDay(); $queryParameters['start']->startOfDay();
$queryParameters['end']->endOfDay(); $queryParameters['end']->endOfDay();
Log::debug(sprintf('dashboard(), convert to native: %s', var_export($this->convertToNative, true))); Log::debug(sprintf('dashboard(), convert to native: %s', var_export($this->convertToPrimary, true)));
// loop each account, and collect info: // loop each account, and collect info:
/** @var Account $account */ /** @var Account $account */
@@ -107,7 +107,7 @@ class AccountController extends Controller
Log::debug(sprintf('Now in %s(array, #%d)', __METHOD__, $account->id)); Log::debug(sprintf('Now in %s(array, #%d)', __METHOD__, $account->id));
$currency = $this->repository->getAccountCurrency($account); $currency = $this->repository->getAccountCurrency($account);
$currentStart = clone $params['start']; $currentStart = clone $params['start'];
$range = Steam::finalAccountBalanceInRange($account, $params['start'], clone $params['end'], $this->convertToNative); $range = Steam::finalAccountBalanceInRange($account, $params['start'], clone $params['end'], $this->convertToPrimary);
$previous = array_values($range)[0]['balance']; $previous = array_values($range)[0]['balance'];
@@ -131,12 +131,12 @@ class AccountController extends Controller
'period' => '1D', 'period' => '1D',
'entries' => [], 'entries' => [],
]; ];
if ($this->convertToNative) { if ($this->convertToPrimary) {
$currentSet['native_entries'] = []; $currentSet['native_entries'] = [];
$currentSet['native_currency_id'] = (string)$this->nativeCurrency->id; $currentSet['native_currency_id'] = (string)$this->primaryCurrency->id;
$currentSet['native_currency_code'] = $this->nativeCurrency->code; $currentSet['native_currency_code'] = $this->primaryCurrency->code;
$currentSet['native_currency_symbol'] = $this->nativeCurrency->symbol; $currentSet['native_currency_symbol'] = $this->primaryCurrency->symbol;
$currentSet['native_currency_decimal_places'] = $this->nativeCurrency->decimal_places; $currentSet['native_currency_decimal_places'] = $this->primaryCurrency->decimal_places;
$nativePrevious = array_values($range)[0]['native_balance']; $nativePrevious = array_values($range)[0]['native_balance'];
} }
@@ -151,7 +151,7 @@ class AccountController extends Controller
// do the same for the native balance, if relevant: // do the same for the native balance, if relevant:
$nativeBalance = null; $nativeBalance = null;
if ($this->convertToNative) { if ($this->convertToPrimary) {
$nativeBalance = array_key_exists($format, $range) ? $range[$format]['native_balance'] : $nativePrevious; $nativeBalance = array_key_exists($format, $range) ? $range[$format]['native_balance'] : $nativePrevious;
$nativePrevious = $nativeBalance; $nativePrevious = $nativeBalance;
$currentSet['native_entries'][$label] = $nativeBalance; $currentSet['native_entries'][$label] = $nativeBalance;
@@ -191,9 +191,9 @@ class AccountController extends Controller
/** @var Account $account */ /** @var Account $account */
foreach ($accounts as $account) { foreach ($accounts as $account) {
Log::debug(sprintf('Rendering chart data for account %s (%d)', $account->name, $account->id)); Log::debug(sprintf('Rendering chart data for account %s (%d)', $account->name, $account->id));
$currency = $this->repository->getAccountCurrency($account) ?? $this->nativeCurrency; $currency = $this->repository->getAccountCurrency($account) ?? $this->primaryCurrency;
$currentStart = clone $start; $currentStart = clone $start;
$range = Steam::finalAccountBalanceInRange($account, $start, clone $end, $this->convertToNative); $range = Steam::finalAccountBalanceInRange($account, $start, clone $end, $this->convertToPrimary);
$previous = array_values($range)[0]['balance']; $previous = array_values($range)[0]['balance'];
$nativePrevious = null; $nativePrevious = null;
$currentSet = [ $currentSet = [
@@ -210,12 +210,12 @@ class AccountController extends Controller
]; ];
// add "native_entries" if convertToNative is true: // add "native_entries" if convertToNative is true:
if ($this->convertToNative) { if ($this->convertToPrimary) {
$currentSet['native_entries'] = []; $currentSet['native_entries'] = [];
$currentSet['native_currency_id'] = (string)$this->nativeCurrency->id; $currentSet['native_currency_id'] = (string)$this->primaryCurrency->id;
$currentSet['native_currency_code'] = $this->nativeCurrency->code; $currentSet['native_currency_code'] = $this->primaryCurrency->code;
$currentSet['native_currency_symbol'] = $this->nativeCurrency->symbol; $currentSet['native_currency_symbol'] = $this->primaryCurrency->symbol;
$currentSet['native_currency_decimal_places'] = $this->nativeCurrency->decimal_places; $currentSet['native_currency_decimal_places'] = $this->primaryCurrency->decimal_places;
$nativePrevious = array_values($range)[0]['native_balance']; $nativePrevious = array_values($range)[0]['native_balance'];
} }
@@ -232,7 +232,7 @@ class AccountController extends Controller
// do the same for the native balance, if relevant: // do the same for the native balance, if relevant:
$nativeBalance = null; $nativeBalance = null;
if ($this->convertToNative) { if ($this->convertToPrimary) {
$nativeBalance = array_key_exists($format, $range) ? $range[$format]['native_balance'] : $nativePrevious; $nativeBalance = array_key_exists($format, $range) ? $range[$format]['native_balance'] : $nativePrevious;
$nativePrevious = $nativeBalance; $nativePrevious = $nativeBalance;
$currentSet['native_entries'][$label] = $nativeBalance; $currentSet['native_entries'][$label] = $nativeBalance;

View File

@@ -283,17 +283,17 @@ class BudgetController extends Controller
/** @var BudgetLimit $current */ /** @var BudgetLimit $current */
foreach ($limits as $current) { foreach ($limits as $current) {
if (true === $this->convertToNative) { if (true === $this->convertToPrimary) {
if ($current->transaction_currency_id === $this->nativeCurrency->id) { if ($current->transaction_currency_id === $this->primaryCurrency->id) {
// simply add it. // simply add it.
$amount = bcadd($amount, (string)$current->amount); $amount = bcadd($amount, (string)$current->amount);
Log::debug(sprintf('Set amount in limit to %s', $amount)); Log::debug(sprintf('Set amount in limit to %s', $amount));
} }
if ($current->transaction_currency_id !== $this->nativeCurrency->id) { if ($current->transaction_currency_id !== $this->primaryCurrency->id) {
// convert and then add it. // convert and then add it.
$converted = $converter->convert($current->transactionCurrency, $this->nativeCurrency, $limit->start_date, $limit->amount); $converted = $converter->convert($current->transactionCurrency, $this->primaryCurrency, $limit->start_date, $limit->amount);
$amount = bcadd($amount, $converted); $amount = bcadd($amount, $converted);
Log::debug(sprintf('Budgeted in limit #%d: %s %s, converted to %s %s', $current->id, $current->transactionCurrency->code, $current->amount, $this->nativeCurrency->code, $converted)); Log::debug(sprintf('Budgeted in limit #%d: %s %s, converted to %s %s', $current->id, $current->transactionCurrency->code, $current->amount, $this->primaryCurrency->code, $converted));
Log::debug(sprintf('Set amount in limit to %s', $amount)); Log::debug(sprintf('Set amount in limit to %s', $amount));
} }
} }
@@ -301,7 +301,7 @@ class BudgetController extends Controller
$limit = $current; $limit = $current;
} }
} }
if (null !== $limit && true === $this->convertToNative) { if (null !== $limit && true === $this->convertToPrimary) {
// convert and add all amounts. // convert and add all amounts.
$limit->amount = app('steam')->positive($amount); $limit->amount = app('steam')->positive($amount);
Log::debug(sprintf('Final amount in limit with converted amount %s', $limit->amount)); Log::debug(sprintf('Final amount in limit with converted amount %s', $limit->amount));

View File

@@ -111,14 +111,14 @@ class CategoryController extends Controller
$amount = app('steam')->positive($journal['amount']); $amount = app('steam')->positive($journal['amount']);
// overrule if necessary: // overrule if necessary:
if ($this->convertToNative && $journalCurrencyId !== $this->nativeCurrency->id) { if ($this->convertToPrimary && $journalCurrencyId !== $this->primaryCurrency->id) {
$currencyId = (int)$this->nativeCurrency->id; $currencyId = (int)$this->primaryCurrency->id;
$currencyName = (string)$this->nativeCurrency->name; $currencyName = (string)$this->primaryCurrency->name;
$currencyCode = (string)$this->nativeCurrency->code; $currencyCode = (string)$this->primaryCurrency->code;
$currencySymbol = (string)$this->nativeCurrency->symbol; $currencySymbol = (string)$this->primaryCurrency->symbol;
$currencyDecimalPlaces = (int)$this->nativeCurrency->decimal_places; $currencyDecimalPlaces = (int)$this->primaryCurrency->decimal_places;
$convertedAmount = $converter->convert($currency, $this->nativeCurrency, $journal['date'], $amount); $convertedAmount = $converter->convert($currency, $this->primaryCurrency, $journal['date'], $amount);
Log::debug(sprintf('Converted %s %s to %s %s', $journal['currency_code'], $amount, $this->nativeCurrency->code, $convertedAmount)); Log::debug(sprintf('Converted %s %s to %s %s', $journal['currency_code'], $amount, $this->primaryCurrency->code, $convertedAmount));
$amount = $convertedAmount; $amount = $convertedAmount;
} }

View File

@@ -68,8 +68,8 @@ abstract class Controller extends BaseController
/** @var array<int, string> */ /** @var array<int, string> */
protected array $allowedSort; protected array $allowedSort;
protected bool $convertToNative = false; protected bool $convertToPrimary = false;
protected TransactionCurrency $nativeCurrency; protected TransactionCurrency $primaryCurrency;
protected ParameterBag $parameters; protected ParameterBag $parameters;
/** /**
@@ -84,8 +84,8 @@ abstract class Controller extends BaseController
$this->parameters = $this->getParameters(); $this->parameters = $this->getParameters();
if (auth()->check()) { if (auth()->check()) {
$language = Steam::getLanguage(); $language = Steam::getLanguage();
$this->convertToNative = Amount::convertToPrimary(); $this->convertToPrimary = Amount::convertToPrimary();
$this->nativeCurrency = Amount::getPrimaryCurrency(); $this->primaryCurrency = Amount::getPrimaryCurrency();
app()->setLocale($language); app()->setLocale($language);
} }

View File

@@ -97,7 +97,7 @@ class ShowController extends Controller
$admin = auth()->user(); $admin = auth()->user();
$enrichment = new AccountEnrichment(); $enrichment = new AccountEnrichment();
$enrichment->setUser($admin); $enrichment->setUser($admin);
$enrichment->setNative($this->nativeCurrency); $enrichment->setNative($this->primaryCurrency);
$accounts = $enrichment->enrich($accounts); $accounts = $enrichment->enrich($accounts);
// make paginator: // make paginator:
@@ -132,7 +132,7 @@ class ShowController extends Controller
$admin = auth()->user(); $admin = auth()->user();
$enrichment = new AccountEnrichment(); $enrichment = new AccountEnrichment();
$enrichment->setUser($admin); $enrichment->setUser($admin);
$enrichment->setNative($this->nativeCurrency); $enrichment->setNative($this->primaryCurrency);
$account = $enrichment->enrichSingle($account); $account = $enrichment->enrichSingle($account);

View File

@@ -76,7 +76,7 @@ class StoreController extends Controller
$admin = auth()->user(); $admin = auth()->user();
$enrichment = new AccountEnrichment(); $enrichment = new AccountEnrichment();
$enrichment->setUser($admin); $enrichment->setUser($admin);
$enrichment->setNative($this->nativeCurrency); $enrichment->setNative($this->primaryCurrency);
$account = $enrichment->enrichSingle($account); $account = $enrichment->enrichSingle($account);
/** @var AccountTransformer $transformer */ /** @var AccountTransformer $transformer */

View File

@@ -81,7 +81,7 @@ class UpdateController extends Controller
$admin = auth()->user(); $admin = auth()->user();
$enrichment = new AccountEnrichment(); $enrichment = new AccountEnrichment();
$enrichment->setUser($admin); $enrichment->setUser($admin);
$enrichment->setNative($this->nativeCurrency); $enrichment->setNative($this->primaryCurrency);
$account = $enrichment->enrichSingle($account); $account = $enrichment->enrichSingle($account);
/** @var AccountTransformer $transformer */ /** @var AccountTransformer $transformer */

View File

@@ -83,8 +83,8 @@ class ShowController extends Controller
$admin = auth()->user(); $admin = auth()->user();
$enrichment = new SubscriptionEnrichment(); $enrichment = new SubscriptionEnrichment();
$enrichment->setUser($admin); $enrichment->setUser($admin);
$enrichment->setConvertToNative($this->convertToNative); $enrichment->setConvertToNative($this->convertToPrimary);
$enrichment->setNative($this->nativeCurrency); $enrichment->setNative($this->primaryCurrency);
$enrichment->setStart($this->parameters->get('start')); $enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end')); $enrichment->setEnd($this->parameters->get('end'));
$bills = $enrichment->enrich($bills); $bills = $enrichment->enrich($bills);
@@ -114,8 +114,8 @@ class ShowController extends Controller
$admin = auth()->user(); $admin = auth()->user();
$enrichment = new SubscriptionEnrichment(); $enrichment = new SubscriptionEnrichment();
$enrichment->setUser($admin); $enrichment->setUser($admin);
$enrichment->setConvertToNative($this->convertToNative); $enrichment->setConvertToNative($this->convertToPrimary);
$enrichment->setNative($this->nativeCurrency); $enrichment->setNative($this->primaryCurrency);
$enrichment->setStart($this->parameters->get('start')); $enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end')); $enrichment->setEnd($this->parameters->get('end'));
$bill = $enrichment->enrichSingle($bill); $bill = $enrichment->enrichSingle($bill);

View File

@@ -79,8 +79,8 @@ class StoreController extends Controller
$admin = auth()->user(); $admin = auth()->user();
$enrichment = new SubscriptionEnrichment(); $enrichment = new SubscriptionEnrichment();
$enrichment->setUser($admin); $enrichment->setUser($admin);
$enrichment->setConvertToNative($this->convertToNative); $enrichment->setConvertToNative($this->convertToPrimary);
$enrichment->setNative($this->nativeCurrency); $enrichment->setNative($this->primaryCurrency);
$enrichment->setStart($this->parameters->get('start')); $enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end')); $enrichment->setEnd($this->parameters->get('end'));
$bill = $enrichment->enrichSingle($bill); $bill = $enrichment->enrichSingle($bill);

View File

@@ -74,8 +74,8 @@ class UpdateController extends Controller
$admin = auth()->user(); $admin = auth()->user();
$enrichment = new SubscriptionEnrichment(); $enrichment = new SubscriptionEnrichment();
$enrichment->setUser($admin); $enrichment->setUser($admin);
$enrichment->setConvertToNative($this->convertToNative); $enrichment->setConvertToNative($this->convertToPrimary);
$enrichment->setNative($this->nativeCurrency); $enrichment->setNative($this->primaryCurrency);
$enrichment->setStart($this->parameters->get('start')); $enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end')); $enrichment->setEnd($this->parameters->get('end'));
$bill = $enrichment->enrichSingle($bill); $bill = $enrichment->enrichSingle($bill);

View File

@@ -85,8 +85,8 @@ class ListController extends Controller
$admin = auth()->user(); $admin = auth()->user();
$enrichment = new SubscriptionEnrichment(); $enrichment = new SubscriptionEnrichment();
$enrichment->setUser($admin); $enrichment->setUser($admin);
$enrichment->setConvertToNative($this->convertToNative); $enrichment->setConvertToNative($this->convertToPrimary);
$enrichment->setNative($this->nativeCurrency); $enrichment->setNative($this->primaryCurrency);
$enrichment->setStart($this->parameters->get('start')); $enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end')); $enrichment->setEnd($this->parameters->get('end'));
$bills = $enrichment->enrich($bills); $bills = $enrichment->enrich($bills);

View File

@@ -84,7 +84,7 @@ class ListController extends Controller
$admin = auth()->user(); $admin = auth()->user();
$enrichment = new AccountEnrichment(); $enrichment = new AccountEnrichment();
$enrichment->setUser($admin); $enrichment->setUser($admin);
$enrichment->setNative($this->nativeCurrency); $enrichment->setNative($this->primaryCurrency);
$accounts = $enrichment->enrich($accounts); $accounts = $enrichment->enrich($accounts);
// make paginator: // make paginator:

View File

@@ -108,7 +108,7 @@ class ListController extends Controller
$admin = auth()->user(); $admin = auth()->user();
$enrichment = new AccountEnrichment(); $enrichment = new AccountEnrichment();
$enrichment->setUser($admin); $enrichment->setUser($admin);
$enrichment->setNative($this->nativeCurrency); $enrichment->setNative($this->primaryCurrency);
$accounts = $enrichment->enrich($accounts); $accounts = $enrichment->enrich($accounts);
// make paginator: // make paginator:
@@ -188,8 +188,8 @@ class ListController extends Controller
$admin = auth()->user(); $admin = auth()->user();
$enrichment = new SubscriptionEnrichment(); $enrichment = new SubscriptionEnrichment();
$enrichment->setUser($admin); $enrichment->setUser($admin);
$enrichment->setConvertToNative($this->convertToNative); $enrichment->setConvertToNative($this->convertToPrimary);
$enrichment->setNative($this->nativeCurrency); $enrichment->setNative($this->primaryCurrency);
$enrichment->setStart($this->parameters->get('start')); $enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end')); $enrichment->setEnd($this->parameters->get('end'));
$bills = $enrichment->enrichSingle($bills); $bills = $enrichment->enrichSingle($bills);

View File

@@ -107,7 +107,7 @@ class ShowController extends Controller
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
$manager = $this->getManager(); $manager = $this->getManager();
$this->parameters->set('nativeCurrency', $this->nativeCurrency); $this->parameters->set('nativeCurrency', $this->primaryCurrency);
// update fields with user info. // update fields with user info.
$currency->refreshForUser($user); $currency->refreshForUser($user);
@@ -134,7 +134,7 @@ class ShowController extends Controller
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
$manager = $this->getManager(); $manager = $this->getManager();
$currency = $this->nativeCurrency; $currency = $this->primaryCurrency;
// update fields with user info. // update fields with user info.
$currency->refreshForUser($user); $currency->refreshForUser($user);

View File

@@ -89,7 +89,7 @@ class AccountController extends Controller
$admin = auth()->user(); $admin = auth()->user();
$enrichment = new AccountEnrichment(); $enrichment = new AccountEnrichment();
$enrichment->setUser($admin); $enrichment->setUser($admin);
$enrichment->setNative($this->nativeCurrency); $enrichment->setNative($this->primaryCurrency);
$accounts = $enrichment->enrich($accounts); $accounts = $enrichment->enrich($accounts);
/** @var AccountTransformer $transformer */ /** @var AccountTransformer $transformer */

View File

@@ -279,7 +279,7 @@ class BasicController extends Controller
]; ];
} }
if (0 === count($return)) { if (0 === count($return)) {
$currency = $this->nativeCurrency; $currency = $this->primaryCurrency;
// create objects for big array. // create objects for big array.
$return[] = [ $return[] = [
'key' => sprintf('balance-in-%s', $currency->code), 'key' => sprintf('balance-in-%s', $currency->code),
@@ -333,26 +333,26 @@ class BasicController extends Controller
$paidAmount = $this->billRepository->sumPaidInRange($start, $end); $paidAmount = $this->billRepository->sumPaidInRange($start, $end);
$unpaidAmount = $this->billRepository->sumUnpaidInRange($start, $end); $unpaidAmount = $this->billRepository->sumUnpaidInRange($start, $end);
$currencies = [ $currencies = [
$this->nativeCurrency->id => $this->nativeCurrency, $this->primaryCurrency->id => $this->primaryCurrency,
]; ];
if ($this->convertToNative) { if ($this->convertToPrimary) {
$converter = new ExchangeRateConverter(); $converter = new ExchangeRateConverter();
$newPaidAmount = [[ $newPaidAmount = [[
'id' => $this->nativeCurrency->id, 'id' => $this->primaryCurrency->id,
'name' => $this->nativeCurrency->name, 'name' => $this->primaryCurrency->name,
'symbol' => $this->nativeCurrency->symbol, 'symbol' => $this->primaryCurrency->symbol,
'code' => $this->nativeCurrency->code, 'code' => $this->primaryCurrency->code,
'decimal_places' => $this->nativeCurrency->decimal_places, 'decimal_places' => $this->primaryCurrency->decimal_places,
'sum' => '0', 'sum' => '0',
]]; ]];
$newUnpaidAmount = [[ $newUnpaidAmount = [[
'id' => $this->nativeCurrency->id, 'id' => $this->primaryCurrency->id,
'name' => $this->nativeCurrency->name, 'name' => $this->primaryCurrency->name,
'symbol' => $this->nativeCurrency->symbol, 'symbol' => $this->primaryCurrency->symbol,
'code' => $this->nativeCurrency->code, 'code' => $this->primaryCurrency->code,
'decimal_places' => $this->nativeCurrency->decimal_places, 'decimal_places' => $this->primaryCurrency->decimal_places,
'sum' => '0', 'sum' => '0',
]]; ]];
foreach ([$paidAmount, $unpaidAmount] as $index => $array) { foreach ([$paidAmount, $unpaidAmount] as $index => $array) {
@@ -360,25 +360,25 @@ class BasicController extends Controller
$currencyId = (int) $item['id']; $currencyId = (int) $item['id'];
if (0 === $index) { if (0 === $index) {
// paid amount // paid amount
if ($currencyId === $this->nativeCurrency->id) { if ($currencyId === $this->primaryCurrency->id) {
$newPaidAmount[0]['sum'] = bcadd($newPaidAmount[0]['sum'], (string) $item['sum']); $newPaidAmount[0]['sum'] = bcadd($newPaidAmount[0]['sum'], (string) $item['sum']);
continue; continue;
} }
$currencies[$currencyId] ??= $this->currencyRepos->find($currencyId); $currencies[$currencyId] ??= $this->currencyRepos->find($currencyId);
$convertedAmount = $converter->convert($currencies[$currencyId], $this->nativeCurrency, $start, $item['sum']); $convertedAmount = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $item['sum']);
$newPaidAmount[0]['sum'] = bcadd($newPaidAmount[0]['sum'], $convertedAmount); $newPaidAmount[0]['sum'] = bcadd($newPaidAmount[0]['sum'], $convertedAmount);
continue; continue;
} }
// unpaid amount // unpaid amount
if ($currencyId === $this->nativeCurrency->id) { if ($currencyId === $this->primaryCurrency->id) {
$newUnpaidAmount[0]['sum'] = bcadd($newUnpaidAmount[0]['sum'], (string) $item['sum']); $newUnpaidAmount[0]['sum'] = bcadd($newUnpaidAmount[0]['sum'], (string) $item['sum']);
continue; continue;
} }
$currencies[$currencyId] ??= $this->currencyRepos->find($currencyId); $currencies[$currencyId] ??= $this->currencyRepos->find($currencyId);
$convertedAmount = $converter->convert($currencies[$currencyId], $this->nativeCurrency, $start, $item['sum']); $convertedAmount = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $item['sum']);
$newUnpaidAmount[0]['sum'] = bcadd($newUnpaidAmount[0]['sum'], $convertedAmount); $newUnpaidAmount[0]['sum'] = bcadd($newUnpaidAmount[0]['sum'], $convertedAmount);
} }
} }
@@ -432,7 +432,7 @@ class BasicController extends Controller
Log::debug(sprintf('Done with getBillInformation("%s", "%s")', $start->format('Y-m-d'), $end->format('Y-m-d-'))); Log::debug(sprintf('Done with getBillInformation("%s", "%s")', $start->format('Y-m-d'), $end->format('Y-m-d-')));
if (0 === count($return)) { if (0 === count($return)) {
$currency = $this->nativeCurrency; $currency = $this->primaryCurrency;
unset($info, $amount); unset($info, $amount);
$return[] = [ $return[] = [
@@ -577,7 +577,7 @@ class BasicController extends Controller
// $amount = '0'; // $amount = '0';
// // $days // // $days
// // fill in by money spent, just count it. // // fill in by money spent, just count it.
// $currency = $this->nativeCurrency; // $currency = $this->primaryCurrency;
// $return[$currency->id] = [ // $return[$currency->id] = [
// 'key' => sprintf('left-to-spend-in-%s', $currency->code), // 'key' => sprintf('left-to-spend-in-%s', $currency->code),
// 'title' => trans('firefly.box_left_to_spend_in_currency', ['currency' => $currency->symbol]), // 'title' => trans('firefly.box_left_to_spend_in_currency', ['currency' => $currency->symbol]),
@@ -649,14 +649,14 @@ class BasicController extends Controller
} }
if (0 === count($return)) { if (0 === count($return)) {
$return[] = [ $return[] = [
'key' => sprintf('net-worth-in-%s', $this->nativeCurrency->code), 'key' => sprintf('net-worth-in-%s', $this->primaryCurrency->code),
'title' => trans('firefly.box_net_worth_in_currency', ['currency' => $this->nativeCurrency->symbol]), 'title' => trans('firefly.box_net_worth_in_currency', ['currency' => $this->primaryCurrency->symbol]),
'monetary_value' => '0', 'monetary_value' => '0',
'currency_id' => (string) $this->nativeCurrency->id, 'currency_id' => (string) $this->primaryCurrency->id,
'currency_code' => $this->nativeCurrency->code, 'currency_code' => $this->primaryCurrency->code,
'currency_symbol' => $this->nativeCurrency->symbol, 'currency_symbol' => $this->primaryCurrency->symbol,
'currency_decimal_places' => $this->nativeCurrency->decimal_places, 'currency_decimal_places' => $this->primaryCurrency->decimal_places,
'value_parsed' => app('amount')->formatFlat($this->nativeCurrency->symbol, $this->nativeCurrency->decimal_places, '0', false), 'value_parsed' => app('amount')->formatFlat($this->primaryCurrency->symbol, $this->primaryCurrency->decimal_places, '0', false),
'local_icon' => 'line-chart', 'local_icon' => 'line-chart',
'sub_title' => '', 'sub_title' => '',
]; ];