mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-20 03:08:11 +00:00
Rename default to primary
This commit is contained in:
@@ -63,10 +63,10 @@ class CorrectsCurrencies extends Command
|
|||||||
$repos = app(CurrencyRepositoryInterface::class);
|
$repos = app(CurrencyRepositoryInterface::class);
|
||||||
|
|
||||||
// first check if the user has any default currency (not necessarily the case, so can be forced).
|
// 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));
|
Log::debug(sprintf('Now correcting currencies for user group #%d', $userGroup->id));
|
||||||
$found = [$defaultCurrency->id];
|
$found = [$primaryCurrency->id];
|
||||||
|
|
||||||
// get all meta entries
|
// get all meta entries
|
||||||
$meta = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
|
$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]);
|
$accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value]);
|
||||||
|
|
||||||
// get user's currency preference:
|
// get user's currency preference:
|
||||||
$defaultCurrency = app('amount')->getPrimaryCurrencyByUserGroup($user->userGroup);
|
$primaryCurrency = app('amount')->getPrimaryCurrencyByUserGroup($user->userGroup);
|
||||||
|
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
foreach ($accounts as $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:
|
// set the default currency for the user and for the group:
|
||||||
$preference = $this->getPreference($user);
|
$preference = $this->getPreference($user);
|
||||||
$defaultCurrency = TransactionCurrency::where('code', $preference)->first();
|
$primaryCurrency = TransactionCurrency::where('code', $preference)->first();
|
||||||
if (null === $defaultCurrency) {
|
if (null === $primaryCurrency) {
|
||||||
// get EUR
|
// get EUR
|
||||||
$defaultCurrency = TransactionCurrency::where('code', 'EUR')->first();
|
$primaryCurrency = TransactionCurrency::where('code', 'EUR')->first();
|
||||||
}
|
}
|
||||||
$user->currencies()->updateExistingPivot($defaultCurrency->id, ['user_default' => true]);
|
$user->currencies()->updateExistingPivot($primaryCurrency->id, ['user_default' => true]);
|
||||||
$user->userGroup->currencies()->updateExistingPivot($defaultCurrency->id, ['group_default' => true]);
|
$user->userGroup->currencies()->updateExistingPivot($primaryCurrency->id, ['group_default' => true]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getPreference(User $user): string
|
private function getPreference(User $user): string
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* UserGroupChangedDefaultCurrency.php
|
* UserGroupChangedPrimaryCurrency.php
|
||||||
* Copyright (c) 2024 james@firefly-iii.org.
|
* Copyright (c) 2024 james@firefly-iii.org.
|
||||||
*
|
*
|
||||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
@@ -29,7 +29,7 @@ use FireflyIII\Models\UserGroup;
|
|||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class UserGroupChangedDefaultCurrency extends Event
|
class UserGroupChangedPrimaryCurrency extends Event
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@@ -126,7 +126,7 @@ class PiggyBankFactory
|
|||||||
private function getCurrency(array $data): TransactionCurrency
|
private function getCurrency(array $data): TransactionCurrency
|
||||||
{
|
{
|
||||||
// currency:
|
// currency:
|
||||||
$defaultCurrency = app('amount')->getPrimaryCurrency();
|
$primaryCurrency = app('amount')->getPrimaryCurrency();
|
||||||
$currency = null;
|
$currency = null;
|
||||||
if (array_key_exists('transaction_currency_code', $data)) {
|
if (array_key_exists('transaction_currency_code', $data)) {
|
||||||
$currency = $this->currencyRepository->findByCode((string)($data['transaction_currency_code'] ?? ''));
|
$currency = $this->currencyRepository->findByCode((string)($data['transaction_currency_code'] ?? ''));
|
||||||
@@ -134,7 +134,7 @@ class PiggyBankFactory
|
|||||||
if (array_key_exists('transaction_currency_id', $data)) {
|
if (array_key_exists('transaction_currency_id', $data)) {
|
||||||
$currency = $this->currencyRepository->find((int)($data['transaction_currency_id'] ?? 0));
|
$currency = $this->currencyRepository->find((int)($data['transaction_currency_id'] ?? 0));
|
||||||
}
|
}
|
||||||
$currency ??= $defaultCurrency;
|
$currency ??= $primaryCurrency;
|
||||||
|
|
||||||
return $currency;
|
return $currency;
|
||||||
}
|
}
|
||||||
|
@@ -141,8 +141,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
|||||||
Log::debug(sprintf('getAuditReport: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
Log::debug(sprintf('getAuditReport: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
||||||
$dayBeforeBalance = Steam::finalAccountBalance($account, $date);
|
$dayBeforeBalance = Steam::finalAccountBalance($account, $date);
|
||||||
$startBalance = $dayBeforeBalance['balance'];
|
$startBalance = $dayBeforeBalance['balance'];
|
||||||
$defaultCurrency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
$primaryCurrency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||||
$currency = $accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
|
$currency = $accountRepository->getAccountCurrency($account) ?? $primaryCurrency;
|
||||||
|
|
||||||
foreach ($journals as $index => $journal) {
|
foreach ($journals as $index => $journal) {
|
||||||
$journals[$index]['balance_before'] = $startBalance;
|
$journals[$index]['balance_before'] = $startBalance;
|
||||||
|
@@ -24,7 +24,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Handlers\Events;
|
namespace FireflyIII\Handlers\Events;
|
||||||
|
|
||||||
use FireflyIII\Events\Preferences\UserGroupChangedDefaultCurrency;
|
use FireflyIII\Events\Preferences\UserGroupChangedPrimaryCurrency;
|
||||||
use FireflyIII\Models\Budget;
|
use FireflyIII\Models\Budget;
|
||||||
use FireflyIII\Models\PiggyBank;
|
use FireflyIII\Models\PiggyBank;
|
||||||
use FireflyIII\Models\UserGroup;
|
use FireflyIII\Models\UserGroup;
|
||||||
@@ -38,7 +38,7 @@ use Illuminate\Support\Facades\Log;
|
|||||||
|
|
||||||
class PreferencesEventHandler
|
class PreferencesEventHandler
|
||||||
{
|
{
|
||||||
public function resetPrimaryCurrencyAmounts(UserGroupChangedDefaultCurrency $event): void
|
public function resetPrimaryCurrencyAmounts(UserGroupChangedPrimaryCurrency $event): void
|
||||||
{
|
{
|
||||||
// Reset the primary currency amounts for all objects that have it.
|
// Reset the primary currency amounts for all objects that have it.
|
||||||
Log::debug('Resetting primary currency amounts for all objects.');
|
Log::debug('Resetting primary currency amounts for all objects.');
|
||||||
|
@@ -77,7 +77,7 @@ class CreateController extends Controller
|
|||||||
$periods[$current] = (string) trans('firefly.repeat_freq_'.$current);
|
$periods[$current] = (string) trans('firefly.repeat_freq_'.$current);
|
||||||
}
|
}
|
||||||
$subTitle = (string) trans('firefly.create_new_bill');
|
$subTitle = (string) trans('firefly.create_new_bill');
|
||||||
$defaultCurrency = $this->primaryCurrency;
|
$primaryCurrency = $this->primaryCurrency;
|
||||||
|
|
||||||
// put previous url in session if not redirect from store (not "create another").
|
// put previous url in session if not redirect from store (not "create another").
|
||||||
if (true !== session('bills.create.fromStore')) {
|
if (true !== session('bills.create.fromStore')) {
|
||||||
@@ -85,7 +85,7 @@ class CreateController extends Controller
|
|||||||
}
|
}
|
||||||
$request->session()->forget('bills.create.fromStore');
|
$request->session()->forget('bills.create.fromStore');
|
||||||
|
|
||||||
return view('bills.create', compact('periods', 'subTitle', 'defaultCurrency'));
|
return view('bills.create', compact('periods', 'subTitle', 'primaryCurrency'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -88,7 +88,7 @@ class EditController extends Controller
|
|||||||
$bill->amount_min = app('steam')->bcround($bill->amount_min, $bill->transactionCurrency->decimal_places);
|
$bill->amount_min = app('steam')->bcround($bill->amount_min, $bill->transactionCurrency->decimal_places);
|
||||||
$bill->amount_max = app('steam')->bcround($bill->amount_max, $bill->transactionCurrency->decimal_places);
|
$bill->amount_max = app('steam')->bcround($bill->amount_max, $bill->transactionCurrency->decimal_places);
|
||||||
$rules = $this->repository->getRulesForBill($bill);
|
$rules = $this->repository->getRulesForBill($bill);
|
||||||
$defaultCurrency = $this->primaryCurrency;
|
$primaryCurrency = $this->primaryCurrency;
|
||||||
|
|
||||||
// code to handle active-checkboxes
|
// code to handle active-checkboxes
|
||||||
$hasOldInput = null !== $request->old('_token');
|
$hasOldInput = null !== $request->old('_token');
|
||||||
@@ -105,7 +105,7 @@ class EditController extends Controller
|
|||||||
$request->session()->flash('preFilled', $preFilled);
|
$request->session()->flash('preFilled', $preFilled);
|
||||||
$request->session()->forget('bills.edit.fromUpdate');
|
$request->session()->forget('bills.edit.fromUpdate');
|
||||||
|
|
||||||
return view('bills.edit', compact('subTitle', 'periods', 'rules', 'bill', 'defaultCurrency', 'preFilled'));
|
return view('bills.edit', compact('subTitle', 'periods', 'rules', 'bill', 'primaryCurrency', 'preFilled'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -101,7 +101,7 @@ class IndexController extends Controller
|
|||||||
$parameters->set('start', $tempStart);
|
$parameters->set('start', $tempStart);
|
||||||
$parameters->set('end', $end);
|
$parameters->set('end', $end);
|
||||||
$parameters->set('convertToPrimary', $this->convertToPrimary);
|
$parameters->set('convertToPrimary', $this->convertToPrimary);
|
||||||
$parameters->set('defaultCurrency', $this->primaryCurrency);
|
$parameters->set('primaryCurrency', $this->primaryCurrency);
|
||||||
|
|
||||||
/** @var BillTransformer $transformer */
|
/** @var BillTransformer $transformer */
|
||||||
$transformer = app(BillTransformer::class);
|
$transformer = app(BillTransformer::class);
|
||||||
|
@@ -136,7 +136,7 @@ class IndexController extends Controller
|
|||||||
|
|
||||||
// get all inactive budgets, and simply list them:
|
// get all inactive budgets, and simply list them:
|
||||||
$inactive = $this->repository->getInactiveBudgets();
|
$inactive = $this->repository->getInactiveBudgets();
|
||||||
$defaultCurrency = $this->primaryCurrency;
|
$primaryCurrency = $this->primaryCurrency;
|
||||||
|
|
||||||
return view(
|
return view(
|
||||||
'budgets.index',
|
'budgets.index',
|
||||||
@@ -149,7 +149,7 @@ class IndexController extends Controller
|
|||||||
'budgets',
|
'budgets',
|
||||||
'currencies',
|
'currencies',
|
||||||
'periodTitle',
|
'periodTitle',
|
||||||
'defaultCurrency',
|
'primaryCurrency',
|
||||||
'activeDaysPassed',
|
'activeDaysPassed',
|
||||||
'activeDaysLeft',
|
'activeDaysLeft',
|
||||||
'inactive',
|
'inactive',
|
||||||
@@ -194,7 +194,7 @@ class IndexController extends Controller
|
|||||||
return $availableBudgets;
|
return $availableBudgets;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getAllBudgets(Carbon $start, Carbon $end, Collection $currencies, TransactionCurrency $defaultCurrency): array
|
private function getAllBudgets(Carbon $start, Carbon $end, Collection $currencies, TransactionCurrency $primaryCurrency): array
|
||||||
{
|
{
|
||||||
// get all budgets, and paginate them into $budgets.
|
// get all budgets, and paginate them into $budgets.
|
||||||
$collection = $this->repository->getActiveBudgets();
|
$collection = $this->repository->getActiveBudgets();
|
||||||
@@ -216,7 +216,7 @@ class IndexController extends Controller
|
|||||||
/** @var BudgetLimit $limit */
|
/** @var BudgetLimit $limit */
|
||||||
foreach ($budgetLimits as $limit) {
|
foreach ($budgetLimits as $limit) {
|
||||||
Log::debug(sprintf('Working on budget limit #%d', $limit->id));
|
Log::debug(sprintf('Working on budget limit #%d', $limit->id));
|
||||||
$currency = $limit->transactionCurrency ?? $defaultCurrency;
|
$currency = $limit->transactionCurrency ?? $primaryCurrency;
|
||||||
$amount = app('steam')->bcround($limit->amount, $currency->decimal_places);
|
$amount = app('steam')->bcround($limit->amount, $currency->decimal_places);
|
||||||
$array['budgeted'][] = [
|
$array['budgeted'][] = [
|
||||||
'id' => $limit->id,
|
'id' => $limit->id,
|
||||||
|
@@ -26,7 +26,7 @@ namespace FireflyIII\Http\Controllers;
|
|||||||
use JsonException;
|
use JsonException;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Enums\AccountTypeEnum;
|
use FireflyIII\Enums\AccountTypeEnum;
|
||||||
use FireflyIII\Events\Preferences\UserGroupChangedDefaultCurrency;
|
use FireflyIII\Events\Preferences\UserGroupChangedPrimaryCurrency;
|
||||||
use FireflyIII\Events\Test\UserTestNotificationChannel;
|
use FireflyIII\Events\Test\UserTestNotificationChannel;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Http\Requests\PreferencesRequest;
|
use FireflyIII\Http\Requests\PreferencesRequest;
|
||||||
@@ -271,7 +271,7 @@ class PreferencesController extends Controller
|
|||||||
// set to true!
|
// set to true!
|
||||||
Log::debug('User sets convertToPrimary to true.');
|
Log::debug('User sets convertToPrimary to true.');
|
||||||
Preferences::set('convert_to_primary', $convertToPrimary);
|
Preferences::set('convert_to_primary', $convertToPrimary);
|
||||||
event(new UserGroupChangedDefaultCurrency(auth()->user()->userGroup));
|
event(new UserGroupChangedPrimaryCurrency(auth()->user()->userGroup));
|
||||||
}
|
}
|
||||||
Preferences::set('convert_to_primary', $convertToPrimary);
|
Preferences::set('convert_to_primary', $convertToPrimary);
|
||||||
|
|
||||||
|
@@ -84,7 +84,7 @@ class CreateController extends Controller
|
|||||||
{
|
{
|
||||||
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
|
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
|
||||||
$bills = app('expandedform')->makeSelectListWithEmpty($this->billRepository->getActiveBills());
|
$bills = app('expandedform')->makeSelectListWithEmpty($this->billRepository->getActiveBills());
|
||||||
$defaultCurrency = $this->primaryCurrency;
|
$primaryCurrency = $this->primaryCurrency;
|
||||||
$tomorrow = today(config('app.timezone'));
|
$tomorrow = today(config('app.timezone'));
|
||||||
$oldRepetitionType = $request->old('repetition_type');
|
$oldRepetitionType = $request->old('repetition_type');
|
||||||
$tomorrow->addDay();
|
$tomorrow->addDay();
|
||||||
@@ -116,7 +116,7 @@ class CreateController extends Controller
|
|||||||
|
|
||||||
return view(
|
return view(
|
||||||
'recurring.create',
|
'recurring.create',
|
||||||
compact('tomorrow', 'oldRepetitionType', 'bills', 'weekendResponses', 'preFilled', 'repetitionEnds', 'defaultCurrency', 'budgets')
|
compact('tomorrow', 'oldRepetitionType', 'bills', 'weekendResponses', 'preFilled', 'repetitionEnds', 'primaryCurrency', 'budgets')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ class CreateController extends Controller
|
|||||||
{
|
{
|
||||||
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
|
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
|
||||||
$bills = app('expandedform')->makeSelectListWithEmpty($this->billRepository->getActiveBills());
|
$bills = app('expandedform')->makeSelectListWithEmpty($this->billRepository->getActiveBills());
|
||||||
$defaultCurrency = $this->primaryCurrency;
|
$primaryCurrency = $this->primaryCurrency;
|
||||||
$tomorrow = today(config('app.timezone'));
|
$tomorrow = today(config('app.timezone'));
|
||||||
$oldRepetitionType = $request->old('repetition_type');
|
$oldRepetitionType = $request->old('repetition_type');
|
||||||
$tomorrow->addDay();
|
$tomorrow->addDay();
|
||||||
@@ -210,7 +210,7 @@ class CreateController extends Controller
|
|||||||
|
|
||||||
return view(
|
return view(
|
||||||
'recurring.create',
|
'recurring.create',
|
||||||
compact('tomorrow', 'oldRepetitionType', 'bills', 'weekendResponses', 'preFilled', 'repetitionEnds', 'defaultCurrency', 'budgets')
|
compact('tomorrow', 'oldRepetitionType', 'bills', 'weekendResponses', 'preFilled', 'repetitionEnds', 'primaryCurrency', 'budgets')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -117,7 +117,7 @@ class CreateController extends Controller
|
|||||||
$optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
|
$optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
|
||||||
$allowedOpposingTypes = config('firefly.allowed_opposing_types');
|
$allowedOpposingTypes = config('firefly.allowed_opposing_types');
|
||||||
$accountToTypes = config('firefly.account_to_transaction');
|
$accountToTypes = config('firefly.account_to_transaction');
|
||||||
$defaultCurrency = $this->primaryCurrency;
|
$primaryCurrency = $this->primaryCurrency;
|
||||||
$previousUrl = $this->rememberPreviousUrl('transactions.create.url');
|
$previousUrl = $this->rememberPreviousUrl('transactions.create.url');
|
||||||
$parts = parse_url((string) $previousUrl);
|
$parts = parse_url((string) $previousUrl);
|
||||||
$search = sprintf('?%s', $parts['query'] ?? '');
|
$search = sprintf('?%s', $parts['query'] ?? '');
|
||||||
@@ -156,7 +156,7 @@ class CreateController extends Controller
|
|||||||
'objectType',
|
'objectType',
|
||||||
'optionalDateFields',
|
'optionalDateFields',
|
||||||
'subTitle',
|
'subTitle',
|
||||||
'defaultCurrency',
|
'primaryCurrency',
|
||||||
'previousUrl',
|
'previousUrl',
|
||||||
'optionalFields',
|
'optionalFields',
|
||||||
'preFilled',
|
'preFilled',
|
||||||
|
@@ -84,7 +84,7 @@ class EditController extends Controller
|
|||||||
$title = $transactionGroup->transactionJournals()->count() > 1 ? $transactionGroup->title : $transactionGroup->transactionJournals()->first()->description;
|
$title = $transactionGroup->transactionJournals()->count() > 1 ? $transactionGroup->title : $transactionGroup->transactionJournals()->first()->description;
|
||||||
$subTitle = (string) trans('firefly.edit_transaction_title', ['description' => $title]);
|
$subTitle = (string) trans('firefly.edit_transaction_title', ['description' => $title]);
|
||||||
$subTitleIcon = 'fa-plus';
|
$subTitleIcon = 'fa-plus';
|
||||||
$defaultCurrency = $this->primaryCurrency;
|
$primaryCurrency = $this->primaryCurrency;
|
||||||
$cash = $repository->getCashAccount();
|
$cash = $repository->getCashAccount();
|
||||||
$previousUrl = $this->rememberPreviousUrl('transactions.edit.url');
|
$previousUrl = $this->rememberPreviousUrl('transactions.edit.url');
|
||||||
$parts = parse_url((string) $previousUrl);
|
$parts = parse_url((string) $previousUrl);
|
||||||
@@ -130,7 +130,7 @@ class EditController extends Controller
|
|||||||
'transactionGroup',
|
'transactionGroup',
|
||||||
'allowedOpposingTypes',
|
'allowedOpposingTypes',
|
||||||
'accountToTypes',
|
'accountToTypes',
|
||||||
'defaultCurrency',
|
'primaryCurrency',
|
||||||
'previousUrl'
|
'previousUrl'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@@ -120,7 +120,7 @@ class Range
|
|||||||
// save some formats:
|
// save some formats:
|
||||||
$monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);
|
$monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);
|
||||||
$dateTimeFormat = (string) trans('config.date_time_js', [], $locale);
|
$dateTimeFormat = (string) trans('config.date_time_js', [], $locale);
|
||||||
$defaultCurrency = Amount::getPrimaryCurrency();
|
$primaryCurrency = Amount::getPrimaryCurrency();
|
||||||
|
|
||||||
// also format for moment JS:
|
// also format for moment JS:
|
||||||
$madMomentJS = (string) trans('config.month_and_day_moment_js', [], $locale);
|
$madMomentJS = (string) trans('config.month_and_day_moment_js', [], $locale);
|
||||||
@@ -128,7 +128,7 @@ class Range
|
|||||||
app('view')->share('madMomentJS', $madMomentJS);
|
app('view')->share('madMomentJS', $madMomentJS);
|
||||||
app('view')->share('monthAndDayFormat', $monthAndDayFormat);
|
app('view')->share('monthAndDayFormat', $monthAndDayFormat);
|
||||||
app('view')->share('dateTimeFormat', $dateTimeFormat);
|
app('view')->share('dateTimeFormat', $dateTimeFormat);
|
||||||
app('view')->share('defaultCurrency', $defaultCurrency);
|
app('view')->share('primaryCurrency', $primaryCurrency);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -35,7 +35,7 @@ use FireflyIII\Events\Model\PiggyBank\ChangedName;
|
|||||||
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
|
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
|
||||||
use FireflyIII\Events\Model\Rule\RuleActionFailedOnObject;
|
use FireflyIII\Events\Model\Rule\RuleActionFailedOnObject;
|
||||||
use FireflyIII\Events\NewVersionAvailable;
|
use FireflyIII\Events\NewVersionAvailable;
|
||||||
use FireflyIII\Events\Preferences\UserGroupChangedDefaultCurrency;
|
use FireflyIII\Events\Preferences\UserGroupChangedPrimaryCurrency;
|
||||||
use FireflyIII\Events\RegisteredUser;
|
use FireflyIII\Events\RegisteredUser;
|
||||||
use FireflyIII\Events\RequestedNewPassword;
|
use FireflyIII\Events\RequestedNewPassword;
|
||||||
use FireflyIII\Events\RequestedReportOnJournals;
|
use FireflyIII\Events\RequestedReportOnJournals;
|
||||||
@@ -257,7 +257,7 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
'FireflyIII\Handlers\Events\Security\MFAHandler@sendMFAFailedAttemptsMail',
|
'FireflyIII\Handlers\Events\Security\MFAHandler@sendMFAFailedAttemptsMail',
|
||||||
],
|
],
|
||||||
// preferences
|
// preferences
|
||||||
UserGroupChangedDefaultCurrency::class => [
|
UserGroupChangedPrimaryCurrency::class => [
|
||||||
'FireflyIII\Handlers\Events\PreferencesEventHandler@resetPrimaryCurrencyAmounts',
|
'FireflyIII\Handlers\Events\PreferencesEventHandler@resetPrimaryCurrencyAmounts',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@@ -24,7 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Repositories\Currency;
|
namespace FireflyIII\Repositories\Currency;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Events\Preferences\UserGroupChangedDefaultCurrency;
|
use FireflyIII\Events\Preferences\UserGroupChangedPrimaryCurrency;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Factory\TransactionCurrencyFactory;
|
use FireflyIII\Factory\TransactionCurrencyFactory;
|
||||||
use FireflyIII\Models\AccountMeta;
|
use FireflyIII\Models\AccountMeta;
|
||||||
@@ -438,7 +438,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
|
|||||||
if ($current->id !== $currency->id) {
|
if ($current->id !== $currency->id) {
|
||||||
Log::debug('Trigger on a different default currency.');
|
Log::debug('Trigger on a different default currency.');
|
||||||
// clear all primary currency amounts through an event.
|
// clear all primary currency amounts through an event.
|
||||||
event(new UserGroupChangedDefaultCurrency($this->userGroup));
|
event(new UserGroupChangedPrimaryCurrency($this->userGroup));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Repositories\UserGroups\Currency;
|
namespace FireflyIII\Repositories\UserGroups\Currency;
|
||||||
|
|
||||||
use FireflyIII\Events\Preferences\UserGroupChangedDefaultCurrency;
|
use FireflyIII\Events\Preferences\UserGroupChangedPrimaryCurrency;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Factory\TransactionCurrencyFactory;
|
use FireflyIII\Factory\TransactionCurrencyFactory;
|
||||||
use FireflyIII\Models\AccountMeta;
|
use FireflyIII\Models\AccountMeta;
|
||||||
@@ -386,7 +386,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
|||||||
if ($current->id !== $currency->id) {
|
if ($current->id !== $currency->id) {
|
||||||
Log::debug('Trigger on a different default currency.');
|
Log::debug('Trigger on a different default currency.');
|
||||||
// clear all primary currency amounts through an event.
|
// clear all primary currency amounts through an event.
|
||||||
event(new UserGroupChangedDefaultCurrency($this->userGroup));
|
event(new UserGroupChangedPrimaryCurrency($this->userGroup));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -44,7 +44,7 @@ class FrontpageChartGenerator
|
|||||||
use AugumentData;
|
use AugumentData;
|
||||||
|
|
||||||
public bool $convertToPrimary = false;
|
public bool $convertToPrimary = false;
|
||||||
public TransactionCurrency $defaultCurrency;
|
public TransactionCurrency $primaryCurrency;
|
||||||
private AccountRepositoryInterface $accountRepos;
|
private AccountRepositoryInterface $accountRepos;
|
||||||
private array $currencies;
|
private array $currencies;
|
||||||
private NoCategoryRepositoryInterface $noCatRepos;
|
private NoCategoryRepositoryInterface $noCatRepos;
|
||||||
|
@@ -61,7 +61,7 @@ class CurrencyForm
|
|||||||
$classes = $this->getHolderClasses($name);
|
$classes = $this->getHolderClasses($name);
|
||||||
$value = $this->fillFieldValue($name, $value);
|
$value = $this->fillFieldValue($name, $value);
|
||||||
$options['step'] = 'any';
|
$options['step'] = 'any';
|
||||||
$defaultCurrency = $options['currency'] ?? app('amount')->getPrimaryCurrency();
|
$primaryCurrency = $options['currency'] ?? app('amount')->getPrimaryCurrency();
|
||||||
|
|
||||||
/** @var Collection $currencies */
|
/** @var Collection $currencies */
|
||||||
$currencies = app('amount')->getCurrencies();
|
$currencies = app('amount')->getCurrencies();
|
||||||
@@ -72,15 +72,15 @@ class CurrencyForm
|
|||||||
$preFilled = [];
|
$preFilled = [];
|
||||||
}
|
}
|
||||||
$key = 'amount_currency_id_'.$name;
|
$key = 'amount_currency_id_'.$name;
|
||||||
$sentCurrencyId = array_key_exists($key, $preFilled) ? (int) $preFilled[$key] : $defaultCurrency->id;
|
$sentCurrencyId = array_key_exists($key, $preFilled) ? (int) $preFilled[$key] : $primaryCurrency->id;
|
||||||
|
|
||||||
app('log')->debug(sprintf('Sent currency ID is %d', $sentCurrencyId));
|
app('log')->debug(sprintf('Sent currency ID is %d', $sentCurrencyId));
|
||||||
|
|
||||||
// find this currency in set of currencies:
|
// find this currency in set of currencies:
|
||||||
foreach ($currencies as $currency) {
|
foreach ($currencies as $currency) {
|
||||||
if ($currency->id === $sentCurrencyId) {
|
if ($currency->id === $sentCurrencyId) {
|
||||||
$defaultCurrency = $currency;
|
$primaryCurrency = $currency;
|
||||||
app('log')->debug(sprintf('default currency is now %s', $defaultCurrency->code));
|
app('log')->debug(sprintf('default currency is now %s', $primaryCurrency->code));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -88,11 +88,11 @@ class CurrencyForm
|
|||||||
|
|
||||||
// make sure value is formatted nicely:
|
// make sure value is formatted nicely:
|
||||||
if (null !== $value && '' !== $value) {
|
if (null !== $value && '' !== $value) {
|
||||||
$value = app('steam')->bcround($value, $defaultCurrency->decimal_places);
|
$value = app('steam')->bcround($value, $primaryCurrency->decimal_places);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$html = view('form.'.$view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
|
$html = view('form.'.$view, compact('primaryCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
app('log')->debug(sprintf('Could not render currencyField(): %s', $e->getMessage()));
|
app('log')->debug(sprintf('Could not render currencyField(): %s', $e->getMessage()));
|
||||||
$html = 'Could not render currencyField.';
|
$html = 'Could not render currencyField.';
|
||||||
@@ -129,7 +129,7 @@ class CurrencyForm
|
|||||||
$classes = $this->getHolderClasses($name);
|
$classes = $this->getHolderClasses($name);
|
||||||
$value = $this->fillFieldValue($name, $value);
|
$value = $this->fillFieldValue($name, $value);
|
||||||
$options['step'] = 'any';
|
$options['step'] = 'any';
|
||||||
$defaultCurrency = $options['currency'] ?? app('amount')->getPrimaryCurrency();
|
$primaryCurrency = $options['currency'] ?? app('amount')->getPrimaryCurrency();
|
||||||
|
|
||||||
/** @var Collection $currencies */
|
/** @var Collection $currencies */
|
||||||
$currencies = app('amount')->getAllCurrencies();
|
$currencies = app('amount')->getAllCurrencies();
|
||||||
@@ -141,15 +141,15 @@ class CurrencyForm
|
|||||||
$preFilled = [];
|
$preFilled = [];
|
||||||
}
|
}
|
||||||
$key = 'amount_currency_id_'.$name;
|
$key = 'amount_currency_id_'.$name;
|
||||||
$sentCurrencyId = array_key_exists($key, $preFilled) ? (int) $preFilled[$key] : $defaultCurrency->id;
|
$sentCurrencyId = array_key_exists($key, $preFilled) ? (int) $preFilled[$key] : $primaryCurrency->id;
|
||||||
|
|
||||||
app('log')->debug(sprintf('Sent currency ID is %d', $sentCurrencyId));
|
app('log')->debug(sprintf('Sent currency ID is %d', $sentCurrencyId));
|
||||||
|
|
||||||
// find this currency in set of currencies:
|
// find this currency in set of currencies:
|
||||||
foreach ($currencies as $currency) {
|
foreach ($currencies as $currency) {
|
||||||
if ($currency->id === $sentCurrencyId) {
|
if ($currency->id === $sentCurrencyId) {
|
||||||
$defaultCurrency = $currency;
|
$primaryCurrency = $currency;
|
||||||
app('log')->debug(sprintf('default currency is now %s', $defaultCurrency->code));
|
app('log')->debug(sprintf('default currency is now %s', $primaryCurrency->code));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -157,11 +157,11 @@ class CurrencyForm
|
|||||||
|
|
||||||
// make sure value is formatted nicely:
|
// make sure value is formatted nicely:
|
||||||
if (null !== $value && '' !== $value) {
|
if (null !== $value && '' !== $value) {
|
||||||
$value = app('steam')->bcround($value, $defaultCurrency->decimal_places);
|
$value = app('steam')->bcround($value, $primaryCurrency->decimal_places);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$html = view('form.'.$view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
|
$html = view('form.'.$view, compact('primaryCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
app('log')->debug(sprintf('Could not render currencyField(): %s', $e->getMessage()));
|
app('log')->debug(sprintf('Could not render currencyField(): %s', $e->getMessage()));
|
||||||
$html = 'Could not render currencyField.';
|
$html = 'Could not render currencyField.';
|
||||||
|
@@ -202,7 +202,7 @@ trait AugumentData
|
|||||||
$currency = $entry->transactionCurrency;
|
$currency = $entry->transactionCurrency;
|
||||||
if ($this->convertToPrimary) {
|
if ($this->convertToPrimary) {
|
||||||
// the sumExpenses method already handles this.
|
// the sumExpenses method already handles this.
|
||||||
$currency = $this->defaultCurrency;
|
$currency = $this->primaryCurrency;
|
||||||
}
|
}
|
||||||
|
|
||||||
// clone because these objects change each other.
|
// clone because these objects change each other.
|
||||||
|
@@ -113,7 +113,7 @@ class Steam
|
|||||||
|
|
||||||
if (!$convertToPrimary) {
|
if (!$convertToPrimary) {
|
||||||
if (!$currency instanceof TransactionCurrency) {
|
if (!$currency instanceof TransactionCurrency) {
|
||||||
Log::debug(sprintf('Unset pc_balance and make defaultCurrency balance the balance for account #%d', $account->id));
|
Log::debug(sprintf('Unset pc_balance and make primaryCurrency balance the balance for account #%d', $account->id));
|
||||||
$set['balance'] = $set[$primaryCurrency->code] ?? '0';
|
$set['balance'] = $set[$primaryCurrency->code] ?? '0';
|
||||||
unset($set[$primaryCurrency->code]);
|
unset($set[$primaryCurrency->code]);
|
||||||
}
|
}
|
||||||
|
@@ -224,9 +224,9 @@ trait TransactionValidation
|
|||||||
|
|
||||||
/** @var AccountRepository $accountRepository */
|
/** @var AccountRepository $accountRepository */
|
||||||
$accountRepository = app(AccountRepositoryInterface::class);
|
$accountRepository = app(AccountRepositoryInterface::class);
|
||||||
$defaultCurrency = app('amount')->getPrimaryCurrency();
|
$primaryCurrency = app('amount')->getPrimaryCurrency();
|
||||||
$sourceCurrency = $accountRepository->getAccountCurrency($source) ?? $defaultCurrency;
|
$sourceCurrency = $accountRepository->getAccountCurrency($source) ?? $primaryCurrency;
|
||||||
$destinationCurrency = $accountRepository->getAccountCurrency($destination) ?? $defaultCurrency;
|
$destinationCurrency = $accountRepository->getAccountCurrency($destination) ?? $primaryCurrency;
|
||||||
// if both accounts have the same currency, continue.
|
// if both accounts have the same currency, continue.
|
||||||
if ($sourceCurrency->code === $destinationCurrency->code) {
|
if ($sourceCurrency->code === $destinationCurrency->code) {
|
||||||
Log::debug('Both accounts have the same currency, continue.');
|
Log::debug('Both accounts have the same currency, continue.');
|
||||||
|
Reference in New Issue
Block a user