Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Rename many references from native to primary.
James Cole6d3f2bd5e77a
diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.phpindex 13c06b5972..d9721881ae 100644--- a/app/Api/V1/Controllers/Controller.php+++ b/app/Api/V1/Controllers/Controller.php@@ -84,8 +84,8 @@ abstract class Controller extends BaseController$this->parameters = $this->getParameters();if (auth()->check()) {$language = Steam::getLanguage();- $this->convertToNative = Amount::convertToNative();- $this->nativeCurrency = Amount::getNativeCurrency();+ $this->convertToNative = Amount::convertToPrimary();+ $this->nativeCurrency = Amount::getPrimaryCurrency();app()->setLocale($language);}diff --git a/app/Api/V1/Controllers/Insight/Expense/BillController.php b/app/Api/V1/Controllers/Insight/Expense/BillController.phpindex 4858e0c965..f00766ad6e 100644--- a/app/Api/V1/Controllers/Insight/Expense/BillController.php+++ b/app/Api/V1/Controllers/Insight/Expense/BillController.php@@ -69,8 +69,8 @@ class BillController extends Controller$bills = $request->getBills();$start = $request->getStart();$end = $request->getEnd();- $convertToNative = Amount::convertToNative();- $default = Amount::getNativeCurrency();+ $convertToNative = Amount::convertToPrimary();+ $default = Amount::getPrimaryCurrency();$response = [];// get all bills:@@ -132,8 +132,8 @@ class BillController extends Controller$accounts = $request->getAssetAccounts();$start = $request->getStart();$end = $request->getEnd();- $convertToNative = Amount::convertToNative();- $default = Amount::getNativeCurrency();+ $convertToNative = Amount::convertToPrimary();+ $default = Amount::getPrimaryCurrency();$response = [];// collect all expenses in this period (regardless of type) by the given bills and accounts.diff --git a/app/Api/V1/Controllers/Insight/Expense/PeriodController.php b/app/Api/V1/Controllers/Insight/Expense/PeriodController.phpindex 3b5316dd10..5db5657968 100644--- a/app/Api/V1/Controllers/Insight/Expense/PeriodController.php+++ b/app/Api/V1/Controllers/Insight/Expense/PeriodController.php@@ -47,8 +47,8 @@ class PeriodController extends Controller$start = $request->getStart();$end = $request->getEnd();$response = [];- $convertToNative = Amount::convertToNative();- $default = Amount::getNativeCurrency();+ $convertToNative = Amount::convertToPrimary();+ $default = Amount::getPrimaryCurrency();// collect all expenses in this period (regardless of type)$collector = app(GroupCollectorInterface::class);diff --git a/app/Api/V1/Controllers/Insight/Expense/TagController.php b/app/Api/V1/Controllers/Insight/Expense/TagController.phpindex 2e140656fe..93deb47889 100644--- a/app/Api/V1/Controllers/Insight/Expense/TagController.php+++ b/app/Api/V1/Controllers/Insight/Expense/TagController.php@@ -68,8 +68,8 @@ class TagController extends Controller$start = $request->getStart();$end = $request->getEnd();$response = [];- $convertToNative = Amount::convertToNative();- $default = Amount::getNativeCurrency();+ $convertToNative = Amount::convertToPrimary();+ $default = Amount::getPrimaryCurrency();// collect all expenses in this period (regardless of type) by the given bills and accounts.$collector = app(GroupCollectorInterface::class);diff --git a/app/Api/V1/Controllers/Insight/Income/PeriodController.php b/app/Api/V1/Controllers/Insight/Income/PeriodController.phpindex d11e93829b..fa3d0ae0ec 100644--- a/app/Api/V1/Controllers/Insight/Income/PeriodController.php+++ b/app/Api/V1/Controllers/Insight/Income/PeriodController.php@@ -46,8 +46,8 @@ class PeriodController extends Controller$start = $request->getStart();$end = $request->getEnd();$response = [];- $convertToNative = Amount::convertToNative();- $default = Amount::getNativeCurrency();+ $convertToNative = Amount::convertToPrimary();+ $default = Amount::getPrimaryCurrency();// collect all expenses in this period (regardless of type)$collector = app(GroupCollectorInterface::class);diff --git a/app/Api/V1/Controllers/Insight/Income/TagController.php b/app/Api/V1/Controllers/Insight/Income/TagController.phpindex 1f127f298d..9ff5cd0acc 100644--- a/app/Api/V1/Controllers/Insight/Income/TagController.php+++ b/app/Api/V1/Controllers/Insight/Income/TagController.php@@ -68,8 +68,8 @@ class TagController extends Controller$start = $request->getStart();$end = $request->getEnd();$response = [];- $convertToNative = Amount::convertToNative();- $default = Amount::getNativeCurrency();+ $convertToNative = Amount::convertToPrimary();+ $default = Amount::getPrimaryCurrency();// collect all expenses in this period (regardless of type) by the given bills and accounts.$collector = app(GroupCollectorInterface::class);diff --git a/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php b/app/Api/V1/Controllers/Insight/Transfer/PeriodController.phpindex d35c2b74df..0d403904cc 100644--- a/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php+++ b/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php@@ -46,8 +46,8 @@ class PeriodController extends Controller$start = $request->getStart();$end = $request->getEnd();$response = [];- $convertToNative = Amount::convertToNative();- $default = Amount::getNativeCurrency();+ $convertToNative = Amount::convertToPrimary();+ $default = Amount::getPrimaryCurrency();// collect all expenses in this period (regardless of type)$collector = app(GroupCollectorInterface::class);diff --git a/app/Api/V1/Controllers/Insight/Transfer/TagController.php b/app/Api/V1/Controllers/Insight/Transfer/TagController.phpindex f0c02a2df5..e6bfeeaf49 100644--- a/app/Api/V1/Controllers/Insight/Transfer/TagController.php+++ b/app/Api/V1/Controllers/Insight/Transfer/TagController.php@@ -66,8 +66,8 @@ class TagController extends Controller$start = $request->getStart();$end = $request->getEnd();$response = [];- $convertToNative = Amount::convertToNative();- $default = Amount::getNativeCurrency();+ $convertToNative = Amount::convertToPrimary();+ $default = Amount::getPrimaryCurrency();// collect all expenses in this period (regardless of type) by the given bills and accounts.diff --git a/app/Api/V1/Controllers/Summary/BasicController.php b/app/Api/V1/Controllers/Summary/BasicController.phpindex 02b7bc0405..ebfe6e74f3 100644--- a/app/Api/V1/Controllers/Summary/BasicController.php+++ b/app/Api/V1/Controllers/Summary/BasicController.php@@ -127,8 +127,8 @@ class BasicController extends Controller{Log::debug('getBalanceInformation');// some config settings- $convertToNative = Amount::convertToNative();- $default = Amount::getNativeCurrency();+ $convertToNative = Amount::convertToPrimary();+ $default = Amount::getPrimaryCurrency();// prep some arrays:$sums = [];$return = [];diff --git a/app/Api/V2/Controllers/Autocomplete/AccountController.php b/app/Api/V2/Controllers/Autocomplete/AccountController.phpindex b267c1a09c..ce4483329b 100644--- a/app/Api/V2/Controllers/Autocomplete/AccountController.php+++ b/app/Api/V2/Controllers/Autocomplete/AccountController.php@@ -55,7 +55,7 @@ class AccountController extends Controller$userGroup = $this->validateUserGroup($request);$this->repository = app(AccountRepositoryInterface::class);$this->repository->setUserGroup($userGroup);- $this->default = app('amount')->getNativeCurrency();+ $this->default = app('amount')->getPrimaryCurrency();$this->converter = app(ExchangeRateConverter::class);return $next($request);diff --git a/app/Api/V2/Controllers/Chart/AccountController.php b/app/Api/V2/Controllers/Chart/AccountController.phpindex 7f273cae3f..9765ae30c5 100644--- a/app/Api/V2/Controllers/Chart/AccountController.php+++ b/app/Api/V2/Controllers/Chart/AccountController.php@@ -58,7 +58,7 @@ class AccountController extends Controller$this->repository = app(AccountRepositoryInterface::class);$this->repository->setUserGroup($this->validateUserGroup($request));$this->chartData = new ChartData();- $this->default = app('amount')->getNativeCurrency();+ $this->default = app('amount')->getPrimaryCurrency();return $next($request);}diff --git a/app/Api/V2/Controllers/Chart/BalanceController.php b/app/Api/V2/Controllers/Chart/BalanceController.phpindex 85aec5c6e3..32d489e88c 100644--- a/app/Api/V2/Controllers/Chart/BalanceController.php+++ b/app/Api/V2/Controllers/Chart/BalanceController.php@@ -62,7 +62,7 @@ class BalanceController extends Controller$this->repository->setUserGroup($userGroup);$this->collector->setUserGroup($userGroup);$this->chartData = new ChartData();- // $this->default = app('amount')->getNativeCurrency();+ // $this->default = app('amount')->getPrimaryCurrency();return $next($request);}@@ -87,7 +87,7 @@ class BalanceController extends Controller// prepare for currency conversion and data collection:/** @var TransactionCurrency $default */- $default = app('amount')->getNativeCurrency();+ $default = app('amount')->getPrimaryCurrency();// get journals for entire period:diff --git a/app/Api/V2/Controllers/Chart/BudgetController.php b/app/Api/V2/Controllers/Chart/BudgetController.phpindex 9ef001cc77..148524157f 100644--- a/app/Api/V2/Controllers/Chart/BudgetController.php+++ b/app/Api/V2/Controllers/Chart/BudgetController.php@@ -63,7 +63,7 @@ class BudgetController extends Controller$this->repository = app(BudgetRepositoryInterface::class);$this->blRepository = app(BudgetLimitRepositoryInterface::class);$this->opsRepository = app(OperationsRepositoryInterface::class);- $this->currency = app('amount')->getNativeCurrency();+ $this->currency = app('amount')->getPrimaryCurrency();$userGroup = $this->validateUserGroup($request);$this->repository->setUserGroup($userGroup);$this->opsRepository->setUserGroup($userGroup);diff --git a/app/Api/V2/Controllers/Chart/CategoryController.php b/app/Api/V2/Controllers/Chart/CategoryController.phpindex e259739805..9a1372935b 100644--- a/app/Api/V2/Controllers/Chart/CategoryController.php+++ b/app/Api/V2/Controllers/Chart/CategoryController.php@@ -82,7 +82,7 @@ class CategoryController extends Controller/** @var Carbon $end */$end = $this->parameters->get('end');$accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::ASSET->value, AccountTypeEnum::DEFAULT->value]);- $default = app('amount')->getNativeCurrency();+ $default = app('amount')->getPrimaryCurrency();$converter = new ExchangeRateConverter();$currencies = [];$return = [];diff --git a/app/Api/V2/Controllers/Summary/BasicController.php b/app/Api/V2/Controllers/Summary/BasicController.phpindex feb3798cef..5a7ef94980 100644--- a/app/Api/V2/Controllers/Summary/BasicController.php+++ b/app/Api/V2/Controllers/Summary/BasicController.php@@ -119,7 +119,7 @@ class BasicController extends Controllerprivate function getBalanceInformation(Carbon $start, Carbon $end): array{$object = new SummaryBalanceGrouped();- $default = app('amount')->getNativeCurrency();+ $default = app('amount')->getPrimaryCurrency();$object->setDefault($default);@@ -234,7 +234,7 @@ class BasicController extends Controller$available = $this->abRepository->getAvailableBudgetWithCurrency($start, $end);$budgets = $this->budgetRepository->getActiveBudgets();$spent = $this->opsRepository->listExpenses($start, $end, null, $budgets);- $default = app('amount')->getNativeCurrency();+ $default = app('amount')->getPrimaryCurrency();$currencies = [];$converter = new ExchangeRateConverter();diff --git a/app/Factory/PiggyBankFactory.php b/app/Factory/PiggyBankFactory.phpindex eefd1436e5..933f870d0b 100644--- a/app/Factory/PiggyBankFactory.php+++ b/app/Factory/PiggyBankFactory.php@@ -126,7 +126,7 @@ class PiggyBankFactoryprivate function getCurrency(array $data): TransactionCurrency{// currency:- $defaultCurrency = app('amount')->getNativeCurrency();+ $defaultCurrency = app('amount')->getPrimaryCurrency();$currency = null;if (array_key_exists('transaction_currency_code', $data)) {$currency = $this->currencyRepository->findByCode((string)($data['transaction_currency_code'] ?? ''));diff --git a/app/Handlers/Events/PreferencesEventHandler.php b/app/Handlers/Events/PreferencesEventHandler.phpindex 91bbb9a9bd..11fd4cbda2 100644--- a/app/Handlers/Events/PreferencesEventHandler.php+++ b/app/Handlers/Events/PreferencesEventHandler.php@@ -60,7 +60,7 @@ class PreferencesEventHandler$this->resetBudgets($event->userGroup);$this->resetTransactions($event->userGroup);// fire laravel command to recalculate them all.- if (Amount::convertToNative()) {+ if (Amount::convertToPrimary()) {Log::debug('Will now convert to native.');Artisan::call('correction:recalculate-native-amounts');diff --git a/app/Handlers/Observer/AccountObserver.php b/app/Handlers/Observer/AccountObserver.phpindex 73782b6bb7..8531b6eb39 100644--- a/app/Handlers/Observer/AccountObserver.php+++ b/app/Handlers/Observer/AccountObserver.php@@ -49,7 +49,7 @@ class AccountObserverprivate function updateNativeAmount(Account $account): void{- if (!Amount::convertToNative($account->user)) {+ if (!Amount::convertToPrimary($account->user)) {return;}$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);diff --git a/app/Handlers/Observer/AutoBudgetObserver.php b/app/Handlers/Observer/AutoBudgetObserver.phpindex 967635d6c1..a4e3e5e325 100644--- a/app/Handlers/Observer/AutoBudgetObserver.php+++ b/app/Handlers/Observer/AutoBudgetObserver.php@@ -39,7 +39,7 @@ class AutoBudgetObserverprivate function updateNativeAmount(AutoBudget $autoBudget): void{- if (!Amount::convertToNative($autoBudget->budget->user)) {+ if (!Amount::convertToPrimary($autoBudget->budget->user)) {return;}$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($autoBudget->budget->user->userGroup);diff --git a/app/Handlers/Observer/AvailableBudgetObserver.php b/app/Handlers/Observer/AvailableBudgetObserver.phpindex b3c069519c..36e488d48f 100644--- a/app/Handlers/Observer/AvailableBudgetObserver.php+++ b/app/Handlers/Observer/AvailableBudgetObserver.php@@ -39,7 +39,7 @@ class AvailableBudgetObserverprivate function updateNativeAmount(AvailableBudget $availableBudget): void{- if (!Amount::convertToNative($availableBudget->user)) {+ if (!Amount::convertToPrimary($availableBudget->user)) {// Log::debug('Do not update native available amount of the available budget.');return;diff --git a/app/Handlers/Observer/BillObserver.php b/app/Handlers/Observer/BillObserver.phpindex 40f56f1f29..b6f76b4740 100644--- a/app/Handlers/Observer/BillObserver.php+++ b/app/Handlers/Observer/BillObserver.php@@ -43,7 +43,7 @@ class BillObserverprivate function updateNativeAmount(Bill $bill): void{- if (!Amount::convertToNative($bill->user)) {+ if (!Amount::convertToPrimary($bill->user)) {return;}$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($bill->user->userGroup);diff --git a/app/Handlers/Observer/BudgetLimitObserver.php b/app/Handlers/Observer/BudgetLimitObserver.phpindex d4a7bb833b..08b5018165 100644--- a/app/Handlers/Observer/BudgetLimitObserver.php+++ b/app/Handlers/Observer/BudgetLimitObserver.php@@ -39,7 +39,7 @@ class BudgetLimitObserverprivate function updateNativeAmount(BudgetLimit $budgetLimit): void{- if (!Amount::convertToNative($budgetLimit->budget->user)) {+ if (!Amount::convertToPrimary($budgetLimit->budget->user)) {// Log::debug('Do not update native amount of the budget limit.');return;diff --git a/app/Handlers/Observer/PiggyBankEventObserver.php b/app/Handlers/Observer/PiggyBankEventObserver.phpindex 55dd5ac332..eee9db9a80 100644--- a/app/Handlers/Observer/PiggyBankEventObserver.php+++ b/app/Handlers/Observer/PiggyBankEventObserver.php@@ -45,7 +45,7 @@ class PiggyBankEventObserverreturn;}- if (!Amount::convertToNative($user)) {+ if (!Amount::convertToPrimary($user)) {return;}$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($event->piggyBank->accounts()->first()->user->userGroup);diff --git a/app/Handlers/Observer/TransactionObserver.php b/app/Handlers/Observer/TransactionObserver.phpindex 7affb74699..ca433badc2 100644--- a/app/Handlers/Observer/TransactionObserver.php+++ b/app/Handlers/Observer/TransactionObserver.php@@ -50,7 +50,7 @@ class TransactionObserverprivate function updateNativeAmount(Transaction $transaction): void{- if (!Amount::convertToNative($transaction->transactionJournal->user)) {+ if (!Amount::convertToPrimary($transaction->transactionJournal->user)) {return;}$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($transaction->transactionJournal->user->userGroup);diff --git a/app/Helpers/Report/NetWorth.php b/app/Helpers/Report/NetWorth.phpindex 2fca6d115a..e04b1e19e5 100644--- a/app/Helpers/Report/NetWorth.php+++ b/app/Helpers/Report/NetWorth.php@@ -64,7 +64,7 @@ class NetWorth implements NetWorthInterfacepublic function byAccounts(Collection $accounts, Carbon $date): array{// start in the past, end in the future? use $date- $convertToNative = Amount::convertToNative();+ $convertToNative = Amount::convertToPrimary();$ids = implode(',', $accounts->pluck('id')->toArray());$cache = new CacheProperties();$cache->addProperty($date);@@ -75,7 +75,7 @@ class NetWorth implements NetWorthInterfacereturn $cache->get();}Log::debug(sprintf('Now in byAccounts("%s", "%s")', $ids, $date->format('Y-m-d H:i:s')));- $default = Amount::getNativeCurrency();+ $default = Amount::getPrimaryCurrency();$netWorth = [];Log::debug(sprintf('NetWorth: finalAccountsBalance("%s")', $date->format('Y-m-d H:i:s')));$balances = Steam::finalAccountsBalance($accounts, $date);diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.phpindex daa9da7db8..413244712b 100644--- a/app/Http/Controllers/Controller.php+++ b/app/Http/Controllers/Controller.php@@ -128,11 +128,11 @@ abstract class Controller extends BaseController$this->defaultCurrency = null;// get shown-intro-preference:if (auth()->check()) {- $this->defaultCurrency = Amount::getNativeCurrency();+ $this->defaultCurrency = Amount::getPrimaryCurrency();$language = Steam::getLanguage();$locale = Steam::getLocale();$darkMode = app('preferences')->get('darkMode', 'browser')->data;- $this->convertToNative = Amount::convertToNative();+ $this->convertToNative = Amount::convertToPrimary();$page = $this->getPageName();$shownDemo = $this->hasSeenDemo();View::share('language', $language);diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.phpindex 71f7b7dc27..c62a7883f0 100644--- a/app/Http/Controllers/DebugController.php+++ b/app/Http/Controllers/DebugController.php@@ -285,8 +285,8 @@ class DebugController extends Controller'user_count' => User::count(),'user_flags' => $userFlags,'user_agent' => $userAgent,- 'native' => Amount::getNativeCurrency(),- 'convert_to_native' => Amount::convertToNative(),+ 'native' => Amount::getPrimaryCurrency(),+ 'convert_to_native' => Amount::convertToPrimary(),'locale_attempts' => $localeAttempts,'locale' => Steam::getLocale(),'language' => Steam::getLanguage(),diff --git a/app/Http/Controllers/Json/FrontpageController.php b/app/Http/Controllers/Json/FrontpageController.phpindex f508c66763..d4a8450103 100644--- a/app/Http/Controllers/Json/FrontpageController.php+++ b/app/Http/Controllers/Json/FrontpageController.php@@ -45,8 +45,8 @@ class FrontpageController extends Controller{$set = $repository->getPiggyBanks();$info = [];- $native = Amount::getNativeCurrency();- $convertToNative = Amount::convertToNative();+ $native = Amount::getPrimaryCurrency();+ $convertToNative = Amount::convertToPrimary();/** @var PiggyBank $piggyBank */diff --git a/app/Http/Middleware/Range.php b/app/Http/Middleware/Range.phpindex 4699a454c0..31933b924a 100644--- a/app/Http/Middleware/Range.php+++ b/app/Http/Middleware/Range.php@@ -120,7 +120,7 @@ class Range// save some formats:$monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);$dateTimeFormat = (string) trans('config.date_time_js', [], $locale);- $defaultCurrency = Amount::getNativeCurrency();+ $defaultCurrency = Amount::getPrimaryCurrency();// also format for moment JS:$madMomentJS = (string) trans('config.month_and_day_moment_js', [], $locale);diff --git a/app/Http/Requests/PiggyBankStoreRequest.php b/app/Http/Requests/PiggyBankStoreRequest.phpindex 61ba326821..d7a9058100 100644--- a/app/Http/Requests/PiggyBankStoreRequest.php+++ b/app/Http/Requests/PiggyBankStoreRequest.php@@ -126,7 +126,7 @@ class PiggyBankStoreRequest extends FormRequest$currencyId = (int) ($data['transaction_currency_id'] ?? 0);$currency = TransactionCurrency::find($currencyId);if (null === $currency) {- return Amount::getNativeCurrency();+ return Amount::getPrimaryCurrency();}return $currency;diff --git a/app/Http/Requests/PiggyBankUpdateRequest.php b/app/Http/Requests/PiggyBankUpdateRequest.phpindex d6facfb7de..37c895cde4 100644--- a/app/Http/Requests/PiggyBankUpdateRequest.php+++ b/app/Http/Requests/PiggyBankUpdateRequest.php@@ -131,7 +131,7 @@ class PiggyBankUpdateRequest extends FormRequest$currencyId = (int) ($data['transaction_currency_id'] ?? 0);$currency = TransactionCurrency::find($currencyId);if (null === $currency) {- return Amount::getNativeCurrency();+ return Amount::getPrimaryCurrency();}return $currency;diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.phpindex 47cae859bc..6591860499 100644--- a/app/Repositories/Account/AccountRepository.php+++ b/app/Repositories/Account/AccountRepository.php@@ -357,7 +357,7 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfacif (AccountTypeEnum::ASSET->value !== $account->accountType->type) {throw new FireflyException(sprintf('%s is not an asset account.', $account->name));}- $currency = $this->getAccountCurrency($account) ?? app('amount')->getNativeCurrency();+ $currency = $this->getAccountCurrency($account) ?? app('amount')->getPrimaryCurrency();$name = trans('firefly.reconciliation_account_name', ['name' => $account->name, 'currency' => $currency->code]);/** @var AccountType $type */diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.phpindex 48bd57711b..b81664177b 100644--- a/app/Repositories/Bill/BillRepository.php+++ b/app/Repositories/Bill/BillRepository.php@@ -275,7 +275,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface];$result[$currencyId]['sum'] = bcadd($result[$currencyId]['sum'], (string) $transaction->amount);$result[$currencyId]['native_sum'] = bcadd($result[$currencyId]['native_sum'], $transaction->native_amount ?? '0');- if ($journal->foreign_currency_id === Amount::getNativeCurrency()->id) {+ if ($journal->foreign_currency_id === Amount::getPrimaryCurrency()->id) {$result[$currencyId]['native_sum'] = bcadd($result[$currencyId]['native_sum'], (string) $transaction->amount);}++$result[$currencyId]['count'];@@ -411,7 +411,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface];$result[$currencyId]['sum'] = bcadd($result[$currencyId]['sum'], (string) $transaction->amount);$result[$currencyId]['native_sum'] = bcadd($result[$currencyId]['native_sum'], $transaction->native_amount ?? '0');- if ($journal->foreign_currency_id === Amount::getNativeCurrency()->id) {+ if ($journal->foreign_currency_id === Amount::getPrimaryCurrency()->id) {$result[$currencyId]['native_sum'] = bcadd($result[$currencyId]['native_sum'], (string) $transaction->amount);}++$result[$currencyId]['count'];@@ -534,8 +534,8 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterfaceLog::debug(sprintf('sumPaidInRange from %s to %s', $start->toW3cString(), $end->toW3cString()));$bills = $this->getActiveBills();$return = [];- $convertToNative = Amount::convertToNative($this->user);- $default = app('amount')->getNativeCurrency();+ $convertToNative = Amount::convertToPrimary($this->user);+ $default = app('amount')->getPrimaryCurrency();/** @var Bill $bill */foreach ($bills as $bill) {@@ -600,8 +600,8 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterfaceapp('log')->debug(sprintf('Now in sumUnpaidInRange("%s", "%s")', $start->format('Y-m-d'), $end->format('Y-m-d')));$bills = $this->getActiveBills();$return = [];- $convertToNative = Amount::convertToNative($this->user);- $default = app('amount')->getNativeCurrency();+ $convertToNative = Amount::convertToPrimary($this->user);+ $default = app('amount')->getPrimaryCurrency();/** @var Bill $bill */foreach ($bills as $bill) {diff --git a/app/Repositories/Budget/AvailableBudgetRepository.php b/app/Repositories/Budget/AvailableBudgetRepository.phpindex 2ec270541f..773bc144a3 100644--- a/app/Repositories/Budget/AvailableBudgetRepository.php+++ b/app/Repositories/Budget/AvailableBudgetRepository.php@@ -142,8 +142,8 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface, ULog::debug(sprintf('Found %d available budgets (already converted)', $availableBudgets->count()));// use native amount if necessary?- $convertToNative = Amount::convertToNative($this->user);- $default = Amount::getNativeCurrency();+ $convertToNative = Amount::convertToPrimary($this->user);+ $default = Amount::getPrimaryCurrency();/** @var AvailableBudget $availableBudget */foreach ($availableBudgets as $availableBudget) {diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.phpindex 65460aaa74..3c5f9d70d6 100644--- a/app/Repositories/Budget/BudgetRepository.php+++ b/app/Repositories/Budget/BudgetRepository.php@@ -91,7 +91,7 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface$limitRepository = app(BudgetLimitRepository::class);$limitRepository->setUser($this->user);$budgets = $this->getActiveBudgets();- $defaultCurrency = app('amount')->getNativeCurrency();+ $defaultCurrency = app('amount')->getPrimaryCurrency();$converter = new ExchangeRateConverter();/** @var Budget $budget */diff --git a/app/Repositories/Budget/OperationsRepository.php b/app/Repositories/Budget/OperationsRepository.phpindex b98b8a4393..36b4ec7282 100644--- a/app/Repositories/Budget/OperationsRepository.php+++ b/app/Repositories/Budget/OperationsRepository.php@@ -142,7 +142,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn$array = [];// if needs conversion to native.- $convertToNative = Amount::convertToNative($this->user);+ $convertToNative = Amount::convertToPrimary($this->user);$nativeCurrency = Amount::getPrimaryCurrencyByUserGroup($this->userGroup);$currencyId = (int) $nativeCurrency->id;$currencyCode = $nativeCurrency->code;diff --git a/app/Repositories/Category/OperationsRepository.php b/app/Repositories/Category/OperationsRepository.phpindex 051769c563..7a6a273012 100644--- a/app/Repositories/Category/OperationsRepository.php+++ b/app/Repositories/Category/OperationsRepository.php@@ -358,8 +358,8 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn}$collector->setCategories($categories);$journals = $collector->getExtractedJournals();- $convertToNative = Amount::convertToNative($this->user);- $default = Amount::getNativeCurrency();+ $convertToNative = Amount::convertToPrimary($this->user);+ $default = Amount::getPrimaryCurrency();$array = [];foreach ($journals as $journal) {diff --git a/app/Repositories/UserGroups/Bill/BillRepository.php b/app/Repositories/UserGroups/Bill/BillRepository.phpindex df61518b1c..81103c8d6c 100644--- a/app/Repositories/UserGroups/Bill/BillRepository.php+++ b/app/Repositories/UserGroups/Bill/BillRepository.php@@ -71,7 +71,7 @@ class BillRepository implements BillRepositoryInterface{Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));$bills = $this->getActiveBills();- $default = app('amount')->getNativeCurrency();+ $default = app('amount')->getPrimaryCurrency();$return = [];$converter = new ExchangeRateConverter();@@ -141,7 +141,7 @@ class BillRepository implements BillRepositoryInterfaceLog::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));$bills = $this->getActiveBills();$return = [];- $default = app('amount')->getNativeCurrency();+ $default = app('amount')->getPrimaryCurrency();$converter = new ExchangeRateConverter();/** @var Bill $bill */diff --git a/app/Repositories/UserGroups/Budget/AvailableBudgetRepository.php b/app/Repositories/UserGroups/Budget/AvailableBudgetRepository.phpindex 277832c924..d024ff1d9c 100644--- a/app/Repositories/UserGroups/Budget/AvailableBudgetRepository.php+++ b/app/Repositories/UserGroups/Budget/AvailableBudgetRepository.php@@ -44,7 +44,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterfaceLog::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));$return = [];$converter = new ExchangeRateConverter();- $default = app('amount')->getNativeCurrency();+ $default = app('amount')->getPrimaryCurrency();$availableBudgets = $this->userGroup->availableBudgets()->where('start_date', $start->format('Y-m-d'))->where('end_date', $end->format('Y-m-d'))->get()diff --git a/app/Support/Amount.php b/app/Support/Amount.phpindex c167e14d24..e09c7447d4 100644--- a/app/Support/Amount.php+++ b/app/Support/Amount.php@@ -101,13 +101,13 @@ class Amount*/public function getAmountFromJournal(array $journal): string{- $convertToNative = $this->convertToNative();- $currency = $this->getNativeCurrency();- $field = $convertToNative && $currency->id !== $journal['currency_id'] ? 'native_amount' : 'amount';+ $convertToPrimary = $this->convertToPrimary();+ $currency = $this->getPrimaryCurrency();+ $field = $convertToPrimary && $currency->id !== $journal['currency_id'] ? 'native_amount' : 'amount';$amount = $journal[$field] ?? '0';// Log::debug(sprintf('Field is %s, amount is %s', $field, $amount));// fallback, the transaction has a foreign amount in $currency.- if ($convertToNative && null !== $journal['foreign_amount'] && $currency->id === (int)$journal['foreign_currency_id']) {+ if ($convertToPrimary && null !== $journal['foreign_amount'] && $currency->id === (int)$journal['foreign_currency_id']) {$amount = $journal['foreign_amount'];// Log::debug(sprintf('Overruled, amount is now %s', $amount));}@@ -115,7 +115,7 @@ class Amountreturn (string)$amount;}- public function convertToNative(?User $user = null): bool+ public function convertToPrimary(?User $user = null): bool{if (!$user instanceof User) {return true === Preferences::get('convert_to_native', false)->data && true === config('cer.enabled');@@ -124,13 +124,13 @@ class Amountreturn true === Preferences::getForUser($user, 'convert_to_native', false)->data && true === config('cer.enabled');}- public function getNativeCurrency(): TransactionCurrency+ public function getPrimaryCurrency(): TransactionCurrency{if (auth()->check()) {/** @var User $user */$user = auth()->user();if (null !== $user->userGroup) {- return $this->getNativeCurrencyByUserGroup($user->userGroup);+ return $this->getPrimaryCurrencyByUserGroup($user->userGroup);}}@@ -169,9 +169,9 @@ class Amount*/public function getAmountFromJournalObject(TransactionJournal $journal): string{- $convertToNative = $this->convertToNative();- $currency = $this->getNativeCurrency();- $field = $convertToNative && $currency->id !== $journal->transaction_currency_id ? 'native_amount' : 'amount';+ $convertToPrimary = $this->convertToPrimary();+ $currency = $this->getPrimaryCurrency();+ $field = $convertToPrimary && $currency->id !== $journal->transaction_currency_id ? 'native_amount' : 'amount';/** @var null|Transaction $sourceTransaction */$sourceTransaction = $journal->transactions()->where('amount', '<', 0)->first();@@ -195,24 +195,6 @@ class Amountreturn $user->currencies()->orderBy('code', 'ASC')->get();}- #[Deprecated]- public function getDefaultCurrency(): TransactionCurrency- {- return $this->getNativeCurrency();- }-- #[Deprecated(message: 'use getDefaultCurrencyByUserGroup instead')]- public function getDefaultCurrencyByUser(User $user): TransactionCurrency- {- return $this->getDefaultCurrencyByUserGroup($user->userGroup);- }-- #[Deprecated]- public function getDefaultCurrencyByUserGroup(UserGroup $userGroup): TransactionCurrency- {- return $this->getNativeCurrencyByUserGroup($userGroup);- }-/*** This method returns the correct format rules required by accounting.js,* the library used to format amounts in charts.diff --git a/app/Support/Export/ExportDataGenerator.php b/app/Support/Export/ExportDataGenerator.phpindex 78145d74e9..1364eec115 100644--- a/app/Support/Export/ExportDataGenerator.php+++ b/app/Support/Export/ExportDataGenerator.php@@ -738,7 +738,7 @@ class ExportDataGenerator$metaFields = config('firefly.journal_meta_fields');$header = array_merge($header, $metaFields);- $default = Amount::getNativeCurrency();+ $default = Amount::getPrimaryCurrency();$collector = app(GroupCollectorInterface::class);$collector->setUser($this->user);diff --git a/app/Support/Form/CurrencyForm.php b/app/Support/Form/CurrencyForm.phpindex 0ac0b07f62..c947e7b192 100644--- a/app/Support/Form/CurrencyForm.php+++ b/app/Support/Form/CurrencyForm.php@@ -61,7 +61,7 @@ class CurrencyForm$classes = $this->getHolderClasses($name);$value = $this->fillFieldValue($name, $value);$options['step'] = 'any';- $defaultCurrency = $options['currency'] ?? app('amount')->getNativeCurrency();+ $defaultCurrency = $options['currency'] ?? app('amount')->getPrimaryCurrency();/** @var Collection $currencies */$currencies = app('amount')->getCurrencies();@@ -129,7 +129,7 @@ class CurrencyForm$classes = $this->getHolderClasses($name);$value = $this->fillFieldValue($name, $value);$options['step'] = 'any';- $defaultCurrency = $options['currency'] ?? app('amount')->getNativeCurrency();+ $defaultCurrency = $options['currency'] ?? app('amount')->getPrimaryCurrency();/** @var Collection $currencies */$currencies = app('amount')->getAllCurrencies();diff --git a/app/Support/Http/Controllers/ChartGeneration.php b/app/Support/Http/Controllers/ChartGeneration.phpindex 1680a3ec5b..689e03de6a 100644--- a/app/Support/Http/Controllers/ChartGeneration.php+++ b/app/Support/Http/Controllers/ChartGeneration.php@@ -48,7 +48,7 @@ trait ChartGenerationprotected function accountBalanceChart(Collection $accounts, Carbon $start, Carbon $end): array // chart helper method.{// chart properties for cache:- $convertToNative = Amount::convertToNative();+ $convertToNative = Amount::convertToPrimary();$cache = new CacheProperties();$cache->addProperty($start);$cache->addProperty($end);@@ -67,7 +67,7 @@ trait ChartGeneration/** @var AccountRepositoryInterface $accountRepos */$accountRepos = app(AccountRepositoryInterface::class);- $default = app('amount')->getNativeCurrency();+ $default = app('amount')->getPrimaryCurrency();$chartData = [];Log::debug(sprintf('Start of accountBalanceChart(list, %s, %s)', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));diff --git a/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php b/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.phpindex 41567cf529..3d4f373c68 100644--- a/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php+++ b/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php@@ -54,7 +54,7 @@ class TransactionGroupEnrichment implements EnrichmentInterfaceprivate array $notes; // @phpstan-ignore-lineprivate array $tags;private User $user;- private readonly TransactionCurrency $nativeCurrency;+ private readonly TransactionCurrency $primaryCurrency;private UserGroup $userGroup;public function __construct()@@ -66,7 +66,7 @@ class TransactionGroupEnrichment implements EnrichmentInterface$this->locations = [];$this->attachmentCount = [];$this->dateFields = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date'];- $this->nativeCurrency = Amount::getNativeCurrency();+ $this->primaryCurrency = Amount::getPrimaryCurrency();}#[Override]@@ -198,9 +198,9 @@ class TransactionGroupEnrichment implements EnrichmentInterface$metaData = $this->metaData;$locations = $this->locations;$attachmentCount = $this->attachmentCount;- $nativeCurrency = $this->nativeCurrency;+ $primaryCurrency = $this->primaryCurrency;- $this->collection = $this->collection->map(function (array $item) use ($nativeCurrency, $notes, $tags, $metaData, $locations, $attachmentCount) {+ $this->collection = $this->collection->map(function (array $item) use ($primaryCurrency, $notes, $tags, $metaData, $locations, $attachmentCount) {foreach ($item['transactions'] as $index => $transaction) {$journalId = (int) $transaction['transaction_journal_id'];@@ -220,13 +220,13 @@ class TransactionGroupEnrichment implements EnrichmentInterface'zoom_level' => null,];- // native currency- $item['transactions'][$index]['native_currency'] = [- 'id' => (string) $nativeCurrency->id,- 'code' => $nativeCurrency->code,- 'name' => $nativeCurrency->name,- 'symbol' => $nativeCurrency->symbol,- 'decimal_places' => $nativeCurrency->decimal_places,+ // primary currency+ $item['transactions'][$index]['primary_currency'] = [+ 'id' => (string) $primaryCurrency->id,+ 'code' => $primaryCurrency->code,+ 'name' => $primaryCurrency->name,+ 'symbol' => $primaryCurrency->symbol,+ 'decimal_places' => $primaryCurrency->decimal_places,];// append meta datadiff --git a/app/Support/Report/Summarizer/TransactionSummarizer.php b/app/Support/Report/Summarizer/TransactionSummarizer.phpindex f5ef8f00e9..1306a491ba 100644--- a/app/Support/Report/Summarizer/TransactionSummarizer.php+++ b/app/Support/Report/Summarizer/TransactionSummarizer.php@@ -46,7 +46,7 @@ class TransactionSummarizer{$this->user = $user;$this->default = Amount::getPrimaryCurrencyByUserGroup($user->userGroup);- $this->convertToNative = Amount::convertToNative($user);+ $this->convertToNative = Amount::convertToPrimary($user);}public function groupByCurrencyId(array $journals, string $method = 'negative', bool $includeForeign = true): array@@ -159,7 +159,7 @@ class TransactionSummarizer$array = [];$idKey = sprintf('%s_account_id', $direction);$nameKey = sprintf('%s_account_name', $direction);- $convertToNative = Amount::convertToNative($this->user);+ $convertToNative = Amount::convertToPrimary($this->user);$default = Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);diff --git a/app/Support/Steam.php b/app/Support/Steam.phpindex 43f9a81920..d4b301e9e1 100644--- a/app/Support/Steam.php+++ b/app/Support/Steam.php@@ -93,7 +93,7 @@ class Steamreturn [];}- $defaultCurrency = Amount::getNativeCurrency();+ $defaultCurrency = Amount::getPrimaryCurrency();if ($convertToNative) {if ($defaultCurrency->id === $currency?->id) {Log::debug(sprintf('Unset [%s] for account #%d (no longer unset "native_balance")', $defaultCurrency->code, $account->id));@@ -344,7 +344,7 @@ class Steam}// Log::debug(sprintf('finalAccountBalance(#%d, %s)', $account->id, $date->format('Y-m-d H:i:s')));if (null === $convertToNative) {- $convertToNative = Amount::convertToNative($account->user);+ $convertToNative = Amount::convertToPrimary($account->user);}if (!$native instanceof TransactionCurrency) {$native = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);diff --git a/app/Support/Twig/AmountFormat.php b/app/Support/Twig/AmountFormat.phpindex 70581d32a9..97bf5ff0c3 100644--- a/app/Support/Twig/AmountFormat.php+++ b/app/Support/Twig/AmountFormat.php@@ -52,7 +52,7 @@ class AmountFormat extends AbstractExtensionreturn new TwigFilter('formatAmount',static function (string $string): string {- $currency = app('amount')->getNativeCurrency();+ $currency = app('amount')->getPrimaryCurrency();return app('amount')->formatAnything($currency, $string, true);},@@ -65,7 +65,7 @@ class AmountFormat extends AbstractExtensionreturn new TwigFilter('formatAmountPlain',static function (string $string): string {- $currency = app('amount')->getNativeCurrency();+ $currency = app('amount')->getPrimaryCurrency();return app('amount')->formatAnything($currency, $string, false);},@@ -98,7 +98,7 @@ class AmountFormat extends AbstractExtension/** @var AccountRepositoryInterface $accountRepos */$accountRepos = app(AccountRepositoryInterface::class);- $currency = $accountRepos->getAccountCurrency($account) ?? app('amount')->getNativeCurrency();+ $currency = $accountRepos->getAccountCurrency($account) ?? app('amount')->getPrimaryCurrency();return app('amount')->formatAnything($currency, $amount, $coloured);},@@ -157,7 +157,7 @@ class AmountFormat extends AbstractExtension$currency = TransactionCurrency::whereCode($code)->first();if (null === $currency) {Log::error(sprintf('Could not find currency with code "%s". Fallback to native currency.', $code));- $currency = Amount::getNativeCurrency();+ $currency = Amount::getPrimaryCurrency();Log::error(sprintf('Fallback currency is "%s".', $currency->code));}diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.phpindex 61cbd5eba4..9f0a145b35 100644--- a/app/Support/Twig/General.php+++ b/app/Support/Twig/General.php@@ -75,8 +75,8 @@ class General extends AbstractExtensionLog::debug(sprintf('twig balance: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));$info = Steam::finalAccountBalance($account, $date);$currency = Steam::getAccountCurrency($account);- $default = Amount::getNativeCurrency();- $convertToNative = Amount::convertToNative();+ $default = Amount::getPrimaryCurrency();+ $convertToNative = Amount::convertToPrimary();$useNative = $convertToNative && $default->id !== $currency->id;$currency ??= $default;$strings = [];diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.phpindex f995606de1..e7b5603d8c 100644--- a/app/Transformers/AccountTransformer.php+++ b/app/Transformers/AccountTransformer.php@@ -51,8 +51,8 @@ class AccountTransformer extends AbstractTransformer{$this->parameters = new ParameterBag();$this->repository = app(AccountRepositoryInterface::class);- $this->convertToNative = Amount::convertToNative();- $this->native = Amount::getNativeCurrency();+ $this->convertToNative = Amount::convertToPrimary();+ $this->native = Amount::getPrimaryCurrency();}/**diff --git a/app/Transformers/AvailableBudgetTransformer.php b/app/Transformers/AvailableBudgetTransformer.phpindex fb34c8c9b1..56846f025d 100644--- a/app/Transformers/AvailableBudgetTransformer.php+++ b/app/Transformers/AvailableBudgetTransformer.php@@ -50,8 +50,8 @@ class AvailableBudgetTransformer extends AbstractTransformer$this->repository = app(BudgetRepositoryInterface::class);$this->opsRepository = app(OperationsRepositoryInterface::class);$this->noBudgetRepository = app(NoBudgetRepositoryInterface::class);- $this->default = Amount::getNativeCurrency();- $this->convertToNative = Amount::convertToNative();+ $this->default = Amount::getPrimaryCurrency();+ $this->convertToNative = Amount::convertToPrimary();}/**diff --git a/app/Transformers/BillTransformer.php b/app/Transformers/BillTransformer.phpindex 5318d08533..0c7586e10a 100644--- a/app/Transformers/BillTransformer.php+++ b/app/Transformers/BillTransformer.php@@ -40,7 +40,7 @@ class BillTransformer extends AbstractTransformer*/public function __construct(){- $this->native = Amount::getNativeCurrency();+ $this->native = Amount::getPrimaryCurrency();}/**diff --git a/app/Transformers/BudgetLimitTransformer.php b/app/Transformers/BudgetLimitTransformer.phpindex bc43a51f9e..3a46e8591f 100644--- a/app/Transformers/BudgetLimitTransformer.php+++ b/app/Transformers/BudgetLimitTransformer.php@@ -46,8 +46,8 @@ class BudgetLimitTransformer extends AbstractTransformerpublic function __construct(){- $this->default = Amount::getNativeCurrency();- $this->convertToNative = Amount::convertToNative();+ $this->default = Amount::getPrimaryCurrency();+ $this->convertToNative = Amount::convertToPrimary();}/**diff --git a/app/Transformers/BudgetTransformer.php b/app/Transformers/BudgetTransformer.phpindex d028143c41..24b3816327 100644--- a/app/Transformers/BudgetTransformer.php+++ b/app/Transformers/BudgetTransformer.php@@ -51,8 +51,8 @@ class BudgetTransformer extends AbstractTransformer$this->opsRepository = app(OperationsRepositoryInterface::class);$this->repository = app(BudgetRepositoryInterface::class);$this->parameters = new ParameterBag();- $this->default = Amount::getNativeCurrency();- $this->convertToNative = Amount::convertToNative();+ $this->default = Amount::getPrimaryCurrency();+ $this->convertToNative = Amount::convertToPrimary();}/**diff --git a/app/Transformers/CategoryTransformer.php b/app/Transformers/CategoryTransformer.phpindex f7090cec3b..21c8b7f296 100644--- a/app/Transformers/CategoryTransformer.php+++ b/app/Transformers/CategoryTransformer.php@@ -48,8 +48,8 @@ class CategoryTransformer extends AbstractTransformer{$this->opsRepository = app(OperationsRepositoryInterface::class);$this->repository = app(CategoryRepositoryInterface::class);- $this->default = Amount::getNativeCurrency();- $this->convertToNative = Amount::convertToNative();+ $this->default = Amount::getPrimaryCurrency();+ $this->convertToNative = Amount::convertToPrimary();}/**diff --git a/app/Transformers/TransactionGroupTransformer.php b/app/Transformers/TransactionGroupTransformer.phpindex ccf4c6c0ab..ea3b57c713 100644--- a/app/Transformers/TransactionGroupTransformer.php+++ b/app/Transformers/TransactionGroupTransformer.php@@ -122,13 +122,13 @@ class TransactionGroupTransformer extends AbstractTransformer$foreignAmount = app('steam')->positive($transaction['foreign_amount']);}- // set native amount to the normal amount if the currency matches.- if ($transaction['native_currency']['id'] ?? null === $transaction['currency_id']) {- $transaction['native_amount'] = $amount;+ // set primary amount to the normal amount if the currency matches.+ if ($transaction['primary_currency']['id'] ?? null === $transaction['currency_id']) {+ $transaction['pc_amount'] = $amount;}- if (array_key_exists('native_amount', $transaction) && null !== $transaction['native_amount']) {- $transaction['native_amount'] = app('steam')->positive($transaction['native_amount']);+ if (array_key_exists('pc_amount', $transaction) && null !== $transaction['pc_amount']) {+ $transaction['pc_amount'] = app('steam')->positive($transaction['pc_amount']);}$type = $this->stringFromArray($transaction, 'transaction_type_type', TransactionTypeEnum::WITHDRAWAL->value);@@ -160,15 +160,15 @@ class TransactionGroupTransformer extends AbstractTransformer'amount' => $amount,'foreign_amount' => $foreignAmount,- // native amount, defaults to NULL when convertToNative is false.- 'native_amount' => $transaction['native_amount'] ?? null,+ // primary currency amount, defaults to NULL when convertToPrimary is false.+ 'pc_amount' => $transaction['pc_amount'] ?? null,- // native currency, always present.- 'native_currency_id' => $transaction['native_currency']['id'] ?? null,- 'native_currency_code' => $transaction['native_currency']['code'] ?? null,- 'native_currency_name' => $transaction['native_currency']['name'] ?? null,- 'native_currency_symbol' => $transaction['native_currency']['symbol'] ?? null,- 'native_currency_decimal_places' => $transaction['native_currency']['decimal_places'] ?? null,+ // primary currency, always present.+ 'primary_currency_id' => $transaction['primary_currency']['id'] ?? null,+ 'primary_currency_code' => $transaction['primary_currency']['code'] ?? null,+ 'primary_currency_name' => $transaction['primary_currency']['name'] ?? null,+ 'primary_currency_symbol' => $transaction['primary_currency']['symbol'] ?? null,+ 'primary_currency_decimal_places' => $transaction['primary_currency']['decimal_places'] ?? null,// source balance after'source_balance_after' => $transaction['source_balance_after'] ?? null,diff --git a/app/Transformers/V2/AccountTransformer.php b/app/Transformers/V2/AccountTransformer.phpindex 4b7e9f58bc..ed7cec916e 100644--- a/app/Transformers/V2/AccountTransformer.php+++ b/app/Transformers/V2/AccountTransformer.php@@ -136,7 +136,7 @@ class AccountTransformer extends AbstractTransformerprivate function getDefaultCurrency(): void{- $this->default = app('amount')->getNativeCurrency();+ $this->default = app('amount')->getPrimaryCurrency();}private function collectAccountMetaData(Collection $accounts): voiddiff --git a/app/Transformers/V2/BillTransformer.php b/app/Transformers/V2/BillTransformer.phpindex 79d18c671a..36bfaffaf8 100644--- a/app/Transformers/V2/BillTransformer.php+++ b/app/Transformers/V2/BillTransformer.php@@ -99,7 +99,7 @@ class BillTransformer extends AbstractTransformer];}Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));- $this->default = app('amount')->getNativeCurrency();+ $this->default = app('amount')->getPrimaryCurrency();$this->converter = new ExchangeRateConverter();// grab all paid dates:diff --git a/app/Transformers/V2/TransactionGroupTransformer.php b/app/Transformers/V2/TransactionGroupTransformer.phpindex e9f3b12128..66077a857a 100644--- a/app/Transformers/V2/TransactionGroupTransformer.php+++ b/app/Transformers/V2/TransactionGroupTransformer.php@@ -82,7 +82,7 @@ class TransactionGroupTransformer extends AbstractTransformer}}- $this->default = app('amount')->getNativeCurrency();+ $this->default = app('amount')->getPrimaryCurrency();$this->converter = new ExchangeRateConverter();$this->collectAllMetaData();diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.phpindex c56c976c16..5352c0e9c1 100644--- a/app/Validation/TransactionValidation.php+++ b/app/Validation/TransactionValidation.php@@ -224,7 +224,7 @@ trait TransactionValidation/** @var AccountRepository $accountRepository */$accountRepository = app(AccountRepositoryInterface::class);- $defaultCurrency = app('amount')->getNativeCurrency();+ $defaultCurrency = app('amount')->getPrimaryCurrency();$sourceCurrency = $accountRepository->getAccountCurrency($source) ?? $defaultCurrency;$destinationCurrency = $accountRepository->getAccountCurrency($destination) ?? $defaultCurrency;// if both accounts have the same currency, continue.