Rename default to primary

This commit is contained in:
Sander Dorigo
2025-08-01 13:48:32 +02:00
parent 37d45f4f87
commit 87567d5a31
24 changed files with 62 additions and 62 deletions

View File

@@ -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);
}
}

View File

@@ -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