mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Rename default to primary
This commit is contained in:
@@ -63,10 +63,10 @@ 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')->getPrimaryCurrencyByUserGroup($userGroup);
|
||||
$primaryCurrency = app('amount')->getPrimaryCurrencyByUserGroup($userGroup);
|
||||
|
||||
Log::debug(sprintf('Now correcting currencies for user group #%d', $userGroup->id));
|
||||
$found = [$defaultCurrency->id];
|
||||
$found = [$primaryCurrency->id];
|
||||
|
||||
// get all meta entries
|
||||
$meta = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
|
||||
|
@@ -108,11 +108,11 @@ class UpgradesAccountCurrencies extends Command
|
||||
$accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value]);
|
||||
|
||||
// get user's currency preference:
|
||||
$defaultCurrency = app('amount')->getPrimaryCurrencyByUserGroup($user->userGroup);
|
||||
$primaryCurrency = app('amount')->getPrimaryCurrencyByUserGroup($user->userGroup);
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
$this->updateAccount($account, $defaultCurrency);
|
||||
$this->updateAccount($account, $primaryCurrency);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -117,13 +117,13 @@ class UpgradesCurrencyPreferences extends Command
|
||||
|
||||
// set the default currency for the user and for the group:
|
||||
$preference = $this->getPreference($user);
|
||||
$defaultCurrency = TransactionCurrency::where('code', $preference)->first();
|
||||
if (null === $defaultCurrency) {
|
||||
$primaryCurrency = TransactionCurrency::where('code', $preference)->first();
|
||||
if (null === $primaryCurrency) {
|
||||
// get EUR
|
||||
$defaultCurrency = TransactionCurrency::where('code', 'EUR')->first();
|
||||
$primaryCurrency = TransactionCurrency::where('code', 'EUR')->first();
|
||||
}
|
||||
$user->currencies()->updateExistingPivot($defaultCurrency->id, ['user_default' => true]);
|
||||
$user->userGroup->currencies()->updateExistingPivot($defaultCurrency->id, ['group_default' => true]);
|
||||
$user->currencies()->updateExistingPivot($primaryCurrency->id, ['user_default' => true]);
|
||||
$user->userGroup->currencies()->updateExistingPivot($primaryCurrency->id, ['group_default' => true]);
|
||||
}
|
||||
|
||||
private function getPreference(User $user): string
|
||||
|
Reference in New Issue
Block a user