Skip to content

Firefly III: a personal finances manager

Rename method.

James Cole210bd83bd436
diff --git a/app/Console/Commands/Correction/CorrectsAmounts.php b/app/Console/Commands/Correction/CorrectsAmounts.php
index 5616908377..1c8a22deec 100644
--- a/app/Console/Commands/Correction/CorrectsAmounts.php
+++ b/app/Console/Commands/Correction/CorrectsAmounts.php
@@ -86,7 +86,7 @@ class CorrectsAmounts extends Command
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
$repository->setUser($journal->user);
- $native = Amount::getNativeCurrencyByUserGroup($journal->userGroup);
+ $native = Amount::getPrimaryCurrencyByUserGroup($journal->userGroup);
/** @var null|Transaction $source */
$source = $journal->transactions()->where('amount', '<', 0)->first();
diff --git a/app/Console/Commands/Correction/CorrectsCurrencies.php b/app/Console/Commands/Correction/CorrectsCurrencies.php
index e96a15523d..f62314179e 100644
--- a/app/Console/Commands/Correction/CorrectsCurrencies.php
+++ b/app/Console/Commands/Correction/CorrectsCurrencies.php
@@ -63,7 +63,7 @@ class CorrectsCurrencies extends Command
$repos = app(CurrencyRepositoryInterface::class);
// first check if the user has any default currency (not necessarily the case, so can be forced).
- $defaultCurrency = app('amount')->getNativeCurrencyByUserGroup($userGroup);
+ $defaultCurrency = app('amount')->getPrimaryCurrencyByUserGroup($userGroup);
Log::debug(sprintf('Now correcting currencies for user group #%d', $userGroup->id));
$found = [$defaultCurrency->id];
diff --git a/app/Console/Commands/Correction/CorrectsNativeAmounts.php b/app/Console/Commands/Correction/CorrectsNativeAmounts.php
index 87d84abe66..3532af0d79 100644
--- a/app/Console/Commands/Correction/CorrectsNativeAmounts.php
+++ b/app/Console/Commands/Correction/CorrectsNativeAmounts.php
@@ -88,7 +88,7 @@ class CorrectsNativeAmounts extends Command
// do a check with the group's currency so we can skip some stuff.
Preferences::mark();
- $currency = app('amount')->getNativeCurrencyByUserGroup($userGroup);
+ $currency = app('amount')->getPrimaryCurrencyByUserGroup($userGroup);
$this->recalculatePiggyBanks($userGroup, $currency);
$this->recalculateBudgets($userGroup, $currency);
diff --git a/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php b/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php
index 713f54d8c6..0383e72785 100644
--- a/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php
+++ b/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php
@@ -132,6 +132,6 @@ class CorrectsOpeningBalanceCurrencies extends Command
$repos = app(AccountRepositoryInterface::class);
$repos->setUser($account->user);
- return $repos->getAccountCurrency($account) ?? app('amount')->getNativeCurrencyByUserGroup($account->userGroup);
+ return $repos->getAccountCurrency($account) ?? app('amount')->getPrimaryCurrencyByUserGroup($account->userGroup);
}
}
diff --git a/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php b/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php
index 94c5643feb..3c4e62003f 100644
--- a/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php
+++ b/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php
@@ -108,7 +108,7 @@ class UpgradesAccountCurrencies extends Command
$accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value]);
// get user's currency preference:
- $defaultCurrency = app('amount')->getNativeCurrencyByUserGroup($user->userGroup);
+ $defaultCurrency = app('amount')->getPrimaryCurrencyByUserGroup($user->userGroup);
/** @var Account $account */
foreach ($accounts as $account) {
diff --git a/app/Console/Commands/Upgrade/UpgradesBudgetLimits.php b/app/Console/Commands/Upgrade/UpgradesBudgetLimits.php
index a1bbe571ed..473247de6f 100644
--- a/app/Console/Commands/Upgrade/UpgradesBudgetLimits.php
+++ b/app/Console/Commands/Upgrade/UpgradesBudgetLimits.php
@@ -66,7 +66,7 @@ class UpgradesBudgetLimits extends Command
/** @var null|User $user */
$user = $budget->user;
if (null !== $user) {
- $currency = app('amount')->getNativeCurrencyByUserGroup($user->userGroup);
+ $currency = app('amount')->getPrimaryCurrencyByUserGroup($user->userGroup);
$budgetLimit->transaction_currency_id = $currency->id;
$budgetLimit->save();
$this->friendlyInfo(
diff --git a/app/Console/Commands/Upgrade/UpgradesMultiPiggyBanks.php b/app/Console/Commands/Upgrade/UpgradesMultiPiggyBanks.php
index 7affe2abc0..d155510181 100644
--- a/app/Console/Commands/Upgrade/UpgradesMultiPiggyBanks.php
+++ b/app/Console/Commands/Upgrade/UpgradesMultiPiggyBanks.php
@@ -96,7 +96,7 @@ class UpgradesMultiPiggyBanks extends Command
$this->repository->setUser($piggyBank->account->user);
$this->accountRepository->setUser($piggyBank->account->user);
$repetition = $this->repository->getRepetition($piggyBank, true);
- $currency = $this->accountRepository->getAccountCurrency($piggyBank->account) ?? app('amount')->getNativeCurrencyByUserGroup($piggyBank->account->user->userGroup);
+ $currency = $this->accountRepository->getAccountCurrency($piggyBank->account) ?? app('amount')->getPrimaryCurrencyByUserGroup($piggyBank->account->user->userGroup);
// update piggy bank to have a currency.
$piggyBank->transaction_currency_id = $currency->id;
diff --git a/app/Factory/BillFactory.php b/app/Factory/BillFactory.php
index 7a6babf654..1fe4567134 100644
--- a/app/Factory/BillFactory.php
+++ b/app/Factory/BillFactory.php
@@ -50,7 +50,7 @@ class BillFactory
app('log')->debug(sprintf('Now in %s', __METHOD__), $data);
$factory = app(TransactionCurrencyFactory::class);
$currency = $factory->find((int) ($data['currency_id'] ?? null), (string) ($data['currency_code'] ?? null))
- ?? app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
+ ?? app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
try {
$skip = array_key_exists('skip', $data) ? $data['skip'] : 0;
diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php
index bf1a755e9e..be27983f07 100644
--- a/app/Factory/TransactionJournalFactory.php
+++ b/app/Factory/TransactionJournalFactory.php
@@ -488,7 +488,7 @@ class TransactionJournalFactory
$preference = $this->accountRepository->getAccountCurrency($account);
if (null === $preference && !$currency instanceof TransactionCurrency) {
// return user's default:
- return app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
+ return app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
}
$result = $preference ?? $currency;
Log::debug(sprintf('Currency is now #%d (%s) because of account #%d (%s)', $result->id, $result->code, $account->id, $account->name));
diff --git a/app/Generator/Report/Audit/MonthReportGenerator.php b/app/Generator/Report/Audit/MonthReportGenerator.php
index a8bbca3b18..b54e1c9042 100644
--- a/app/Generator/Report/Audit/MonthReportGenerator.php
+++ b/app/Generator/Report/Audit/MonthReportGenerator.php
@@ -141,7 +141,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
Log::debug(sprintf('getAuditReport: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
$dayBeforeBalance = Steam::finalAccountBalance($account, $date);
$startBalance = $dayBeforeBalance['balance'];
- $defaultCurrency = app('amount')->getNativeCurrencyByUserGroup($account->user->userGroup);
+ $defaultCurrency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
$currency = $accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
foreach ($journals as $index => $journal) {
diff --git a/app/Generator/Webhook/StandardMessageGenerator.php b/app/Generator/Webhook/StandardMessageGenerator.php
index dbb3516dfc..2dfefccd66 100644
--- a/app/Generator/Webhook/StandardMessageGenerator.php
+++ b/app/Generator/Webhook/StandardMessageGenerator.php
@@ -177,7 +177,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface
$accounts = $this->collectAccounts($model);
$enrichment = new AccountEnrichment();
$enrichment->setUser($model->user);
- $enrichment->setNative(Amount::getNativeCurrencyByUserGroup($model->userGroup));
+ $enrichment->setNative(Amount::getPrimaryCurrencyByUserGroup($model->userGroup));
$accounts = $enrichment->enrich($accounts);
foreach ($accounts as $account) {
$transformer = new AccountTransformer();
diff --git a/app/Handlers/Observer/AccountObserver.php b/app/Handlers/Observer/AccountObserver.php
index b5f5c32443..73782b6bb7 100644
--- a/app/Handlers/Observer/AccountObserver.php
+++ b/app/Handlers/Observer/AccountObserver.php
@@ -52,7 +52,7 @@ class AccountObserver
if (!Amount::convertToNative($account->user)) {
return;
}
- $userCurrency = app('amount')->getNativeCurrencyByUserGroup($account->user->userGroup);
+ $userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
$repository = app(AccountRepositoryInterface::class);
$currency = $repository->getAccountCurrency($account);
if (null !== $currency && $currency->id !== $userCurrency->id && '' !== (string) $account->virtual_balance && 0 !== bccomp($account->virtual_balance, '0')) {
diff --git a/app/Handlers/Observer/AutoBudgetObserver.php b/app/Handlers/Observer/AutoBudgetObserver.php
index 8ff4ff8e1f..967635d6c1 100644
--- a/app/Handlers/Observer/AutoBudgetObserver.php
+++ b/app/Handlers/Observer/AutoBudgetObserver.php
@@ -42,7 +42,7 @@ class AutoBudgetObserver
if (!Amount::convertToNative($autoBudget->budget->user)) {
return;
}
- $userCurrency = app('amount')->getNativeCurrencyByUserGroup($autoBudget->budget->user->userGroup);
+ $userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($autoBudget->budget->user->userGroup);
$autoBudget->native_amount = null;
if ($autoBudget->transactionCurrency->id !== $userCurrency->id) {
$converter = new ExchangeRateConverter();
diff --git a/app/Handlers/Observer/AvailableBudgetObserver.php b/app/Handlers/Observer/AvailableBudgetObserver.php
index 5e1e3ef890..b3c069519c 100644
--- a/app/Handlers/Observer/AvailableBudgetObserver.php
+++ b/app/Handlers/Observer/AvailableBudgetObserver.php
@@ -44,7 +44,7 @@ class AvailableBudgetObserver
return;
}
- $userCurrency = app('amount')->getNativeCurrencyByUserGroup($availableBudget->user->userGroup);
+ $userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($availableBudget->user->userGroup);
$availableBudget->native_amount = null;
if ($availableBudget->transactionCurrency->id !== $userCurrency->id) {
$converter = new ExchangeRateConverter();
diff --git a/app/Handlers/Observer/BillObserver.php b/app/Handlers/Observer/BillObserver.php
index 5ab6549a77..40f56f1f29 100644
--- a/app/Handlers/Observer/BillObserver.php
+++ b/app/Handlers/Observer/BillObserver.php
@@ -46,7 +46,7 @@ class BillObserver
if (!Amount::convertToNative($bill->user)) {
return;
}
- $userCurrency = app('amount')->getNativeCurrencyByUserGroup($bill->user->userGroup);
+ $userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($bill->user->userGroup);
$bill->native_amount_min = null;
$bill->native_amount_max = null;
if ($bill->transactionCurrency->id !== $userCurrency->id) {
diff --git a/app/Handlers/Observer/BudgetLimitObserver.php b/app/Handlers/Observer/BudgetLimitObserver.php
index f67e6a37e9..d4a7bb833b 100644
--- a/app/Handlers/Observer/BudgetLimitObserver.php
+++ b/app/Handlers/Observer/BudgetLimitObserver.php
@@ -44,7 +44,7 @@ class BudgetLimitObserver
return;
}
- $userCurrency = app('amount')->getNativeCurrencyByUserGroup($budgetLimit->budget->user->userGroup);
+ $userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($budgetLimit->budget->user->userGroup);
$budgetLimit->native_amount = null;
if ($budgetLimit->transactionCurrency->id !== $userCurrency->id) {
$converter = new ExchangeRateConverter();
diff --git a/app/Handlers/Observer/PiggyBankEventObserver.php b/app/Handlers/Observer/PiggyBankEventObserver.php
index 0f62454063..55dd5ac332 100644
--- a/app/Handlers/Observer/PiggyBankEventObserver.php
+++ b/app/Handlers/Observer/PiggyBankEventObserver.php
@@ -48,7 +48,7 @@ class PiggyBankEventObserver
if (!Amount::convertToNative($user)) {
return;
}
- $userCurrency = app('amount')->getNativeCurrencyByUserGroup($event->piggyBank->accounts()->first()->user->userGroup);
+ $userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($event->piggyBank->accounts()->first()->user->userGroup);
$event->native_amount = null;
if ($event->piggyBank->transactionCurrency->id !== $userCurrency->id) {
$converter = new ExchangeRateConverter();
diff --git a/app/Handlers/Observer/PiggyBankObserver.php b/app/Handlers/Observer/PiggyBankObserver.php
index 47f2052a84..c3a4c369cb 100644
--- a/app/Handlers/Observer/PiggyBankObserver.php
+++ b/app/Handlers/Observer/PiggyBankObserver.php
@@ -49,7 +49,7 @@ class PiggyBankObserver
return;
}
- $userCurrency = app('amount')->getNativeCurrencyByUserGroup($group);
+ $userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($group);
$piggyBank->native_target_amount = null;
if ($piggyBank->transactionCurrency->id !== $userCurrency->id) {
$converter = new ExchangeRateConverter();
diff --git a/app/Handlers/Observer/TransactionObserver.php b/app/Handlers/Observer/TransactionObserver.php
index 9869b45dd3..7affb74699 100644
--- a/app/Handlers/Observer/TransactionObserver.php
+++ b/app/Handlers/Observer/TransactionObserver.php
@@ -53,7 +53,7 @@ class TransactionObserver
if (!Amount::convertToNative($transaction->transactionJournal->user)) {
return;
}
- $userCurrency = app('amount')->getNativeCurrencyByUserGroup($transaction->transactionJournal->user->userGroup);
+ $userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($transaction->transactionJournal->user->userGroup);
$transaction->native_amount = null;
$transaction->native_foreign_amount = null;
// first normal amount
diff --git a/app/Models/TransactionCurrency.php b/app/Models/TransactionCurrency.php
index 4f93717955..83dfd6bfe0 100644
--- a/app/Models/TransactionCurrency.php
+++ b/app/Models/TransactionCurrency.php
@@ -65,7 +65,7 @@ class TransactionCurrency extends Model
public function refreshForUser(User $user): void
{
$current = $user->userGroup->currencies()->where('transaction_currencies.id', $this->id)->first();
- $native = app('amount')->getNativeCurrencyByUserGroup($user->userGroup);
+ $native = app('amount')->getPrimaryCurrencyByUserGroup($user->userGroup);
$this->userGroupNative = $native->id === $this->id;
$this->userGroupEnabled = null !== $current;
}
diff --git a/app/Repositories/Account/AccountTasker.php b/app/Repositories/Account/AccountTasker.php
index 031794595e..1d1261f85d 100644
--- a/app/Repositories/Account/AccountTasker.php
+++ b/app/Repositories/Account/AccountTasker.php
@@ -58,7 +58,7 @@ class AccountTasker implements AccountTaskerInterface, UserGroupInterface
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
- $defaultCurrency = app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
+ $defaultCurrency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
$return = [
'accounts' => [],
@@ -148,7 +148,7 @@ class AccountTasker implements AccountTaskerInterface, UserGroupInterface
*/
private function groupExpenseByDestination(array $array): array
{
- $defaultCurrency = app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
+ $defaultCurrency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
/** @var CurrencyRepositoryInterface $currencyRepos */
$currencyRepos = app(CurrencyRepositoryInterface::class);
@@ -236,7 +236,7 @@ class AccountTasker implements AccountTaskerInterface, UserGroupInterface
*/
private function groupIncomeBySource(array $array): array
{
- $defaultCurrency = app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
+ $defaultCurrency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
/** @var CurrencyRepositoryInterface $currencyRepos */
$currencyRepos = app(CurrencyRepositoryInterface::class);
diff --git a/app/Repositories/Budget/BudgetLimitRepository.php b/app/Repositories/Budget/BudgetLimitRepository.php
index 87a18dde34..8974613364 100644
--- a/app/Repositories/Budget/BudgetLimitRepository.php
+++ b/app/Repositories/Budget/BudgetLimitRepository.php
@@ -271,7 +271,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface, UserGroup
$factory = app(TransactionCurrencyFactory::class);
$currency = $factory->find($data['currency_id'] ?? null, $data['currency_code'] ?? null);
if (null === $currency) {
- $currency = app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
+ $currency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
}
$currency->enabled = true;
$currency->save();
@@ -369,7 +369,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface, UserGroup
}
// catch unexpected null:
if (null === $currency) {
- $currency = $budgetLimit->transactionCurrency ?? app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
+ $currency = $budgetLimit->transactionCurrency ?? app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
}
$currency->enabled = true;
$currency->save();
diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php
index 6c7cf80784..65460aaa74 100644
--- a/app/Repositories/Budget/BudgetRepository.php
+++ b/app/Repositories/Budget/BudgetRepository.php
@@ -391,7 +391,7 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
$autoBudget = $this->getAutoBudget($budget);
// grab default currency:
- $currency = app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
+ $currency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
if (!$autoBudget instanceof AutoBudget) {
// at this point it's a blind assumption auto_budget_type is 1 or 2.
@@ -776,7 +776,7 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
$currency = $repos->findByCode((string) $data['currency_code']);
}
if (null === $currency) {
- $currency = app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
+ $currency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
}
$autoBudget = new AutoBudget();
diff --git a/app/Repositories/Budget/OperationsRepository.php b/app/Repositories/Budget/OperationsRepository.php
index cc4f5b654b..b98b8a4393 100644
--- a/app/Repositories/Budget/OperationsRepository.php
+++ b/app/Repositories/Budget/OperationsRepository.php
@@ -143,7 +143,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
// if needs conversion to native.
$convertToNative = Amount::convertToNative($this->user);
- $nativeCurrency = Amount::getNativeCurrencyByUserGroup($this->userGroup);
+ $nativeCurrency = Amount::getPrimaryCurrencyByUserGroup($this->userGroup);
$currencyId = (int) $nativeCurrency->id;
$currencyCode = $nativeCurrency->code;
$currencyName = $nativeCurrency->name;
diff --git a/app/Repositories/Currency/CurrencyRepository.php b/app/Repositories/Currency/CurrencyRepository.php
index 2716d2e21e..67e0918dc6 100644
--- a/app/Repositories/Currency/CurrencyRepository.php
+++ b/app/Repositories/Currency/CurrencyRepository.php
@@ -243,7 +243,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
Log::debug('Grabbing default currency for this user...');
/** @var null|TransactionCurrency $result */
- $result = app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
+ $result = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
}
Log::debug(sprintf('Final result: %s', $result->code));
@@ -428,7 +428,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
public function makeDefault(TransactionCurrency $currency): void
{
- $current = app('amount')->getNativeCurrencyByUserGroup($this->userGroup);
+ $current = app('amount')->getPrimaryCurrencyByUserGroup($this->userGroup);
Log::debug(sprintf('Enabled + made default currency %s for user #%d', $currency->code, $this->userGroup->id));
$this->userGroup->currencies()->detach($currency->id);
foreach ($this->userGroup->currencies()->get() as $item) {
diff --git a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php
index 3da904540d..658ca6e1c8 100644
--- a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php
+++ b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php
@@ -71,7 +71,7 @@ trait ModifiesPiggyBanks
$pivot->native_current_amount = null;
// also update native_current_amount.
- $userCurrency = app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
+ $userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
if ($userCurrency->id !== $piggyBank->transaction_currency_id) {
$converter = new ExchangeRateConverter();
$converter->setIgnoreSettings(true);
@@ -94,7 +94,7 @@ trait ModifiesPiggyBanks
$pivot->native_current_amount = null;
// also update native_current_amount.
- $userCurrency = app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
+ $userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
if ($userCurrency->id !== $piggyBank->transaction_currency_id) {
$converter = new ExchangeRateConverter();
$converter->setIgnoreSettings(true);
diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php
index f84266febd..febfa1a90d 100644
--- a/app/Repositories/PiggyBank/PiggyBankRepository.php
+++ b/app/Repositories/PiggyBank/PiggyBankRepository.php
@@ -171,7 +171,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte
$accountRepos = app(AccountRepositoryInterface::class);
$accountRepos->setUser($this->user);
- $defaultCurrency = app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
+ $defaultCurrency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
app('log')->debug(sprintf('Piggy bank #%d currency is %s', $piggyBank->id, $piggyBank->transactionCurrency->code));
diff --git a/app/Repositories/TransactionGroup/TransactionGroupRepository.php b/app/Repositories/TransactionGroup/TransactionGroupRepository.php
index 97e4c6ef09..6fce8e43db 100644
--- a/app/Repositories/TransactionGroup/TransactionGroupRepository.php
+++ b/app/Repositories/TransactionGroup/TransactionGroupRepository.php
@@ -340,7 +340,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
{
$return = [];
$journals = $group->transactionJournals->pluck('id')->toArray();
- $currency = app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
+ $currency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
$data = PiggyBankEvent::whereIn('transaction_journal_id', $journals)
->with('piggyBank', 'piggyBank.account')
->get(['piggy_bank_events.*'])
diff --git a/app/Repositories/UserGroups/Currency/CurrencyRepository.php b/app/Repositories/UserGroups/Currency/CurrencyRepository.php
index eddd408446..9acda51bf7 100644
--- a/app/Repositories/UserGroups/Currency/CurrencyRepository.php
+++ b/app/Repositories/UserGroups/Currency/CurrencyRepository.php
@@ -245,7 +245,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
Log::debug('Grabbing default currency for this user...');
/** @var null|TransactionCurrency $result */
- $result = app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
+ $result = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
}
Log::debug(sprintf('Final result: %s', $result->code));
@@ -376,7 +376,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
public function makeDefault(TransactionCurrency $currency): void
{
- $current = app('amount')->getNativeCurrencyByUserGroup($this->userGroup);
+ $current = app('amount')->getPrimaryCurrencyByUserGroup($this->userGroup);
Log::debug(sprintf('Enabled + made default currency %s for user #%d', $currency->code, $this->userGroup->id));
$this->userGroup->currencies()->detach($currency->id);
foreach ($this->userGroup->currencies()->get() as $item) {
diff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.php
index 95471d1032..f3225155c7 100644
--- a/app/Services/Internal/Support/AccountServiceTrait.php
+++ b/app/Services/Internal/Support/AccountServiceTrait.php
@@ -235,7 +235,7 @@ trait AccountServiceTrait
// get or grab currency:
$currency = $this->accountRepository->getAccountCurrency($account);
if (null === $currency) {
- $currency = app('amount')->getNativeCurrencyByUserGroup($account->user->userGroup);
+ $currency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
}
// submit to factory:
@@ -355,7 +355,7 @@ trait AccountServiceTrait
if (null === $currency) {
// use default currency:
- $currency = app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
+ $currency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
}
$currency->enabled = true;
$currency->save();
@@ -395,7 +395,7 @@ trait AccountServiceTrait
// if exists, update:
$currency = $this->accountRepository->getAccountCurrency($account);
if (null === $currency) {
- $currency = app('amount')->getNativeCurrencyByUserGroup($account->user->userGroup);
+ $currency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
}
// simply grab the first journal and change it:
@@ -461,7 +461,7 @@ trait AccountServiceTrait
// get or grab currency:
$currency = $this->accountRepository->getAccountCurrency($account);
if (null === $currency) {
- $currency = app('amount')->getNativeCurrencyByUserGroup($account->user->userGroup);
+ $currency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
}
// submit to factory:
$submission = [
@@ -578,7 +578,7 @@ trait AccountServiceTrait
// if exists, update:
$currency = $this->accountRepository->getAccountCurrency($account);
if (null === $currency) {
- $currency = app('amount')->getNativeCurrencyByUserGroup($account->user->userGroup);
+ $currency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
}
// simply grab the first journal and change it:
@@ -659,7 +659,7 @@ trait AccountServiceTrait
// get or grab currency:
$currency = $this->accountRepository->getAccountCurrency($account);
if (null === $currency) {
- $currency = app('amount')->getNativeCurrencyByUserGroup($account->user->userGroup);
+ $currency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
}
// submit to factory:
diff --git a/app/Services/Internal/Support/RecurringTransactionTrait.php b/app/Services/Internal/Support/RecurringTransactionTrait.php
index 84771766cf..6ac399f6e5 100644
--- a/app/Services/Internal/Support/RecurringTransactionTrait.php
+++ b/app/Services/Internal/Support/RecurringTransactionTrait.php
@@ -109,7 +109,7 @@ trait RecurringTransactionTrait
$currency = $factory->find($array['currency_id'] ?? null, $array['currency_code'] ?? null);
$foreignCurrency = $factory->find($array['foreign_currency_id'] ?? null, $array['foreign_currency_code'] ?? null);
if (null === $currency) {
- $currency = app('amount')->getNativeCurrencyByUserGroup($recurrence->user->userGroup);
+ $currency = app('amount')->getPrimaryCurrencyByUserGroup($recurrence->user->userGroup);
}
app('log')->debug(
diff --git a/app/Services/Internal/Update/BillUpdateService.php b/app/Services/Internal/Update/BillUpdateService.php
index 8726cd7ebc..a4aca38ce4 100644
--- a/app/Services/Internal/Update/BillUpdateService.php
+++ b/app/Services/Internal/Update/BillUpdateService.php
@@ -56,7 +56,7 @@ class BillUpdateService
if (array_key_exists('currency_id', $data) || array_key_exists('currency_code', $data)) {
$factory = app(TransactionCurrencyFactory::class);
$currency = $factory->find((int) ($data['currency_id'] ?? null), $data['currency_code'] ?? null)
- ?? app('amount')->getNativeCurrencyByUserGroup($bill->user->userGroup);
+ ?? app('amount')->getPrimaryCurrencyByUserGroup($bill->user->userGroup);
// enable the currency if it isn't.
$currency->enabled = true;
diff --git a/app/Support/Amount.php b/app/Support/Amount.php
index adaea875a6..c167e14d24 100644
--- a/app/Support/Amount.php
+++ b/app/Support/Amount.php
@@ -137,25 +137,25 @@ class Amount
return $this->getSystemCurrency();
}
- public function getNativeCurrencyByUserGroup(UserGroup $userGroup): TransactionCurrency
+ public function getPrimaryCurrencyByUserGroup(UserGroup $userGroup): TransactionCurrency
{
$cache = new CacheProperties();
- $cache->addProperty('getNativeCurrencyByGroup');
+ $cache->addProperty('getPrimaryCurrencyByGroup');
$cache->addProperty($userGroup->id);
if ($cache->has()) {
return $cache->get();
}
- /** @var null|TransactionCurrency $native */
- $native = $userGroup->currencies()->where('group_default', true)->first();
- if (null === $native) {
- $native = $this->getSystemCurrency();
+ /** @var null|TransactionCurrency $primary */
+ $primary = $userGroup->currencies()->where('group_default', true)->first();
+ if (null === $primary) {
+ $primary = $this->getSystemCurrency();
// could be the user group has no default right now.
- $userGroup->currencies()->sync([$native->id => ['group_default' => true]]);
+ $userGroup->currencies()->sync([$primary->id => ['group_default' => true]]);
}
- $cache->store($native);
+ $cache->store($primary);
- return $native;
+ return $primary;
}
public function getSystemCurrency(): TransactionCurrency
diff --git a/app/Support/Report/Budget/BudgetReportGenerator.php b/app/Support/Report/Budget/BudgetReportGenerator.php
index d8516bbc7b..3014e97dc4 100644
--- a/app/Support/Report/Budget/BudgetReportGenerator.php
+++ b/app/Support/Report/Budget/BudgetReportGenerator.php
@@ -347,6 +347,6 @@ class BudgetReportGenerator
$this->blRepository->setUser($user);
$this->opsRepository->setUser($user);
$this->nbRepository->setUser($user);
- $this->currency = app('amount')->getNativeCurrencyByUserGroup($user->userGroup);
+ $this->currency = app('amount')->getPrimaryCurrencyByUserGroup($user->userGroup);
}
}
diff --git a/app/Support/Report/Summarizer/TransactionSummarizer.php b/app/Support/Report/Summarizer/TransactionSummarizer.php
index 59a0f1e223..f5ef8f00e9 100644
--- a/app/Support/Report/Summarizer/TransactionSummarizer.php
+++ b/app/Support/Report/Summarizer/TransactionSummarizer.php
@@ -45,7 +45,7 @@ class TransactionSummarizer
public function setUser(User $user): void
{
$this->user = $user;
- $this->default = Amount::getNativeCurrencyByUserGroup($user->userGroup);
+ $this->default = Amount::getPrimaryCurrencyByUserGroup($user->userGroup);
$this->convertToNative = Amount::convertToNative($user);
}
@@ -160,7 +160,7 @@ class TransactionSummarizer
$idKey = sprintf('%s_account_id', $direction);
$nameKey = sprintf('%s_account_name', $direction);
$convertToNative = Amount::convertToNative($this->user);
- $default = Amount::getNativeCurrencyByUserGroup($this->user->userGroup);
+ $default = Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
Log::debug(sprintf('groupByDirection(array, %s, %s).', $direction, $method));
diff --git a/app/Support/Steam.php b/app/Support/Steam.php
index a8cde113cf..43f9a81920 100644
--- a/app/Support/Steam.php
+++ b/app/Support/Steam.php
@@ -224,7 +224,7 @@ class Steam
$request->subDay()->endOfDay();
Log::debug(sprintf('finalAccountBalanceInRange: Call finalAccountBalance with date/time "%s"', $request->toIso8601String()));
$startBalance = $this->finalAccountBalance($account, $request);
- $nativeCurrency = Amount::getNativeCurrencyByUserGroup($account->user->userGroup);
+ $nativeCurrency = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
$accountCurrency = $this->getAccountCurrency($account);
$hasCurrency = $accountCurrency instanceof TransactionCurrency;
$currency = $accountCurrency ?? $nativeCurrency;
@@ -347,7 +347,7 @@ class Steam
$convertToNative = Amount::convertToNative($account->user);
}
if (!$native instanceof TransactionCurrency) {
- $native = Amount::getNativeCurrencyByUserGroup($account->user->userGroup);
+ $native = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
}
// account balance thing.
$currencyPresent = isset($account->meta) && array_key_exists('currency', $account->meta) && null !== $account->meta['currency'];
diff --git a/app/Transformers/PiggyBankEventTransformer.php b/app/Transformers/PiggyBankEventTransformer.php
index 07202d4d97..70f8122189 100644
--- a/app/Transformers/PiggyBankEventTransformer.php
+++ b/app/Transformers/PiggyBankEventTransformer.php
@@ -61,7 +61,7 @@ class PiggyBankEventTransformer extends AbstractTransformer
$this->piggyRepos->setUser($account->user);
// get associated currency or fall back to the default:
- $currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getNativeCurrencyByUserGroup($account->user->userGroup);
+ $currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
// get associated journal and transaction, if any:
$journalId = $event->transaction_journal_id;
diff --git a/app/Transformers/UserGroupTransformer.php b/app/Transformers/UserGroupTransformer.php
index 885da183a6..98e495f6ef 100644
--- a/app/Transformers/UserGroupTransformer.php
+++ b/app/Transformers/UserGroupTransformer.php
@@ -105,7 +105,7 @@ class UserGroupTransformer extends AbstractTransformer
*/
public function transform(UserGroup $userGroup): array
{
- $currency = Amount::getNativeCurrencyByUserGroup($userGroup);
+ $currency = Amount::getPrimaryCurrencyByUserGroup($userGroup);
return [
'id' => $userGroup->id,
diff --git a/app/Transformers/V2/PiggyBankTransformer.php b/app/Transformers/V2/PiggyBankTransformer.php
index 26e927b0d4..11f51e1781 100644
--- a/app/Transformers/V2/PiggyBankTransformer.php
+++ b/app/Transformers/V2/PiggyBankTransformer.php
@@ -139,7 +139,7 @@ class PiggyBankTransformer extends AbstractTransformer
}
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
- $this->default = app('amount')->getNativeCurrencyByUserGroup(auth()->user()->userGroup);
+ $this->default = app('amount')->getPrimaryCurrencyByUserGroup(auth()->user()->userGroup);
$this->converter = new ExchangeRateConverter();
return $objects;