mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Rename default to native.
This commit is contained in:
parent
3766128cb8
commit
ae366341cc
@ -66,7 +66,7 @@ class ShowController extends Controller
|
|||||||
$default = 1 === $group->pivot->group_default;
|
$default = 1 === $group->pivot->group_default;
|
||||||
}
|
}
|
||||||
$currency->userGroupEnabled = $enabled;
|
$currency->userGroupEnabled = $enabled;
|
||||||
$currency->userGroupDefault = $default;
|
$currency->userGroupNative = $default;
|
||||||
|
|
||||||
|
|
||||||
$transformer = new CurrencyTransformer();
|
$transformer = new CurrencyTransformer();
|
||||||
|
@ -74,10 +74,10 @@ class IndexController extends Controller
|
|||||||
// order so default and enabled are on top:
|
// order so default and enabled are on top:
|
||||||
$collection = $collection->sortBy(
|
$collection = $collection->sortBy(
|
||||||
static function (TransactionCurrency $currency) {
|
static function (TransactionCurrency $currency) {
|
||||||
$default = true === $currency->userGroupDefault ? 0 : 1;
|
$native = true === $currency->userGroupNative ? 0 : 1;
|
||||||
$enabled = true === $currency->userGroupEnabled ? 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();
|
$total = $collection->count();
|
||||||
|
@ -37,7 +37,7 @@ class TransactionCurrency extends Model
|
|||||||
use ReturnsIntegerIdTrait;
|
use ReturnsIntegerIdTrait;
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
public ?bool $userGroupDefault = null;
|
public ?bool $userGroupNative = null;
|
||||||
public ?bool $userGroupEnabled = null;
|
public ?bool $userGroupEnabled = null;
|
||||||
protected $casts
|
protected $casts
|
||||||
= [
|
= [
|
||||||
@ -73,8 +73,8 @@ class TransactionCurrency extends Model
|
|||||||
public function refreshForUser(User $user): void
|
public function refreshForUser(User $user): void
|
||||||
{
|
{
|
||||||
$current = $user->userGroup->currencies()->where('transaction_currencies.id', $this->id)->first();
|
$current = $user->userGroup->currencies()->where('transaction_currencies.id', $this->id)->first();
|
||||||
$default = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup);
|
$native = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup);
|
||||||
$this->userGroupDefault = $default->id === $this->id;
|
$this->userGroupNative = $native->id === $this->id;
|
||||||
$this->userGroupEnabled = null !== $current;
|
$this->userGroupEnabled = null !== $current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,11 +180,11 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
|||||||
$hasId = $local->contains(static function (TransactionCurrency $entry) use ($current) {
|
$hasId = $local->contains(static function (TransactionCurrency $entry) use ($current) {
|
||||||
return $entry->id === $current->id;
|
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;
|
return 1 === (int) $entry->pivot->group_default && $entry->id === $current->id;
|
||||||
});
|
});
|
||||||
$current->userGroupEnabled = $hasId;
|
$current->userGroupEnabled = $hasId;
|
||||||
$current->userGroupDefault = $isDefault;
|
$current->userGroupNative = $isNative;
|
||||||
|
|
||||||
return $current;
|
return $current;
|
||||||
});
|
});
|
||||||
@ -195,7 +195,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
|||||||
$all = $this->userGroup->currencies()->orderBy('code', 'ASC')->withPivot(['group_default'])->get();
|
$all = $this->userGroup->currencies()->orderBy('code', 'ASC')->withPivot(['group_default'])->get();
|
||||||
$all->map(static function (TransactionCurrency $current) { // @phpstan-ignore-line
|
$all->map(static function (TransactionCurrency $current) { // @phpstan-ignore-line
|
||||||
$current->userGroupEnabled = true;
|
$current->userGroupEnabled = true;
|
||||||
$current->userGroupDefault = 1 === (int) $current->pivot->group_default;
|
$current->userGroupNative = 1 === (int) $current->pivot->group_default;
|
||||||
|
|
||||||
return $current;
|
return $current;
|
||||||
});
|
});
|
||||||
|
@ -51,7 +51,7 @@ class CurrencyUpdateService
|
|||||||
$currency->decimal_places = $data['decimal_places'];
|
$currency->decimal_places = $data['decimal_places'];
|
||||||
}
|
}
|
||||||
$currency->userGroupEnabled = null;
|
$currency->userGroupEnabled = null;
|
||||||
$currency->userGroupDefault = null;
|
$currency->userGroupNative = null;
|
||||||
$currency->save();
|
$currency->save();
|
||||||
|
|
||||||
return $currency;
|
return $currency;
|
||||||
|
@ -168,25 +168,32 @@ class Amount
|
|||||||
return $this->getSystemCurrency();
|
return $this->getSystemCurrency();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
public function getDefaultCurrencyByUserGroup(UserGroup $userGroup): TransactionCurrency
|
public function getDefaultCurrencyByUserGroup(UserGroup $userGroup): TransactionCurrency
|
||||||
|
{
|
||||||
|
return $this->getNativeCurrencyByUserGroup($userGroup);
|
||||||
|
}
|
||||||
|
public function getNativeCurrencyByUserGroup(UserGroup $userGroup): TransactionCurrency
|
||||||
{
|
{
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty('getDefaultCurrencyByGroup');
|
$cache->addProperty('getNativeCurrencyByGroup');
|
||||||
$cache->addProperty($userGroup->id);
|
$cache->addProperty($userGroup->id);
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return $cache->get();
|
return $cache->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var null|TransactionCurrency $default */
|
/** @var null|TransactionCurrency $default */
|
||||||
$default = $userGroup->currencies()->where('group_default', true)->first();
|
$native = $userGroup->currencies()->where('group_default', true)->first();
|
||||||
if (null === $default) {
|
if (null === $native) {
|
||||||
$default = $this->getSystemCurrency();
|
$native = $this->getSystemCurrency();
|
||||||
// could be the user group has no default right now.
|
// 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(): TransactionCurrency
|
public function getSystemCurrency(): TransactionCurrency
|
||||||
|
@ -40,7 +40,7 @@ class CurrencyTransformer extends AbstractTransformer
|
|||||||
'id' => $currency->id,
|
'id' => $currency->id,
|
||||||
'created_at' => $currency->created_at->toAtomString(),
|
'created_at' => $currency->created_at->toAtomString(),
|
||||||
'updated_at' => $currency->updated_at->toAtomString(),
|
'updated_at' => $currency->updated_at->toAtomString(),
|
||||||
'default' => $currency->userGroupDefault,
|
'native' => $currency->userGroupNative,
|
||||||
'enabled' => $currency->userGroupEnabled,
|
'enabled' => $currency->userGroupEnabled,
|
||||||
'name' => $currency->name,
|
'name' => $currency->name,
|
||||||
'code' => $currency->code,
|
'code' => $currency->code,
|
||||||
|
@ -46,7 +46,7 @@ class CurrencyTransformer extends AbstractTransformer
|
|||||||
'id' => $currency->id,
|
'id' => $currency->id,
|
||||||
'created_at' => $currency->created_at->toAtomString(),
|
'created_at' => $currency->created_at->toAtomString(),
|
||||||
'updated_at' => $currency->updated_at->toAtomString(),
|
'updated_at' => $currency->updated_at->toAtomString(),
|
||||||
'default' => $currency->userGroupDefault,
|
'native' => $currency->userGroupNative,
|
||||||
'enabled' => $currency->userGroupEnabled,
|
'enabled' => $currency->userGroupEnabled,
|
||||||
'name' => $currency->name,
|
'name' => $currency->name,
|
||||||
'code' => $currency->code,
|
'code' => $currency->code,
|
||||||
|
@ -1775,9 +1775,10 @@ return [
|
|||||||
'updated_currency' => 'Currency :name updated',
|
'updated_currency' => 'Currency :name updated',
|
||||||
'ask_site_owner' => 'Please ask :owner to add, remove or edit currencies.',
|
'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_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',
|
'make_default_currency' => 'Make default',
|
||||||
'default_currency' => 'default',
|
'default_currency' => 'default',
|
||||||
|
'native_currency_button' => 'native',
|
||||||
'currency_is_disabled' => 'Disabled',
|
'currency_is_disabled' => 'Disabled',
|
||||||
'enable_currency' => 'Enable',
|
'enable_currency' => 'Enable',
|
||||||
'disable_currency' => 'Disable',
|
'disable_currency' => 'Disable',
|
||||||
|
@ -56,12 +56,6 @@
|
|||||||
<span class="fa fa-fw fa-check-square-o"></span>
|
<span class="fa fa-fw fa-check-square-o"></span>
|
||||||
{{ 'enable_currency'|_ }}</a>
|
{{ 'enable_currency'|_ }}</a>
|
||||||
{% endif %}
|
{% 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>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@ -70,7 +64,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{{ currency.name }} ({{ currency.code }}) ({{ currency.symbol|raw }})
|
{{ currency.name }} ({{ currency.code }}) ({{ currency.symbol|raw }})
|
||||||
{% if currency.id == defaultCurrency.id %}
|
{% 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 %}
|
{% endif %}
|
||||||
{% if currency.userGroupEnabled == false %}
|
{% if currency.userGroupEnabled == false %}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user