mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 02:36:28 +00:00 
			
		
		
		
	Rename many references from native to primary.
This commit is contained in:
		| @@ -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); | ||||
|                 } | ||||
| 
 | ||||
|   | ||||
| @@ -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.
 | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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.
 | ||||
|   | ||||
| @@ -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          = []; | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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); | ||||
|             } | ||||
|   | ||||
| @@ -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:
 | ||||
| 
 | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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     = []; | ||||
|   | ||||
| @@ -119,7 +119,7 @@ class BasicController extends Controller | ||||
|     private 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(); | ||||
| 
 | ||||
|   | ||||
| @@ -126,7 +126,7 @@ class PiggyBankFactory | ||||
|     private 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'] ?? '')); | ||||
|   | ||||
| @@ -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'); | ||||
| 
 | ||||
|   | ||||
| @@ -49,7 +49,7 @@ class AccountObserver | ||||
| 
 | ||||
|     private function updateNativeAmount(Account $account): void | ||||
|     { | ||||
|         if (!Amount::convertToNative($account->user)) { | ||||
|         if (!Amount::convertToPrimary($account->user)) { | ||||
|             return; | ||||
|         } | ||||
|         $userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup); | ||||
|   | ||||
| @@ -39,7 +39,7 @@ class AutoBudgetObserver | ||||
| 
 | ||||
|     private 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); | ||||
|   | ||||
| @@ -39,7 +39,7 @@ class AvailableBudgetObserver | ||||
| 
 | ||||
|     private 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; | ||||
|   | ||||
| @@ -43,7 +43,7 @@ class BillObserver | ||||
| 
 | ||||
|     private function updateNativeAmount(Bill $bill): void | ||||
|     { | ||||
|         if (!Amount::convertToNative($bill->user)) { | ||||
|         if (!Amount::convertToPrimary($bill->user)) { | ||||
|             return; | ||||
|         } | ||||
|         $userCurrency            = app('amount')->getPrimaryCurrencyByUserGroup($bill->user->userGroup); | ||||
|   | ||||
| @@ -39,7 +39,7 @@ class BudgetLimitObserver | ||||
| 
 | ||||
|     private 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; | ||||
|   | ||||
| @@ -45,7 +45,7 @@ class PiggyBankEventObserver | ||||
| 
 | ||||
|             return; | ||||
|         } | ||||
|         if (!Amount::convertToNative($user)) { | ||||
|         if (!Amount::convertToPrimary($user)) { | ||||
|             return; | ||||
|         } | ||||
|         $userCurrency         = app('amount')->getPrimaryCurrencyByUserGroup($event->piggyBank->accounts()->first()->user->userGroup); | ||||
|   | ||||
| @@ -50,7 +50,7 @@ class TransactionObserver | ||||
| 
 | ||||
|     private 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); | ||||
|   | ||||
| @@ -64,7 +64,7 @@ class NetWorth implements NetWorthInterface | ||||
|     public 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 NetWorthInterface | ||||
|             return $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); | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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(), | ||||
|   | ||||
| @@ -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 */ | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -357,7 +357,7 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac | ||||
|         if (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 */ | ||||
|   | ||||
| @@ -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, UserGroupInterface | ||||
|         Log::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, UserGroupInterface | ||||
|         app('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) { | ||||
|   | ||||
| @@ -142,8 +142,8 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface, U | ||||
|         Log::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) { | ||||
|   | ||||
| @@ -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 */ | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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) { | ||||
|   | ||||
| @@ -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 BillRepositoryInterface | ||||
|         Log::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 */ | ||||
|   | ||||
| @@ -44,7 +44,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface | ||||
|         Log::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() | ||||
|   | ||||
| @@ -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 Amount | ||||
|         return (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 Amount | ||||
|         return 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 Amount | ||||
|         return $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. | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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(); | ||||
|   | ||||
| @@ -48,7 +48,7 @@ trait ChartGeneration | ||||
|     protected 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'))); | ||||
|   | ||||
| @@ -54,7 +54,7 @@ class TransactionGroupEnrichment implements EnrichmentInterface | ||||
|     private array          $notes; // @phpstan-ignore-line
 | ||||
|     private 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 data
 | ||||
|   | ||||
| @@ -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); | ||||
| 
 | ||||
| 
 | ||||
|   | ||||
| @@ -93,7 +93,7 @@ class Steam | ||||
| 
 | ||||
|             return []; | ||||
|         } | ||||
|         $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); | ||||
|   | ||||
| @@ -52,7 +52,7 @@ class AmountFormat extends AbstractExtension | ||||
|         return 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 AbstractExtension | ||||
|         return 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)); | ||||
|                 } | ||||
| 
 | ||||
|   | ||||
| @@ -75,8 +75,8 @@ class General extends AbstractExtension | ||||
|                 Log::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         = []; | ||||
|   | ||||
| @@ -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(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|   | ||||
| @@ -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(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|   | ||||
| @@ -40,7 +40,7 @@ class BillTransformer extends AbstractTransformer | ||||
|      */ | ||||
|     public function __construct() | ||||
|     { | ||||
|         $this->native = Amount::getNativeCurrency(); | ||||
|         $this->native = Amount::getPrimaryCurrency(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|   | ||||
| @@ -46,8 +46,8 @@ class BudgetLimitTransformer extends AbstractTransformer | ||||
| 
 | ||||
|     public function __construct() | ||||
|     { | ||||
|         $this->default         = Amount::getNativeCurrency(); | ||||
|         $this->convertToNative = Amount::convertToNative(); | ||||
|         $this->default         = Amount::getPrimaryCurrency(); | ||||
|         $this->convertToNative = Amount::convertToPrimary(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|   | ||||
| @@ -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(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|   | ||||
| @@ -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(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|   | ||||
| @@ -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, | ||||
|   | ||||
| @@ -136,7 +136,7 @@ class AccountTransformer extends AbstractTransformer | ||||
| 
 | ||||
|     private function getDefaultCurrency(): void | ||||
|     { | ||||
|         $this->default = app('amount')->getNativeCurrency(); | ||||
|         $this->default = app('amount')->getPrimaryCurrency(); | ||||
|     } | ||||
| 
 | ||||
|     private function collectAccountMetaData(Collection $accounts): void | ||||
|   | ||||
| @@ -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:
 | ||||
|   | ||||
| @@ -82,7 +82,7 @@ class TransactionGroupTransformer extends AbstractTransformer | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         $this->default     = app('amount')->getNativeCurrency(); | ||||
|         $this->default     = app('amount')->getPrimaryCurrency(); | ||||
|         $this->converter   = new ExchangeRateConverter(); | ||||
| 
 | ||||
|         $this->collectAllMetaData(); | ||||
|   | ||||
| @@ -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.
 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user