Skip to content

Firefly III: a personal finances manager

Rename default to primary

Sander Dorigo87567d5a310e
diff --git a/app/Console/Commands/Correction/CorrectsCurrencies.php b/app/Console/Commands/Correction/CorrectsCurrencies.php
index f62314179e..1ded27400b 100644
--- a/app/Console/Commands/Correction/CorrectsCurrencies.php
+++ b/app/Console/Commands/Correction/CorrectsCurrencies.php
@@ -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')
diff --git a/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php b/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php
index 3c4e62003f..eef26f8608 100644
--- a/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php
+++ b/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php
@@ -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);
}
}
diff --git a/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php b/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php
index 05c2a48583..56b1a5ee0c 100644
--- a/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php
+++ b/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php
@@ -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
diff --git a/app/Events/Preferences/UserGroupChangedDefaultCurrency.php b/app/Events/Preferences/UserGroupChangedDefaultCurrency.php
index 5eb709b3e2..f39b72b2fc 100644
--- a/app/Events/Preferences/UserGroupChangedDefaultCurrency.php
+++ b/app/Events/Preferences/UserGroupChangedDefaultCurrency.php
@@ -1,7 +1,7 @@
<?php
/*
- * UserGroupChangedDefaultCurrency.php
+ * UserGroupChangedPrimaryCurrency.php
* Copyright (c) 2024 [email protected].
*
* 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\Support\Facades\Log;
-class UserGroupChangedDefaultCurrency extends Event
+class UserGroupChangedPrimaryCurrency extends Event
{
use SerializesModels;
diff --git a/app/Factory/PiggyBankFactory.php b/app/Factory/PiggyBankFactory.php
index 933f870d0b..539e1999b8 100644
--- a/app/Factory/PiggyBankFactory.php
+++ b/app/Factory/PiggyBankFactory.php
@@ -126,7 +126,7 @@ class PiggyBankFactory
private function getCurrency(array $data): TransactionCurrency
{
// currency:
- $defaultCurrency = app('amount')->getPrimaryCurrency();
+ $primaryCurrency = app('amount')->getPrimaryCurrency();
$currency = null;
if (array_key_exists('transaction_currency_code', $data)) {
$currency = $this->currencyRepository->findByCode((string)($data['transaction_currency_code'] ?? ''));
@@ -134,7 +134,7 @@ class PiggyBankFactory
if (array_key_exists('transaction_currency_id', $data)) {
$currency = $this->currencyRepository->find((int)($data['transaction_currency_id'] ?? 0));
}
- $currency ??= $defaultCurrency;
+ $currency ??= $primaryCurrency;
return $currency;
}
diff --git a/app/Generator/Report/Audit/MonthReportGenerator.php b/app/Generator/Report/Audit/MonthReportGenerator.php
index b54e1c9042..bc02d217a8 100644
--- a/app/Generator/Report/Audit/MonthReportGenerator.php
+++ b/app/Generator/Report/Audit/MonthReportGenerator.php
@@ -141,8 +141,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
Log::debug(sprintf('getAuditReport: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
$dayBeforeBalance = Steam::finalAccountBalance($account, $date);
$startBalance = $dayBeforeBalance['balance'];
- $defaultCurrency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
- $currency = $accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
+ $primaryCurrency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
+ $currency = $accountRepository->getAccountCurrency($account) ?? $primaryCurrency;
foreach ($journals as $index => $journal) {
$journals[$index]['balance_before'] = $startBalance;
diff --git a/app/Handlers/Events/PreferencesEventHandler.php b/app/Handlers/Events/PreferencesEventHandler.php
index 6296d07437..c510844e45 100644
--- a/app/Handlers/Events/PreferencesEventHandler.php
+++ b/app/Handlers/Events/PreferencesEventHandler.php
@@ -24,7 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Events;
-use FireflyIII\Events\Preferences\UserGroupChangedDefaultCurrency;
+use FireflyIII\Events\Preferences\UserGroupChangedPrimaryCurrency;
use FireflyIII\Models\Budget;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\UserGroup;
@@ -38,7 +38,7 @@ use Illuminate\Support\Facades\Log;
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.
Log::debug('Resetting primary currency amounts for all objects.');
diff --git a/app/Http/Controllers/Bill/CreateController.php b/app/Http/Controllers/Bill/CreateController.php
index 4bc0536a31..401ead7c6d 100644
--- a/app/Http/Controllers/Bill/CreateController.php
+++ b/app/Http/Controllers/Bill/CreateController.php
@@ -77,7 +77,7 @@ class CreateController extends Controller
$periods[$current] = (string) trans('firefly.repeat_freq_'.$current);
}
$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").
if (true !== session('bills.create.fromStore')) {
@@ -85,7 +85,7 @@ class CreateController extends Controller
}
$request->session()->forget('bills.create.fromStore');
- return view('bills.create', compact('periods', 'subTitle', 'defaultCurrency'));
+ return view('bills.create', compact('periods', 'subTitle', 'primaryCurrency'));
}
/**
diff --git a/app/Http/Controllers/Bill/EditController.php b/app/Http/Controllers/Bill/EditController.php
index e744444798..de520dfc7f 100644
--- a/app/Http/Controllers/Bill/EditController.php
+++ b/app/Http/Controllers/Bill/EditController.php
@@ -88,7 +88,7 @@ class EditController extends Controller
$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);
$rules = $this->repository->getRulesForBill($bill);
- $defaultCurrency = $this->primaryCurrency;
+ $primaryCurrency = $this->primaryCurrency;
// code to handle active-checkboxes
$hasOldInput = null !== $request->old('_token');
@@ -105,7 +105,7 @@ class EditController extends Controller
$request->session()->flash('preFilled', $preFilled);
$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'));
}
/**
diff --git a/app/Http/Controllers/Bill/IndexController.php b/app/Http/Controllers/Bill/IndexController.php
index 605b355b69..b47886e648 100644
--- a/app/Http/Controllers/Bill/IndexController.php
+++ b/app/Http/Controllers/Bill/IndexController.php
@@ -101,7 +101,7 @@ class IndexController extends Controller
$parameters->set('start', $tempStart);
$parameters->set('end', $end);
$parameters->set('convertToPrimary', $this->convertToPrimary);
- $parameters->set('defaultCurrency', $this->primaryCurrency);
+ $parameters->set('primaryCurrency', $this->primaryCurrency);
/** @var BillTransformer $transformer */
$transformer = app(BillTransformer::class);
diff --git a/app/Http/Controllers/Budget/IndexController.php b/app/Http/Controllers/Budget/IndexController.php
index 2d87ccd176..a370bbd00f 100644
--- a/app/Http/Controllers/Budget/IndexController.php
+++ b/app/Http/Controllers/Budget/IndexController.php
@@ -136,7 +136,7 @@ class IndexController extends Controller
// get all inactive budgets, and simply list them:
$inactive = $this->repository->getInactiveBudgets();
- $defaultCurrency = $this->primaryCurrency;
+ $primaryCurrency = $this->primaryCurrency;
return view(
'budgets.index',
@@ -149,7 +149,7 @@ class IndexController extends Controller
'budgets',
'currencies',
'periodTitle',
- 'defaultCurrency',
+ 'primaryCurrency',
'activeDaysPassed',
'activeDaysLeft',
'inactive',
@@ -194,7 +194,7 @@ class IndexController extends Controller
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.
$collection = $this->repository->getActiveBudgets();
@@ -216,7 +216,7 @@ class IndexController extends Controller
/** @var BudgetLimit $limit */
foreach ($budgetLimits as $limit) {
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);
$array['budgeted'][] = [
'id' => $limit->id,
diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php
index f69cb2c9fb..dbf91fb2ad 100644
--- a/app/Http/Controllers/PreferencesController.php
+++ b/app/Http/Controllers/PreferencesController.php
@@ -26,7 +26,7 @@ namespace FireflyIII\Http\Controllers;
use JsonException;
use Carbon\Carbon;
use FireflyIII\Enums\AccountTypeEnum;
-use FireflyIII\Events\Preferences\UserGroupChangedDefaultCurrency;
+use FireflyIII\Events\Preferences\UserGroupChangedPrimaryCurrency;
use FireflyIII\Events\Test\UserTestNotificationChannel;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Requests\PreferencesRequest;
@@ -271,7 +271,7 @@ class PreferencesController extends Controller
// set to true!
Log::debug('User sets convertToPrimary to true.');
Preferences::set('convert_to_primary', $convertToPrimary);
- event(new UserGroupChangedDefaultCurrency(auth()->user()->userGroup));
+ event(new UserGroupChangedPrimaryCurrency(auth()->user()->userGroup));
}
Preferences::set('convert_to_primary', $convertToPrimary);
diff --git a/app/Http/Controllers/Recurring/CreateController.php b/app/Http/Controllers/Recurring/CreateController.php
index 9e2c70e99b..f2b5bd599c 100644
--- a/app/Http/Controllers/Recurring/CreateController.php
+++ b/app/Http/Controllers/Recurring/CreateController.php
@@ -84,7 +84,7 @@ class CreateController extends Controller
{
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
$bills = app('expandedform')->makeSelectListWithEmpty($this->billRepository->getActiveBills());
- $defaultCurrency = $this->primaryCurrency;
+ $primaryCurrency = $this->primaryCurrency;
$tomorrow = today(config('app.timezone'));
$oldRepetitionType = $request->old('repetition_type');
$tomorrow->addDay();
@@ -116,7 +116,7 @@ class CreateController extends Controller
return view(
'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());
$bills = app('expandedform')->makeSelectListWithEmpty($this->billRepository->getActiveBills());
- $defaultCurrency = $this->primaryCurrency;
+ $primaryCurrency = $this->primaryCurrency;
$tomorrow = today(config('app.timezone'));
$oldRepetitionType = $request->old('repetition_type');
$tomorrow->addDay();
@@ -210,7 +210,7 @@ class CreateController extends Controller
return view(
'recurring.create',
- compact('tomorrow', 'oldRepetitionType', 'bills', 'weekendResponses', 'preFilled', 'repetitionEnds', 'defaultCurrency', 'budgets')
+ compact('tomorrow', 'oldRepetitionType', 'bills', 'weekendResponses', 'preFilled', 'repetitionEnds', 'primaryCurrency', 'budgets')
);
}
diff --git a/app/Http/Controllers/Transaction/CreateController.php b/app/Http/Controllers/Transaction/CreateController.php
index 6eab9a121c..d8e6092837 100644
--- a/app/Http/Controllers/Transaction/CreateController.php
+++ b/app/Http/Controllers/Transaction/CreateController.php
@@ -117,7 +117,7 @@ class CreateController extends Controller
$optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
$allowedOpposingTypes = config('firefly.allowed_opposing_types');
$accountToTypes = config('firefly.account_to_transaction');
- $defaultCurrency = $this->primaryCurrency;
+ $primaryCurrency = $this->primaryCurrency;
$previousUrl = $this->rememberPreviousUrl('transactions.create.url');
$parts = parse_url((string) $previousUrl);
$search = sprintf('?%s', $parts['query'] ?? '');
@@ -156,7 +156,7 @@ class CreateController extends Controller
'objectType',
'optionalDateFields',
'subTitle',
- 'defaultCurrency',
+ 'primaryCurrency',
'previousUrl',
'optionalFields',
'preFilled',
diff --git a/app/Http/Controllers/Transaction/EditController.php b/app/Http/Controllers/Transaction/EditController.php
index 14b1614ee0..507cc0cc34 100644
--- a/app/Http/Controllers/Transaction/EditController.php
+++ b/app/Http/Controllers/Transaction/EditController.php
@@ -84,7 +84,7 @@ class EditController extends Controller
$title = $transactionGroup->transactionJournals()->count() > 1 ? $transactionGroup->title : $transactionGroup->transactionJournals()->first()->description;
$subTitle = (string) trans('firefly.edit_transaction_title', ['description' => $title]);
$subTitleIcon = 'fa-plus';
- $defaultCurrency = $this->primaryCurrency;
+ $primaryCurrency = $this->primaryCurrency;
$cash = $repository->getCashAccount();
$previousUrl = $this->rememberPreviousUrl('transactions.edit.url');
$parts = parse_url((string) $previousUrl);
@@ -130,7 +130,7 @@ class EditController extends Controller
'transactionGroup',
'allowedOpposingTypes',
'accountToTypes',
- 'defaultCurrency',
+ 'primaryCurrency',
'previousUrl'
)
);
diff --git a/app/Http/Middleware/Range.php b/app/Http/Middleware/Range.php
index 31933b924a..3390515840 100644
--- a/app/Http/Middleware/Range.php
+++ b/app/Http/Middleware/Range.php
@@ -120,7 +120,7 @@ class Range
// save some formats:
$monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);
$dateTimeFormat = (string) trans('config.date_time_js', [], $locale);
- $defaultCurrency = Amount::getPrimaryCurrency();
+ $primaryCurrency = Amount::getPrimaryCurrency();
// also format for moment JS:
$madMomentJS = (string) trans('config.month_and_day_moment_js', [], $locale);
@@ -128,7 +128,7 @@ class Range
app('view')->share('madMomentJS', $madMomentJS);
app('view')->share('monthAndDayFormat', $monthAndDayFormat);
app('view')->share('dateTimeFormat', $dateTimeFormat);
- app('view')->share('defaultCurrency', $defaultCurrency);
+ app('view')->share('primaryCurrency', $primaryCurrency);
}
/**
diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php
index 4a78b01823..09ec135daa 100644
--- a/app/Providers/EventServiceProvider.php
+++ b/app/Providers/EventServiceProvider.php
@@ -35,7 +35,7 @@ use FireflyIII\Events\Model\PiggyBank\ChangedName;
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
use FireflyIII\Events\Model\Rule\RuleActionFailedOnObject;
use FireflyIII\Events\NewVersionAvailable;
-use FireflyIII\Events\Preferences\UserGroupChangedDefaultCurrency;
+use FireflyIII\Events\Preferences\UserGroupChangedPrimaryCurrency;
use FireflyIII\Events\RegisteredUser;
use FireflyIII\Events\RequestedNewPassword;
use FireflyIII\Events\RequestedReportOnJournals;
@@ -257,7 +257,7 @@ class EventServiceProvider extends ServiceProvider
'FireflyIII\Handlers\Events\Security\MFAHandler@sendMFAFailedAttemptsMail',
],
// preferences
- UserGroupChangedDefaultCurrency::class => [
+ UserGroupChangedPrimaryCurrency::class => [
'FireflyIII\Handlers\Events\PreferencesEventHandler@resetPrimaryCurrencyAmounts',
],
];
diff --git a/app/Repositories/Currency/CurrencyRepository.php b/app/Repositories/Currency/CurrencyRepository.php
index d448a21816..3acdfc5593 100644
--- a/app/Repositories/Currency/CurrencyRepository.php
+++ b/app/Repositories/Currency/CurrencyRepository.php
@@ -24,7 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Currency;
use Carbon\Carbon;
-use FireflyIII\Events\Preferences\UserGroupChangedDefaultCurrency;
+use FireflyIII\Events\Preferences\UserGroupChangedPrimaryCurrency;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Factory\TransactionCurrencyFactory;
use FireflyIII\Models\AccountMeta;
@@ -438,7 +438,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
if ($current->id !== $currency->id) {
Log::debug('Trigger on a different default currency.');
// clear all primary currency amounts through an event.
- event(new UserGroupChangedDefaultCurrency($this->userGroup));
+ event(new UserGroupChangedPrimaryCurrency($this->userGroup));
}
}
}
diff --git a/app/Repositories/UserGroups/Currency/CurrencyRepository.php b/app/Repositories/UserGroups/Currency/CurrencyRepository.php
index 5dad9eb1f8..409ebeef5d 100644
--- a/app/Repositories/UserGroups/Currency/CurrencyRepository.php
+++ b/app/Repositories/UserGroups/Currency/CurrencyRepository.php
@@ -24,7 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\UserGroups\Currency;
-use FireflyIII\Events\Preferences\UserGroupChangedDefaultCurrency;
+use FireflyIII\Events\Preferences\UserGroupChangedPrimaryCurrency;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Factory\TransactionCurrencyFactory;
use FireflyIII\Models\AccountMeta;
@@ -386,7 +386,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
if ($current->id !== $currency->id) {
Log::debug('Trigger on a different default currency.');
// clear all primary currency amounts through an event.
- event(new UserGroupChangedDefaultCurrency($this->userGroup));
+ event(new UserGroupChangedPrimaryCurrency($this->userGroup));
}
}
}
diff --git a/app/Support/Chart/Category/FrontpageChartGenerator.php b/app/Support/Chart/Category/FrontpageChartGenerator.php
index f9eeaa4c2b..dd10fd018e 100644
--- a/app/Support/Chart/Category/FrontpageChartGenerator.php
+++ b/app/Support/Chart/Category/FrontpageChartGenerator.php
@@ -44,7 +44,7 @@ class FrontpageChartGenerator
use AugumentData;
public bool $convertToPrimary = false;
- public TransactionCurrency $defaultCurrency;
+ public TransactionCurrency $primaryCurrency;
private AccountRepositoryInterface $accountRepos;
private array $currencies;
private NoCategoryRepositoryInterface $noCatRepos;
diff --git a/app/Support/Form/CurrencyForm.php b/app/Support/Form/CurrencyForm.php
index c947e7b192..88816667d4 100644
--- a/app/Support/Form/CurrencyForm.php
+++ b/app/Support/Form/CurrencyForm.php
@@ -61,7 +61,7 @@ class CurrencyForm
$classes = $this->getHolderClasses($name);
$value = $this->fillFieldValue($name, $value);
$options['step'] = 'any';
- $defaultCurrency = $options['currency'] ?? app('amount')->getPrimaryCurrency();
+ $primaryCurrency = $options['currency'] ?? app('amount')->getPrimaryCurrency();
/** @var Collection $currencies */
$currencies = app('amount')->getCurrencies();
@@ -72,15 +72,15 @@ class CurrencyForm
$preFilled = [];
}
$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));
// find this currency in set of currencies:
foreach ($currencies as $currency) {
if ($currency->id === $sentCurrencyId) {
- $defaultCurrency = $currency;
- app('log')->debug(sprintf('default currency is now %s', $defaultCurrency->code));
+ $primaryCurrency = $currency;
+ app('log')->debug(sprintf('default currency is now %s', $primaryCurrency->code));
break;
}
@@ -88,11 +88,11 @@ class CurrencyForm
// make sure value is formatted nicely:
if (null !== $value && '' !== $value) {
- $value = app('steam')->bcround($value, $defaultCurrency->decimal_places);
+ $value = app('steam')->bcround($value, $primaryCurrency->decimal_places);
}
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) {
app('log')->debug(sprintf('Could not render currencyField(): %s', $e->getMessage()));
$html = 'Could not render currencyField.';
@@ -129,7 +129,7 @@ class CurrencyForm
$classes = $this->getHolderClasses($name);
$value = $this->fillFieldValue($name, $value);
$options['step'] = 'any';
- $defaultCurrency = $options['currency'] ?? app('amount')->getPrimaryCurrency();
+ $primaryCurrency = $options['currency'] ?? app('amount')->getPrimaryCurrency();
/** @var Collection $currencies */
$currencies = app('amount')->getAllCurrencies();
@@ -141,15 +141,15 @@ class CurrencyForm
$preFilled = [];
}
$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));
// find this currency in set of currencies:
foreach ($currencies as $currency) {
if ($currency->id === $sentCurrencyId) {
- $defaultCurrency = $currency;
- app('log')->debug(sprintf('default currency is now %s', $defaultCurrency->code));
+ $primaryCurrency = $currency;
+ app('log')->debug(sprintf('default currency is now %s', $primaryCurrency->code));
break;
}
@@ -157,11 +157,11 @@ class CurrencyForm
// make sure value is formatted nicely:
if (null !== $value && '' !== $value) {
- $value = app('steam')->bcround($value, $defaultCurrency->decimal_places);
+ $value = app('steam')->bcround($value, $primaryCurrency->decimal_places);
}
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) {
app('log')->debug(sprintf('Could not render currencyField(): %s', $e->getMessage()));
$html = 'Could not render currencyField.';
diff --git a/app/Support/Http/Controllers/AugumentData.php b/app/Support/Http/Controllers/AugumentData.php
index 5159fe0210..a95a1e6ff2 100644
--- a/app/Support/Http/Controllers/AugumentData.php
+++ b/app/Support/Http/Controllers/AugumentData.php
@@ -202,7 +202,7 @@ trait AugumentData
$currency = $entry->transactionCurrency;
if ($this->convertToPrimary) {
// the sumExpenses method already handles this.
- $currency = $this->defaultCurrency;
+ $currency = $this->primaryCurrency;
}
// clone because these objects change each other.
diff --git a/app/Support/Steam.php b/app/Support/Steam.php
index fc946ade57..53f78888ce 100644
--- a/app/Support/Steam.php
+++ b/app/Support/Steam.php
@@ -113,7 +113,7 @@ class Steam
if (!$convertToPrimary) {
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';
unset($set[$primaryCurrency->code]);
}
diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.php
index 5352c0e9c1..82f9cbdb0d 100644
--- a/app/Validation/TransactionValidation.php
+++ b/app/Validation/TransactionValidation.php
@@ -224,9 +224,9 @@ trait TransactionValidation
/** @var AccountRepository $accountRepository */
$accountRepository = app(AccountRepositoryInterface::class);
- $defaultCurrency = app('amount')->getPrimaryCurrency();
- $sourceCurrency = $accountRepository->getAccountCurrency($source) ?? $defaultCurrency;
- $destinationCurrency = $accountRepository->getAccountCurrency($destination) ?? $defaultCurrency;
+ $primaryCurrency = app('amount')->getPrimaryCurrency();
+ $sourceCurrency = $accountRepository->getAccountCurrency($source) ?? $primaryCurrency;
+ $destinationCurrency = $accountRepository->getAccountCurrency($destination) ?? $primaryCurrency;
// if both accounts have the same currency, continue.
if ($sourceCurrency->code === $destinationCurrency->code) {
Log::debug('Both accounts have the same currency, continue.');