Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Rename default to native.
James Coleae366341ccdb
diff --git a/app/Api/V2/Controllers/Model/TransactionCurrency/ShowController.php b/app/Api/V2/Controllers/Model/TransactionCurrency/ShowController.phpindex d33e2b2f4e..695457829e 100644--- a/app/Api/V2/Controllers/Model/TransactionCurrency/ShowController.php+++ b/app/Api/V2/Controllers/Model/TransactionCurrency/ShowController.php@@ -66,7 +66,7 @@ class ShowController extends Controller$default = 1 === $group->pivot->group_default;}$currency->userGroupEnabled = $enabled;- $currency->userGroupDefault = $default;+ $currency->userGroupNative = $default;$transformer = new CurrencyTransformer();diff --git a/app/Http/Controllers/TransactionCurrency/IndexController.php b/app/Http/Controllers/TransactionCurrency/IndexController.phpindex 0c728a982c..4c1d017f8f 100644--- a/app/Http/Controllers/TransactionCurrency/IndexController.php+++ b/app/Http/Controllers/TransactionCurrency/IndexController.php@@ -74,10 +74,10 @@ class IndexController extends Controller// order so default and enabled are on top:$collection = $collection->sortBy(static function (TransactionCurrency $currency) {- $default = true === $currency->userGroupDefault ? 0 : 1;+ $native = true === $currency->userGroupNative ? 0 : 1;$enabled = true === $currency->userGroupEnabled ? 0 : 1;- return sprintf('%s-%s-%s', $default, $enabled, $currency->code);+ return sprintf('%s-%s-%s', $native, $enabled, $currency->code);});$total = $collection->count();diff --git a/app/Models/TransactionCurrency.php b/app/Models/TransactionCurrency.phpindex 9577d3a2d4..dae357cb16 100644--- a/app/Models/TransactionCurrency.php+++ b/app/Models/TransactionCurrency.php@@ -37,7 +37,7 @@ class TransactionCurrency extends Modeluse ReturnsIntegerIdTrait;use SoftDeletes;- public ?bool $userGroupDefault = null;+ public ?bool $userGroupNative = null;public ?bool $userGroupEnabled = null;protected $casts= [@@ -73,8 +73,8 @@ class TransactionCurrency extends Modelpublic function refreshForUser(User $user): void{$current = $user->userGroup->currencies()->where('transaction_currencies.id', $this->id)->first();- $default = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup);- $this->userGroupDefault = $default->id === $this->id;+ $native = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup);+ $this->userGroupNative = $native->id === $this->id;$this->userGroupEnabled = null !== $current;}diff --git a/app/Repositories/UserGroups/Currency/CurrencyRepository.php b/app/Repositories/UserGroups/Currency/CurrencyRepository.phpindex 86c116c4b6..1bfec5cee3 100644--- a/app/Repositories/UserGroups/Currency/CurrencyRepository.php+++ b/app/Repositories/UserGroups/Currency/CurrencyRepository.php@@ -180,11 +180,11 @@ class CurrencyRepository implements CurrencyRepositoryInterface$hasId = $local->contains(static function (TransactionCurrency $entry) use ($current) {return $entry->id === $current->id;});- $isDefault = $local->contains(static function (TransactionCurrency $entry) use ($current) {+ $isNative = $local->contains(static function (TransactionCurrency $entry) use ($current) {return 1 === (int) $entry->pivot->group_default && $entry->id === $current->id;});$current->userGroupEnabled = $hasId;- $current->userGroupDefault = $isDefault;+ $current->userGroupNative = $isNative;return $current;});@@ -195,7 +195,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface$all = $this->userGroup->currencies()->orderBy('code', 'ASC')->withPivot(['group_default'])->get();$all->map(static function (TransactionCurrency $current) { // @phpstan-ignore-line$current->userGroupEnabled = true;- $current->userGroupDefault = 1 === (int) $current->pivot->group_default;+ $current->userGroupNative = 1 === (int) $current->pivot->group_default;return $current;});diff --git a/app/Services/Internal/Update/CurrencyUpdateService.php b/app/Services/Internal/Update/CurrencyUpdateService.phpindex 1ef57f722c..8931b33921 100644--- a/app/Services/Internal/Update/CurrencyUpdateService.php+++ b/app/Services/Internal/Update/CurrencyUpdateService.php@@ -51,7 +51,7 @@ class CurrencyUpdateService$currency->decimal_places = $data['decimal_places'];}$currency->userGroupEnabled = null;- $currency->userGroupDefault = null;+ $currency->userGroupNative = null;$currency->save();return $currency;diff --git a/app/Support/Amount.php b/app/Support/Amount.phpindex 939a691670..3cf86907d4 100644--- a/app/Support/Amount.php+++ b/app/Support/Amount.php@@ -168,25 +168,32 @@ class Amountreturn $this->getSystemCurrency();}+ /**+ * @deprecated+ */public function getDefaultCurrencyByUserGroup(UserGroup $userGroup): TransactionCurrency+ {+ return $this->getNativeCurrencyByUserGroup($userGroup);+ }+ public function getNativeCurrencyByUserGroup(UserGroup $userGroup): TransactionCurrency{$cache = new CacheProperties();- $cache->addProperty('getDefaultCurrencyByGroup');+ $cache->addProperty('getNativeCurrencyByGroup');$cache->addProperty($userGroup->id);if ($cache->has()) {return $cache->get();}/** @var null|TransactionCurrency $default */- $default = $userGroup->currencies()->where('group_default', true)->first();- if (null === $default) {- $default = $this->getSystemCurrency();+ $native = $userGroup->currencies()->where('group_default', true)->first();+ if (null === $native) {+ $native = $this->getSystemCurrency();// could be the user group has no default right now.- $userGroup->currencies()->sync([$default->id => ['group_default' => true]]);+ $userGroup->currencies()->sync([$native->id => ['group_default' => true]]);}- $cache->store($default);+ $cache->store($native);- return $default;+ return $native;}public function getSystemCurrency(): TransactionCurrencydiff --git a/app/Transformers/CurrencyTransformer.php b/app/Transformers/CurrencyTransformer.phpindex 4af5284b2b..a7eaa5a5e1 100644--- a/app/Transformers/CurrencyTransformer.php+++ b/app/Transformers/CurrencyTransformer.php@@ -40,7 +40,7 @@ class CurrencyTransformer extends AbstractTransformer'id' => $currency->id,'created_at' => $currency->created_at->toAtomString(),'updated_at' => $currency->updated_at->toAtomString(),- 'default' => $currency->userGroupDefault,+ 'native' => $currency->userGroupNative,'enabled' => $currency->userGroupEnabled,'name' => $currency->name,'code' => $currency->code,diff --git a/app/Transformers/V2/CurrencyTransformer.php b/app/Transformers/V2/CurrencyTransformer.phpindex dcc142fa3d..3a03fe9823 100644--- a/app/Transformers/V2/CurrencyTransformer.php+++ b/app/Transformers/V2/CurrencyTransformer.php@@ -46,7 +46,7 @@ class CurrencyTransformer extends AbstractTransformer'id' => $currency->id,'created_at' => $currency->created_at->toAtomString(),'updated_at' => $currency->updated_at->toAtomString(),- 'default' => $currency->userGroupDefault,+ 'native' => $currency->userGroupNative,'enabled' => $currency->userGroupEnabled,'name' => $currency->name,'code' => $currency->code,diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.phpindex c8b74e176b..b7c3125d24 100644--- a/resources/lang/en_US/firefly.php+++ b/resources/lang/en_US/firefly.php@@ -1775,9 +1775,10 @@ return ['updated_currency' => 'Currency :name updated','ask_site_owner' => 'Please ask :owner to add, remove or edit currencies.','currencies_intro' => 'Firefly III supports various currencies which you can set and enable here.',- 'currencies_switch_default' => 'If you have a large database, switching from one default currency to another may take a moment.',+ 'currencies_switch_default' => 'You can switch the native currency for your current administration on the "Financial administrations"-page.','make_default_currency' => 'Make default','default_currency' => 'default',+ 'native_currency_button' => 'native','currency_is_disabled' => 'Disabled','enable_currency' => 'Enable','disable_currency' => 'Disable',diff --git a/resources/views/currencies/index.twig b/resources/views/currencies/index.twigindex 9da52a312b..9824443efb 100644--- a/resources/views/currencies/index.twig+++ b/resources/views/currencies/index.twig@@ -56,12 +56,6 @@<span class="fa fa-fw fa-check-square-o"></span>{{ 'enable_currency'|_ }}</a>{% endif %}-- {# Make currency default. #}- {% if currency.id != defaultCurrency.id %}- <button data-code="{{ currency.code }}" class="make_default btn btn-default"><span- class="fa fa-fw fa-star"></span> {{ 'make_default_currency'|_ }}</button>- {% endif %}</div></td><td>@@ -70,7 +64,7 @@{% endif %}{{ currency.name }} ({{ currency.code }}) ({{ currency.symbol|raw }}){% if currency.id == defaultCurrency.id %}- <span class="label label-success" id="default-currency">{{ 'default_currency'|_ }}</span>+ <span class="label label-success" id="default-currency">{{ 'native_currency_button'|_ }}</span>{% endif %}{% if currency.userGroupEnabled == false %}