Rename many references from native to primary.

This commit is contained in:
James Cole
2025-07-31 20:24:19 +02:00
parent 210bd83bd4
commit 6d3f2bd5e7
59 changed files with 128 additions and 146 deletions

View File

@@ -84,8 +84,8 @@ abstract class Controller extends BaseController
$this->parameters = $this->getParameters(); $this->parameters = $this->getParameters();
if (auth()->check()) { if (auth()->check()) {
$language = Steam::getLanguage(); $language = Steam::getLanguage();
$this->convertToNative = Amount::convertToNative(); $this->convertToNative = Amount::convertToPrimary();
$this->nativeCurrency = Amount::getNativeCurrency(); $this->nativeCurrency = Amount::getPrimaryCurrency();
app()->setLocale($language); app()->setLocale($language);
} }

View File

@@ -69,8 +69,8 @@ class BillController extends Controller
$bills = $request->getBills(); $bills = $request->getBills();
$start = $request->getStart(); $start = $request->getStart();
$end = $request->getEnd(); $end = $request->getEnd();
$convertToNative = Amount::convertToNative(); $convertToNative = Amount::convertToPrimary();
$default = Amount::getNativeCurrency(); $default = Amount::getPrimaryCurrency();
$response = []; $response = [];
// get all bills: // get all bills:
@@ -132,8 +132,8 @@ class BillController extends Controller
$accounts = $request->getAssetAccounts(); $accounts = $request->getAssetAccounts();
$start = $request->getStart(); $start = $request->getStart();
$end = $request->getEnd(); $end = $request->getEnd();
$convertToNative = Amount::convertToNative(); $convertToNative = Amount::convertToPrimary();
$default = Amount::getNativeCurrency(); $default = Amount::getPrimaryCurrency();
$response = []; $response = [];
// collect all expenses in this period (regardless of type) by the given bills and accounts. // collect all expenses in this period (regardless of type) by the given bills and accounts.

View File

@@ -47,8 +47,8 @@ class PeriodController extends Controller
$start = $request->getStart(); $start = $request->getStart();
$end = $request->getEnd(); $end = $request->getEnd();
$response = []; $response = [];
$convertToNative = Amount::convertToNative(); $convertToNative = Amount::convertToPrimary();
$default = Amount::getNativeCurrency(); $default = Amount::getPrimaryCurrency();
// collect all expenses in this period (regardless of type) // collect all expenses in this period (regardless of type)
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);

View File

@@ -68,8 +68,8 @@ class TagController extends Controller
$start = $request->getStart(); $start = $request->getStart();
$end = $request->getEnd(); $end = $request->getEnd();
$response = []; $response = [];
$convertToNative = Amount::convertToNative(); $convertToNative = Amount::convertToPrimary();
$default = Amount::getNativeCurrency(); $default = Amount::getPrimaryCurrency();
// collect all expenses in this period (regardless of type) by the given bills and accounts. // collect all expenses in this period (regardless of type) by the given bills and accounts.
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);

View File

@@ -46,8 +46,8 @@ class PeriodController extends Controller
$start = $request->getStart(); $start = $request->getStart();
$end = $request->getEnd(); $end = $request->getEnd();
$response = []; $response = [];
$convertToNative = Amount::convertToNative(); $convertToNative = Amount::convertToPrimary();
$default = Amount::getNativeCurrency(); $default = Amount::getPrimaryCurrency();
// collect all expenses in this period (regardless of type) // collect all expenses in this period (regardless of type)
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);

View File

@@ -68,8 +68,8 @@ class TagController extends Controller
$start = $request->getStart(); $start = $request->getStart();
$end = $request->getEnd(); $end = $request->getEnd();
$response = []; $response = [];
$convertToNative = Amount::convertToNative(); $convertToNative = Amount::convertToPrimary();
$default = Amount::getNativeCurrency(); $default = Amount::getPrimaryCurrency();
// collect all expenses in this period (regardless of type) by the given bills and accounts. // collect all expenses in this period (regardless of type) by the given bills and accounts.
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);

View File

@@ -46,8 +46,8 @@ class PeriodController extends Controller
$start = $request->getStart(); $start = $request->getStart();
$end = $request->getEnd(); $end = $request->getEnd();
$response = []; $response = [];
$convertToNative = Amount::convertToNative(); $convertToNative = Amount::convertToPrimary();
$default = Amount::getNativeCurrency(); $default = Amount::getPrimaryCurrency();
// collect all expenses in this period (regardless of type) // collect all expenses in this period (regardless of type)
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);

View File

@@ -66,8 +66,8 @@ class TagController extends Controller
$start = $request->getStart(); $start = $request->getStart();
$end = $request->getEnd(); $end = $request->getEnd();
$response = []; $response = [];
$convertToNative = Amount::convertToNative(); $convertToNative = Amount::convertToPrimary();
$default = Amount::getNativeCurrency(); $default = Amount::getPrimaryCurrency();
// collect all expenses in this period (regardless of type) by the given bills and accounts. // collect all expenses in this period (regardless of type) by the given bills and accounts.

View File

@@ -127,8 +127,8 @@ class BasicController extends Controller
{ {
Log::debug('getBalanceInformation'); Log::debug('getBalanceInformation');
// some config settings // some config settings
$convertToNative = Amount::convertToNative(); $convertToNative = Amount::convertToPrimary();
$default = Amount::getNativeCurrency(); $default = Amount::getPrimaryCurrency();
// prep some arrays: // prep some arrays:
$sums = []; $sums = [];
$return = []; $return = [];

View File

@@ -55,7 +55,7 @@ class AccountController extends Controller
$userGroup = $this->validateUserGroup($request); $userGroup = $this->validateUserGroup($request);
$this->repository = app(AccountRepositoryInterface::class); $this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUserGroup($userGroup); $this->repository->setUserGroup($userGroup);
$this->default = app('amount')->getNativeCurrency(); $this->default = app('amount')->getPrimaryCurrency();
$this->converter = app(ExchangeRateConverter::class); $this->converter = app(ExchangeRateConverter::class);
return $next($request); return $next($request);

View File

@@ -58,7 +58,7 @@ class AccountController extends Controller
$this->repository = app(AccountRepositoryInterface::class); $this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request)); $this->repository->setUserGroup($this->validateUserGroup($request));
$this->chartData = new ChartData(); $this->chartData = new ChartData();
$this->default = app('amount')->getNativeCurrency(); $this->default = app('amount')->getPrimaryCurrency();
return $next($request); return $next($request);
} }

View File

@@ -62,7 +62,7 @@ class BalanceController extends Controller
$this->repository->setUserGroup($userGroup); $this->repository->setUserGroup($userGroup);
$this->collector->setUserGroup($userGroup); $this->collector->setUserGroup($userGroup);
$this->chartData = new ChartData(); $this->chartData = new ChartData();
// $this->default = app('amount')->getNativeCurrency(); // $this->default = app('amount')->getPrimaryCurrency();
return $next($request); return $next($request);
} }
@@ -87,7 +87,7 @@ class BalanceController extends Controller
// prepare for currency conversion and data collection: // prepare for currency conversion and data collection:
/** @var TransactionCurrency $default */ /** @var TransactionCurrency $default */
$default = app('amount')->getNativeCurrency(); $default = app('amount')->getPrimaryCurrency();
// get journals for entire period: // get journals for entire period:

View File

@@ -63,7 +63,7 @@ class BudgetController extends Controller
$this->repository = app(BudgetRepositoryInterface::class); $this->repository = app(BudgetRepositoryInterface::class);
$this->blRepository = app(BudgetLimitRepositoryInterface::class); $this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->opsRepository = app(OperationsRepositoryInterface::class); $this->opsRepository = app(OperationsRepositoryInterface::class);
$this->currency = app('amount')->getNativeCurrency(); $this->currency = app('amount')->getPrimaryCurrency();
$userGroup = $this->validateUserGroup($request); $userGroup = $this->validateUserGroup($request);
$this->repository->setUserGroup($userGroup); $this->repository->setUserGroup($userGroup);
$this->opsRepository->setUserGroup($userGroup); $this->opsRepository->setUserGroup($userGroup);

View File

@@ -82,7 +82,7 @@ class CategoryController extends Controller
/** @var Carbon $end */ /** @var Carbon $end */
$end = $this->parameters->get('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]); $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(); $converter = new ExchangeRateConverter();
$currencies = []; $currencies = [];
$return = []; $return = [];

View File

@@ -119,7 +119,7 @@ class BasicController extends Controller
private function getBalanceInformation(Carbon $start, Carbon $end): array private function getBalanceInformation(Carbon $start, Carbon $end): array
{ {
$object = new SummaryBalanceGrouped(); $object = new SummaryBalanceGrouped();
$default = app('amount')->getNativeCurrency(); $default = app('amount')->getPrimaryCurrency();
$object->setDefault($default); $object->setDefault($default);
@@ -234,7 +234,7 @@ class BasicController extends Controller
$available = $this->abRepository->getAvailableBudgetWithCurrency($start, $end); $available = $this->abRepository->getAvailableBudgetWithCurrency($start, $end);
$budgets = $this->budgetRepository->getActiveBudgets(); $budgets = $this->budgetRepository->getActiveBudgets();
$spent = $this->opsRepository->listExpenses($start, $end, null, $budgets); $spent = $this->opsRepository->listExpenses($start, $end, null, $budgets);
$default = app('amount')->getNativeCurrency(); $default = app('amount')->getPrimaryCurrency();
$currencies = []; $currencies = [];
$converter = new ExchangeRateConverter(); $converter = new ExchangeRateConverter();

View File

@@ -126,7 +126,7 @@ class PiggyBankFactory
private function getCurrency(array $data): TransactionCurrency private function getCurrency(array $data): TransactionCurrency
{ {
// currency: // currency:
$defaultCurrency = app('amount')->getNativeCurrency(); $defaultCurrency = app('amount')->getPrimaryCurrency();
$currency = null; $currency = null;
if (array_key_exists('transaction_currency_code', $data)) { if (array_key_exists('transaction_currency_code', $data)) {
$currency = $this->currencyRepository->findByCode((string)($data['transaction_currency_code'] ?? '')); $currency = $this->currencyRepository->findByCode((string)($data['transaction_currency_code'] ?? ''));

View File

@@ -60,7 +60,7 @@ class PreferencesEventHandler
$this->resetBudgets($event->userGroup); $this->resetBudgets($event->userGroup);
$this->resetTransactions($event->userGroup); $this->resetTransactions($event->userGroup);
// fire laravel command to recalculate them all. // fire laravel command to recalculate them all.
if (Amount::convertToNative()) { if (Amount::convertToPrimary()) {
Log::debug('Will now convert to native.'); Log::debug('Will now convert to native.');
Artisan::call('correction:recalculate-native-amounts'); Artisan::call('correction:recalculate-native-amounts');

View File

@@ -49,7 +49,7 @@ class AccountObserver
private function updateNativeAmount(Account $account): void private function updateNativeAmount(Account $account): void
{ {
if (!Amount::convertToNative($account->user)) { if (!Amount::convertToPrimary($account->user)) {
return; return;
} }
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup); $userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);

View File

@@ -39,7 +39,7 @@ class AutoBudgetObserver
private function updateNativeAmount(AutoBudget $autoBudget): void private function updateNativeAmount(AutoBudget $autoBudget): void
{ {
if (!Amount::convertToNative($autoBudget->budget->user)) { if (!Amount::convertToPrimary($autoBudget->budget->user)) {
return; return;
} }
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($autoBudget->budget->user->userGroup); $userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($autoBudget->budget->user->userGroup);

View File

@@ -39,7 +39,7 @@ class AvailableBudgetObserver
private function updateNativeAmount(AvailableBudget $availableBudget): void 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.'); // Log::debug('Do not update native available amount of the available budget.');
return; return;

View File

@@ -43,7 +43,7 @@ class BillObserver
private function updateNativeAmount(Bill $bill): void private function updateNativeAmount(Bill $bill): void
{ {
if (!Amount::convertToNative($bill->user)) { if (!Amount::convertToPrimary($bill->user)) {
return; return;
} }
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($bill->user->userGroup); $userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($bill->user->userGroup);

View File

@@ -39,7 +39,7 @@ class BudgetLimitObserver
private function updateNativeAmount(BudgetLimit $budgetLimit): void 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.'); // Log::debug('Do not update native amount of the budget limit.');
return; return;

View File

@@ -45,7 +45,7 @@ class PiggyBankEventObserver
return; return;
} }
if (!Amount::convertToNative($user)) { if (!Amount::convertToPrimary($user)) {
return; return;
} }
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($event->piggyBank->accounts()->first()->user->userGroup); $userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($event->piggyBank->accounts()->first()->user->userGroup);

View File

@@ -50,7 +50,7 @@ class TransactionObserver
private function updateNativeAmount(Transaction $transaction): void private function updateNativeAmount(Transaction $transaction): void
{ {
if (!Amount::convertToNative($transaction->transactionJournal->user)) { if (!Amount::convertToPrimary($transaction->transactionJournal->user)) {
return; return;
} }
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($transaction->transactionJournal->user->userGroup); $userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($transaction->transactionJournal->user->userGroup);

View File

@@ -64,7 +64,7 @@ class NetWorth implements NetWorthInterface
public function byAccounts(Collection $accounts, Carbon $date): array public function byAccounts(Collection $accounts, Carbon $date): array
{ {
// start in the past, end in the future? use $date // start in the past, end in the future? use $date
$convertToNative = Amount::convertToNative(); $convertToNative = Amount::convertToPrimary();
$ids = implode(',', $accounts->pluck('id')->toArray()); $ids = implode(',', $accounts->pluck('id')->toArray());
$cache = new CacheProperties(); $cache = new CacheProperties();
$cache->addProperty($date); $cache->addProperty($date);
@@ -75,7 +75,7 @@ class NetWorth implements NetWorthInterface
return $cache->get(); return $cache->get();
} }
Log::debug(sprintf('Now in byAccounts("%s", "%s")', $ids, $date->format('Y-m-d H:i:s'))); Log::debug(sprintf('Now in byAccounts("%s", "%s")', $ids, $date->format('Y-m-d H:i:s')));
$default = Amount::getNativeCurrency(); $default = Amount::getPrimaryCurrency();
$netWorth = []; $netWorth = [];
Log::debug(sprintf('NetWorth: finalAccountsBalance("%s")', $date->format('Y-m-d H:i:s'))); Log::debug(sprintf('NetWorth: finalAccountsBalance("%s")', $date->format('Y-m-d H:i:s')));
$balances = Steam::finalAccountsBalance($accounts, $date); $balances = Steam::finalAccountsBalance($accounts, $date);

View File

@@ -128,11 +128,11 @@ abstract class Controller extends BaseController
$this->defaultCurrency = null; $this->defaultCurrency = null;
// get shown-intro-preference: // get shown-intro-preference:
if (auth()->check()) { if (auth()->check()) {
$this->defaultCurrency = Amount::getNativeCurrency(); $this->defaultCurrency = Amount::getPrimaryCurrency();
$language = Steam::getLanguage(); $language = Steam::getLanguage();
$locale = Steam::getLocale(); $locale = Steam::getLocale();
$darkMode = app('preferences')->get('darkMode', 'browser')->data; $darkMode = app('preferences')->get('darkMode', 'browser')->data;
$this->convertToNative = Amount::convertToNative(); $this->convertToNative = Amount::convertToPrimary();
$page = $this->getPageName(); $page = $this->getPageName();
$shownDemo = $this->hasSeenDemo(); $shownDemo = $this->hasSeenDemo();
View::share('language', $language); View::share('language', $language);

View File

@@ -285,8 +285,8 @@ class DebugController extends Controller
'user_count' => User::count(), 'user_count' => User::count(),
'user_flags' => $userFlags, 'user_flags' => $userFlags,
'user_agent' => $userAgent, 'user_agent' => $userAgent,
'native' => Amount::getNativeCurrency(), 'native' => Amount::getPrimaryCurrency(),
'convert_to_native' => Amount::convertToNative(), 'convert_to_native' => Amount::convertToPrimary(),
'locale_attempts' => $localeAttempts, 'locale_attempts' => $localeAttempts,
'locale' => Steam::getLocale(), 'locale' => Steam::getLocale(),
'language' => Steam::getLanguage(), 'language' => Steam::getLanguage(),

View File

@@ -45,8 +45,8 @@ class FrontpageController extends Controller
{ {
$set = $repository->getPiggyBanks(); $set = $repository->getPiggyBanks();
$info = []; $info = [];
$native = Amount::getNativeCurrency(); $native = Amount::getPrimaryCurrency();
$convertToNative = Amount::convertToNative(); $convertToNative = Amount::convertToPrimary();
/** @var PiggyBank $piggyBank */ /** @var PiggyBank $piggyBank */

View File

@@ -120,7 +120,7 @@ class Range
// save some formats: // save some formats:
$monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale); $monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);
$dateTimeFormat = (string) trans('config.date_time_js', [], $locale); $dateTimeFormat = (string) trans('config.date_time_js', [], $locale);
$defaultCurrency = Amount::getNativeCurrency(); $defaultCurrency = Amount::getPrimaryCurrency();
// also format for moment JS: // also format for moment JS:
$madMomentJS = (string) trans('config.month_and_day_moment_js', [], $locale); $madMomentJS = (string) trans('config.month_and_day_moment_js', [], $locale);

View File

@@ -126,7 +126,7 @@ class PiggyBankStoreRequest extends FormRequest
$currencyId = (int) ($data['transaction_currency_id'] ?? 0); $currencyId = (int) ($data['transaction_currency_id'] ?? 0);
$currency = TransactionCurrency::find($currencyId); $currency = TransactionCurrency::find($currencyId);
if (null === $currency) { if (null === $currency) {
return Amount::getNativeCurrency(); return Amount::getPrimaryCurrency();
} }
return $currency; return $currency;

View File

@@ -131,7 +131,7 @@ class PiggyBankUpdateRequest extends FormRequest
$currencyId = (int) ($data['transaction_currency_id'] ?? 0); $currencyId = (int) ($data['transaction_currency_id'] ?? 0);
$currency = TransactionCurrency::find($currencyId); $currency = TransactionCurrency::find($currencyId);
if (null === $currency) { if (null === $currency) {
return Amount::getNativeCurrency(); return Amount::getPrimaryCurrency();
} }
return $currency; return $currency;

View File

@@ -357,7 +357,7 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
if (AccountTypeEnum::ASSET->value !== $account->accountType->type) { if (AccountTypeEnum::ASSET->value !== $account->accountType->type) {
throw new FireflyException(sprintf('%s is not an asset account.', $account->name)); 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]); $name = trans('firefly.reconciliation_account_name', ['name' => $account->name, 'currency' => $currency->code]);
/** @var AccountType $type */ /** @var AccountType $type */

View File

@@ -275,7 +275,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
]; ];
$result[$currencyId]['sum'] = bcadd($result[$currencyId]['sum'], (string) $transaction->amount); $result[$currencyId]['sum'] = bcadd($result[$currencyId]['sum'], (string) $transaction->amount);
$result[$currencyId]['native_sum'] = bcadd($result[$currencyId]['native_sum'], $transaction->native_amount ?? '0'); $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]['native_sum'] = bcadd($result[$currencyId]['native_sum'], (string) $transaction->amount);
} }
++$result[$currencyId]['count']; ++$result[$currencyId]['count'];
@@ -411,7 +411,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
]; ];
$result[$currencyId]['sum'] = bcadd($result[$currencyId]['sum'], (string) $transaction->amount); $result[$currencyId]['sum'] = bcadd($result[$currencyId]['sum'], (string) $transaction->amount);
$result[$currencyId]['native_sum'] = bcadd($result[$currencyId]['native_sum'], $transaction->native_amount ?? '0'); $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]['native_sum'] = bcadd($result[$currencyId]['native_sum'], (string) $transaction->amount);
} }
++$result[$currencyId]['count']; ++$result[$currencyId]['count'];
@@ -534,8 +534,8 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
Log::debug(sprintf('sumPaidInRange from %s to %s', $start->toW3cString(), $end->toW3cString())); Log::debug(sprintf('sumPaidInRange from %s to %s', $start->toW3cString(), $end->toW3cString()));
$bills = $this->getActiveBills(); $bills = $this->getActiveBills();
$return = []; $return = [];
$convertToNative = Amount::convertToNative($this->user); $convertToNative = Amount::convertToPrimary($this->user);
$default = app('amount')->getNativeCurrency(); $default = app('amount')->getPrimaryCurrency();
/** @var Bill $bill */ /** @var Bill $bill */
foreach ($bills as $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'))); app('log')->debug(sprintf('Now in sumUnpaidInRange("%s", "%s")', $start->format('Y-m-d'), $end->format('Y-m-d')));
$bills = $this->getActiveBills(); $bills = $this->getActiveBills();
$return = []; $return = [];
$convertToNative = Amount::convertToNative($this->user); $convertToNative = Amount::convertToPrimary($this->user);
$default = app('amount')->getNativeCurrency(); $default = app('amount')->getPrimaryCurrency();
/** @var Bill $bill */ /** @var Bill $bill */
foreach ($bills as $bill) { foreach ($bills as $bill) {

View File

@@ -142,8 +142,8 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface, U
Log::debug(sprintf('Found %d available budgets (already converted)', $availableBudgets->count())); Log::debug(sprintf('Found %d available budgets (already converted)', $availableBudgets->count()));
// use native amount if necessary? // use native amount if necessary?
$convertToNative = Amount::convertToNative($this->user); $convertToNative = Amount::convertToPrimary($this->user);
$default = Amount::getNativeCurrency(); $default = Amount::getPrimaryCurrency();
/** @var AvailableBudget $availableBudget */ /** @var AvailableBudget $availableBudget */
foreach ($availableBudgets as $availableBudget) { foreach ($availableBudgets as $availableBudget) {

View File

@@ -91,7 +91,7 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
$limitRepository = app(BudgetLimitRepository::class); $limitRepository = app(BudgetLimitRepository::class);
$limitRepository->setUser($this->user); $limitRepository->setUser($this->user);
$budgets = $this->getActiveBudgets(); $budgets = $this->getActiveBudgets();
$defaultCurrency = app('amount')->getNativeCurrency(); $defaultCurrency = app('amount')->getPrimaryCurrency();
$converter = new ExchangeRateConverter(); $converter = new ExchangeRateConverter();
/** @var Budget $budget */ /** @var Budget $budget */

View File

@@ -142,7 +142,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
$array = []; $array = [];
// if needs conversion to native. // if needs conversion to native.
$convertToNative = Amount::convertToNative($this->user); $convertToNative = Amount::convertToPrimary($this->user);
$nativeCurrency = Amount::getPrimaryCurrencyByUserGroup($this->userGroup); $nativeCurrency = Amount::getPrimaryCurrencyByUserGroup($this->userGroup);
$currencyId = (int) $nativeCurrency->id; $currencyId = (int) $nativeCurrency->id;
$currencyCode = $nativeCurrency->code; $currencyCode = $nativeCurrency->code;

View File

@@ -358,8 +358,8 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
} }
$collector->setCategories($categories); $collector->setCategories($categories);
$journals = $collector->getExtractedJournals(); $journals = $collector->getExtractedJournals();
$convertToNative = Amount::convertToNative($this->user); $convertToNative = Amount::convertToPrimary($this->user);
$default = Amount::getNativeCurrency(); $default = Amount::getPrimaryCurrency();
$array = []; $array = [];
foreach ($journals as $journal) { foreach ($journals as $journal) {

View File

@@ -71,7 +71,7 @@ class BillRepository implements BillRepositoryInterface
{ {
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__)); Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
$bills = $this->getActiveBills(); $bills = $this->getActiveBills();
$default = app('amount')->getNativeCurrency(); $default = app('amount')->getPrimaryCurrency();
$return = []; $return = [];
$converter = new ExchangeRateConverter(); $converter = new ExchangeRateConverter();
@@ -141,7 +141,7 @@ class BillRepository implements BillRepositoryInterface
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__)); Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
$bills = $this->getActiveBills(); $bills = $this->getActiveBills();
$return = []; $return = [];
$default = app('amount')->getNativeCurrency(); $default = app('amount')->getPrimaryCurrency();
$converter = new ExchangeRateConverter(); $converter = new ExchangeRateConverter();
/** @var Bill $bill */ /** @var Bill $bill */

View File

@@ -44,7 +44,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__)); Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
$return = []; $return = [];
$converter = new ExchangeRateConverter(); $converter = new ExchangeRateConverter();
$default = app('amount')->getNativeCurrency(); $default = app('amount')->getPrimaryCurrency();
$availableBudgets = $this->userGroup->availableBudgets() $availableBudgets = $this->userGroup->availableBudgets()
->where('start_date', $start->format('Y-m-d')) ->where('start_date', $start->format('Y-m-d'))
->where('end_date', $end->format('Y-m-d'))->get() ->where('end_date', $end->format('Y-m-d'))->get()

View File

@@ -101,13 +101,13 @@ class Amount
*/ */
public function getAmountFromJournal(array $journal): string public function getAmountFromJournal(array $journal): string
{ {
$convertToNative = $this->convertToNative(); $convertToPrimary = $this->convertToPrimary();
$currency = $this->getNativeCurrency(); $currency = $this->getPrimaryCurrency();
$field = $convertToNative && $currency->id !== $journal['currency_id'] ? 'native_amount' : 'amount'; $field = $convertToPrimary && $currency->id !== $journal['currency_id'] ? 'native_amount' : 'amount';
$amount = $journal[$field] ?? '0'; $amount = $journal[$field] ?? '0';
// Log::debug(sprintf('Field is %s, amount is %s', $field, $amount)); // Log::debug(sprintf('Field is %s, amount is %s', $field, $amount));
// fallback, the transaction has a foreign amount in $currency. // 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']; $amount = $journal['foreign_amount'];
// Log::debug(sprintf('Overruled, amount is now %s', $amount)); // Log::debug(sprintf('Overruled, amount is now %s', $amount));
} }
@@ -115,7 +115,7 @@ class Amount
return (string)$amount; return (string)$amount;
} }
public function convertToNative(?User $user = null): bool public function convertToPrimary(?User $user = null): bool
{ {
if (!$user instanceof User) { if (!$user instanceof User) {
return true === Preferences::get('convert_to_native', false)->data && true === config('cer.enabled'); 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'); 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()) { if (auth()->check()) {
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
if (null !== $user->userGroup) { 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 public function getAmountFromJournalObject(TransactionJournal $journal): string
{ {
$convertToNative = $this->convertToNative(); $convertToPrimary = $this->convertToPrimary();
$currency = $this->getNativeCurrency(); $currency = $this->getPrimaryCurrency();
$field = $convertToNative && $currency->id !== $journal->transaction_currency_id ? 'native_amount' : 'amount'; $field = $convertToPrimary && $currency->id !== $journal->transaction_currency_id ? 'native_amount' : 'amount';
/** @var null|Transaction $sourceTransaction */ /** @var null|Transaction $sourceTransaction */
$sourceTransaction = $journal->transactions()->where('amount', '<', 0)->first(); $sourceTransaction = $journal->transactions()->where('amount', '<', 0)->first();
@@ -195,24 +195,6 @@ class Amount
return $user->currencies()->orderBy('code', 'ASC')->get(); 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, * This method returns the correct format rules required by accounting.js,
* the library used to format amounts in charts. * the library used to format amounts in charts.

View File

@@ -738,7 +738,7 @@ class ExportDataGenerator
$metaFields = config('firefly.journal_meta_fields'); $metaFields = config('firefly.journal_meta_fields');
$header = array_merge($header, $metaFields); $header = array_merge($header, $metaFields);
$default = Amount::getNativeCurrency(); $default = Amount::getPrimaryCurrency();
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user); $collector->setUser($this->user);

View File

@@ -61,7 +61,7 @@ class CurrencyForm
$classes = $this->getHolderClasses($name); $classes = $this->getHolderClasses($name);
$value = $this->fillFieldValue($name, $value); $value = $this->fillFieldValue($name, $value);
$options['step'] = 'any'; $options['step'] = 'any';
$defaultCurrency = $options['currency'] ?? app('amount')->getNativeCurrency(); $defaultCurrency = $options['currency'] ?? app('amount')->getPrimaryCurrency();
/** @var Collection $currencies */ /** @var Collection $currencies */
$currencies = app('amount')->getCurrencies(); $currencies = app('amount')->getCurrencies();
@@ -129,7 +129,7 @@ class CurrencyForm
$classes = $this->getHolderClasses($name); $classes = $this->getHolderClasses($name);
$value = $this->fillFieldValue($name, $value); $value = $this->fillFieldValue($name, $value);
$options['step'] = 'any'; $options['step'] = 'any';
$defaultCurrency = $options['currency'] ?? app('amount')->getNativeCurrency(); $defaultCurrency = $options['currency'] ?? app('amount')->getPrimaryCurrency();
/** @var Collection $currencies */ /** @var Collection $currencies */
$currencies = app('amount')->getAllCurrencies(); $currencies = app('amount')->getAllCurrencies();

View File

@@ -48,7 +48,7 @@ trait ChartGeneration
protected function accountBalanceChart(Collection $accounts, Carbon $start, Carbon $end): array // chart helper method. protected function accountBalanceChart(Collection $accounts, Carbon $start, Carbon $end): array // chart helper method.
{ {
// chart properties for cache: // chart properties for cache:
$convertToNative = Amount::convertToNative(); $convertToNative = Amount::convertToPrimary();
$cache = new CacheProperties(); $cache = new CacheProperties();
$cache->addProperty($start); $cache->addProperty($start);
$cache->addProperty($end); $cache->addProperty($end);
@@ -67,7 +67,7 @@ trait ChartGeneration
/** @var AccountRepositoryInterface $accountRepos */ /** @var AccountRepositoryInterface $accountRepos */
$accountRepos = app(AccountRepositoryInterface::class); $accountRepos = app(AccountRepositoryInterface::class);
$default = app('amount')->getNativeCurrency(); $default = app('amount')->getPrimaryCurrency();
$chartData = []; $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'))); 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')));

View File

@@ -54,7 +54,7 @@ class TransactionGroupEnrichment implements EnrichmentInterface
private array $notes; // @phpstan-ignore-line private array $notes; // @phpstan-ignore-line
private array $tags; private array $tags;
private User $user; private User $user;
private readonly TransactionCurrency $nativeCurrency; private readonly TransactionCurrency $primaryCurrency;
private UserGroup $userGroup; private UserGroup $userGroup;
public function __construct() public function __construct()
@@ -66,7 +66,7 @@ class TransactionGroupEnrichment implements EnrichmentInterface
$this->locations = []; $this->locations = [];
$this->attachmentCount = []; $this->attachmentCount = [];
$this->dateFields = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date']; $this->dateFields = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date'];
$this->nativeCurrency = Amount::getNativeCurrency(); $this->primaryCurrency = Amount::getPrimaryCurrency();
} }
#[Override] #[Override]
@@ -198,9 +198,9 @@ class TransactionGroupEnrichment implements EnrichmentInterface
$metaData = $this->metaData; $metaData = $this->metaData;
$locations = $this->locations; $locations = $this->locations;
$attachmentCount = $this->attachmentCount; $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) { foreach ($item['transactions'] as $index => $transaction) {
$journalId = (int) $transaction['transaction_journal_id']; $journalId = (int) $transaction['transaction_journal_id'];
@@ -220,13 +220,13 @@ class TransactionGroupEnrichment implements EnrichmentInterface
'zoom_level' => null, 'zoom_level' => null,
]; ];
// native currency // primary currency
$item['transactions'][$index]['native_currency'] = [ $item['transactions'][$index]['primary_currency'] = [
'id' => (string) $nativeCurrency->id, 'id' => (string) $primaryCurrency->id,
'code' => $nativeCurrency->code, 'code' => $primaryCurrency->code,
'name' => $nativeCurrency->name, 'name' => $primaryCurrency->name,
'symbol' => $nativeCurrency->symbol, 'symbol' => $primaryCurrency->symbol,
'decimal_places' => $nativeCurrency->decimal_places, 'decimal_places' => $primaryCurrency->decimal_places,
]; ];
// append meta data // append meta data

View File

@@ -46,7 +46,7 @@ class TransactionSummarizer
{ {
$this->user = $user; $this->user = $user;
$this->default = Amount::getPrimaryCurrencyByUserGroup($user->userGroup); $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 public function groupByCurrencyId(array $journals, string $method = 'negative', bool $includeForeign = true): array
@@ -159,7 +159,7 @@ class TransactionSummarizer
$array = []; $array = [];
$idKey = sprintf('%s_account_id', $direction); $idKey = sprintf('%s_account_id', $direction);
$nameKey = sprintf('%s_account_name', $direction); $nameKey = sprintf('%s_account_name', $direction);
$convertToNative = Amount::convertToNative($this->user); $convertToNative = Amount::convertToPrimary($this->user);
$default = Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup); $default = Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);

View File

@@ -93,7 +93,7 @@ class Steam
return []; return [];
} }
$defaultCurrency = Amount::getNativeCurrency(); $defaultCurrency = Amount::getPrimaryCurrency();
if ($convertToNative) { if ($convertToNative) {
if ($defaultCurrency->id === $currency?->id) { if ($defaultCurrency->id === $currency?->id) {
Log::debug(sprintf('Unset [%s] for account #%d (no longer unset "native_balance")', $defaultCurrency->code, $account->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'))); // Log::debug(sprintf('finalAccountBalance(#%d, %s)', $account->id, $date->format('Y-m-d H:i:s')));
if (null === $convertToNative) { if (null === $convertToNative) {
$convertToNative = Amount::convertToNative($account->user); $convertToNative = Amount::convertToPrimary($account->user);
} }
if (!$native instanceof TransactionCurrency) { if (!$native instanceof TransactionCurrency) {
$native = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup); $native = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);

View File

@@ -52,7 +52,7 @@ class AmountFormat extends AbstractExtension
return new TwigFilter( return new TwigFilter(
'formatAmount', 'formatAmount',
static function (string $string): string { static function (string $string): string {
$currency = app('amount')->getNativeCurrency(); $currency = app('amount')->getPrimaryCurrency();
return app('amount')->formatAnything($currency, $string, true); return app('amount')->formatAnything($currency, $string, true);
}, },
@@ -65,7 +65,7 @@ class AmountFormat extends AbstractExtension
return new TwigFilter( return new TwigFilter(
'formatAmountPlain', 'formatAmountPlain',
static function (string $string): string { static function (string $string): string {
$currency = app('amount')->getNativeCurrency(); $currency = app('amount')->getPrimaryCurrency();
return app('amount')->formatAnything($currency, $string, false); return app('amount')->formatAnything($currency, $string, false);
}, },
@@ -98,7 +98,7 @@ class AmountFormat extends AbstractExtension
/** @var AccountRepositoryInterface $accountRepos */ /** @var AccountRepositoryInterface $accountRepos */
$accountRepos = app(AccountRepositoryInterface::class); $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); return app('amount')->formatAnything($currency, $amount, $coloured);
}, },
@@ -157,7 +157,7 @@ class AmountFormat extends AbstractExtension
$currency = TransactionCurrency::whereCode($code)->first(); $currency = TransactionCurrency::whereCode($code)->first();
if (null === $currency) { if (null === $currency) {
Log::error(sprintf('Could not find currency with code "%s". Fallback to native currency.', $code)); 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)); Log::error(sprintf('Fallback currency is "%s".', $currency->code));
} }

View File

@@ -75,8 +75,8 @@ class General extends AbstractExtension
Log::debug(sprintf('twig balance: Call finalAccountBalance with date/time "%s"', $date->toIso8601String())); Log::debug(sprintf('twig balance: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
$info = Steam::finalAccountBalance($account, $date); $info = Steam::finalAccountBalance($account, $date);
$currency = Steam::getAccountCurrency($account); $currency = Steam::getAccountCurrency($account);
$default = Amount::getNativeCurrency(); $default = Amount::getPrimaryCurrency();
$convertToNative = Amount::convertToNative(); $convertToNative = Amount::convertToPrimary();
$useNative = $convertToNative && $default->id !== $currency->id; $useNative = $convertToNative && $default->id !== $currency->id;
$currency ??= $default; $currency ??= $default;
$strings = []; $strings = [];

View File

@@ -51,8 +51,8 @@ class AccountTransformer extends AbstractTransformer
{ {
$this->parameters = new ParameterBag(); $this->parameters = new ParameterBag();
$this->repository = app(AccountRepositoryInterface::class); $this->repository = app(AccountRepositoryInterface::class);
$this->convertToNative = Amount::convertToNative(); $this->convertToNative = Amount::convertToPrimary();
$this->native = Amount::getNativeCurrency(); $this->native = Amount::getPrimaryCurrency();
} }
/** /**

View File

@@ -50,8 +50,8 @@ class AvailableBudgetTransformer extends AbstractTransformer
$this->repository = app(BudgetRepositoryInterface::class); $this->repository = app(BudgetRepositoryInterface::class);
$this->opsRepository = app(OperationsRepositoryInterface::class); $this->opsRepository = app(OperationsRepositoryInterface::class);
$this->noBudgetRepository = app(NoBudgetRepositoryInterface::class); $this->noBudgetRepository = app(NoBudgetRepositoryInterface::class);
$this->default = Amount::getNativeCurrency(); $this->default = Amount::getPrimaryCurrency();
$this->convertToNative = Amount::convertToNative(); $this->convertToNative = Amount::convertToPrimary();
} }
/** /**

View File

@@ -40,7 +40,7 @@ class BillTransformer extends AbstractTransformer
*/ */
public function __construct() public function __construct()
{ {
$this->native = Amount::getNativeCurrency(); $this->native = Amount::getPrimaryCurrency();
} }
/** /**

View File

@@ -46,8 +46,8 @@ class BudgetLimitTransformer extends AbstractTransformer
public function __construct() public function __construct()
{ {
$this->default = Amount::getNativeCurrency(); $this->default = Amount::getPrimaryCurrency();
$this->convertToNative = Amount::convertToNative(); $this->convertToNative = Amount::convertToPrimary();
} }
/** /**

View File

@@ -51,8 +51,8 @@ class BudgetTransformer extends AbstractTransformer
$this->opsRepository = app(OperationsRepositoryInterface::class); $this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(BudgetRepositoryInterface::class); $this->repository = app(BudgetRepositoryInterface::class);
$this->parameters = new ParameterBag(); $this->parameters = new ParameterBag();
$this->default = Amount::getNativeCurrency(); $this->default = Amount::getPrimaryCurrency();
$this->convertToNative = Amount::convertToNative(); $this->convertToNative = Amount::convertToPrimary();
} }
/** /**

View File

@@ -48,8 +48,8 @@ class CategoryTransformer extends AbstractTransformer
{ {
$this->opsRepository = app(OperationsRepositoryInterface::class); $this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(CategoryRepositoryInterface::class); $this->repository = app(CategoryRepositoryInterface::class);
$this->default = Amount::getNativeCurrency(); $this->default = Amount::getPrimaryCurrency();
$this->convertToNative = Amount::convertToNative(); $this->convertToNative = Amount::convertToPrimary();
} }
/** /**

View File

@@ -122,13 +122,13 @@ class TransactionGroupTransformer extends AbstractTransformer
$foreignAmount = app('steam')->positive($transaction['foreign_amount']); $foreignAmount = app('steam')->positive($transaction['foreign_amount']);
} }
// set native amount to the normal amount if the currency matches. // set primary amount to the normal amount if the currency matches.
if ($transaction['native_currency']['id'] ?? null === $transaction['currency_id']) { if ($transaction['primary_currency']['id'] ?? null === $transaction['currency_id']) {
$transaction['native_amount'] = $amount; $transaction['pc_amount'] = $amount;
} }
if (array_key_exists('native_amount', $transaction) && null !== $transaction['native_amount']) { if (array_key_exists('pc_amount', $transaction) && null !== $transaction['pc_amount']) {
$transaction['native_amount'] = app('steam')->positive($transaction['native_amount']); $transaction['pc_amount'] = app('steam')->positive($transaction['pc_amount']);
} }
$type = $this->stringFromArray($transaction, 'transaction_type_type', TransactionTypeEnum::WITHDRAWAL->value); $type = $this->stringFromArray($transaction, 'transaction_type_type', TransactionTypeEnum::WITHDRAWAL->value);
@@ -160,15 +160,15 @@ class TransactionGroupTransformer extends AbstractTransformer
'amount' => $amount, 'amount' => $amount,
'foreign_amount' => $foreignAmount, 'foreign_amount' => $foreignAmount,
// native amount, defaults to NULL when convertToNative is false. // primary currency amount, defaults to NULL when convertToPrimary is false.
'native_amount' => $transaction['native_amount'] ?? null, 'pc_amount' => $transaction['pc_amount'] ?? null,
// native currency, always present. // primary currency, always present.
'native_currency_id' => $transaction['native_currency']['id'] ?? null, 'primary_currency_id' => $transaction['primary_currency']['id'] ?? null,
'native_currency_code' => $transaction['native_currency']['code'] ?? null, 'primary_currency_code' => $transaction['primary_currency']['code'] ?? null,
'native_currency_name' => $transaction['native_currency']['name'] ?? null, 'primary_currency_name' => $transaction['primary_currency']['name'] ?? null,
'native_currency_symbol' => $transaction['native_currency']['symbol'] ?? null, 'primary_currency_symbol' => $transaction['primary_currency']['symbol'] ?? null,
'native_currency_decimal_places' => $transaction['native_currency']['decimal_places'] ?? null, 'primary_currency_decimal_places' => $transaction['primary_currency']['decimal_places'] ?? null,
// source balance after // source balance after
'source_balance_after' => $transaction['source_balance_after'] ?? null, 'source_balance_after' => $transaction['source_balance_after'] ?? null,

View File

@@ -136,7 +136,7 @@ class AccountTransformer extends AbstractTransformer
private function getDefaultCurrency(): void private function getDefaultCurrency(): void
{ {
$this->default = app('amount')->getNativeCurrency(); $this->default = app('amount')->getPrimaryCurrency();
} }
private function collectAccountMetaData(Collection $accounts): void private function collectAccountMetaData(Collection $accounts): void

View File

@@ -99,7 +99,7 @@ class BillTransformer extends AbstractTransformer
]; ];
} }
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__)); Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
$this->default = app('amount')->getNativeCurrency(); $this->default = app('amount')->getPrimaryCurrency();
$this->converter = new ExchangeRateConverter(); $this->converter = new ExchangeRateConverter();
// grab all paid dates: // grab all paid dates:

View File

@@ -82,7 +82,7 @@ class TransactionGroupTransformer extends AbstractTransformer
} }
} }
$this->default = app('amount')->getNativeCurrency(); $this->default = app('amount')->getPrimaryCurrency();
$this->converter = new ExchangeRateConverter(); $this->converter = new ExchangeRateConverter();
$this->collectAllMetaData(); $this->collectAllMetaData();

View File

@@ -224,7 +224,7 @@ trait TransactionValidation
/** @var AccountRepository $accountRepository */ /** @var AccountRepository $accountRepository */
$accountRepository = app(AccountRepositoryInterface::class); $accountRepository = app(AccountRepositoryInterface::class);
$defaultCurrency = app('amount')->getNativeCurrency(); $defaultCurrency = app('amount')->getPrimaryCurrency();
$sourceCurrency = $accountRepository->getAccountCurrency($source) ?? $defaultCurrency; $sourceCurrency = $accountRepository->getAccountCurrency($source) ?? $defaultCurrency;
$destinationCurrency = $accountRepository->getAccountCurrency($destination) ?? $defaultCurrency; $destinationCurrency = $accountRepository->getAccountCurrency($destination) ?? $defaultCurrency;
// if both accounts have the same currency, continue. // if both accounts have the same currency, continue.