Merge branch 'develop' of https://github.com/firefly-iii/firefly-iii into develop

This commit is contained in:
Sander Dorigo
2025-08-01 07:41:28 +02:00
213 changed files with 1072 additions and 9270 deletions

View File

@@ -86,7 +86,7 @@ class CorrectsAmounts extends Command
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
$repository->setUser($journal->user);
$native = Amount::getNativeCurrencyByUserGroup($journal->userGroup);
$primary = Amount::getPrimaryCurrencyByUserGroup($journal->userGroup);
/** @var null|Transaction $source */
$source = $journal->transactions()->where('amount', '<', 0)->first();
@@ -104,8 +104,8 @@ class CorrectsAmounts extends Command
if (null === $sourceAccount || null === $destAccount) {
continue;
}
$sourceCurrency = $repository->getAccountCurrency($sourceAccount) ?? $native;
$destCurrency = $repository->getAccountCurrency($destAccount) ?? $native;
$sourceCurrency = $repository->getAccountCurrency($sourceAccount) ?? $primary;
$destCurrency = $repository->getAccountCurrency($destAccount) ?? $primary;
if ($sourceCurrency->id === $destCurrency->id) {
Log::debug('Both accounts have the same currency. Removing foreign currency info.');

View File

@@ -63,7 +63,7 @@ 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')->getNativeCurrencyByUserGroup($userGroup);
$defaultCurrency = app('amount')->getPrimaryCurrencyByUserGroup($userGroup);
Log::debug(sprintf('Now correcting currencies for user group #%d', $userGroup->id));
$found = [$defaultCurrency->id];

View File

@@ -75,7 +75,7 @@ class CorrectsDatabase extends Command
'correction:recalculates-liabilities',
'correction:preferences',
// 'correction:transaction-types', // resource heavy, disabled.
'correction:recalculate-native-amounts', // not necessary, disabled.
'correction:recalculate-pc-amounts', // not necessary, disabled.
'firefly-iii:report-integrity',
];
foreach ($commands as $command) {

View File

@@ -132,6 +132,6 @@ class CorrectsOpeningBalanceCurrencies extends Command
$repos = app(AccountRepositoryInterface::class);
$repos->setUser($account->user);
return $repos->getAccountCurrency($account) ?? app('amount')->getNativeCurrencyByUserGroup($account->userGroup);
return $repos->getAccountCurrency($account) ?? app('amount')->getPrimaryCurrencyByUserGroup($account->userGroup);
}
}

View File

@@ -2,7 +2,7 @@
/*
* CorrectsNativeAmounts.php
* CorrectsPrimaryCurrencyAmounts.php
* Copyright (c) 2025 james@firefly-iii.org.
*
* This file is part of Firefly III (https://github.com/firefly-iii).
@@ -48,13 +48,13 @@ use Illuminate\Database\Query\Builder as DatabaseBuilder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class CorrectsNativeAmounts extends Command
class CorrectsPrimaryCurrencyAmounts extends Command
{
use ShowsFriendlyMessages;
protected $description = 'Recalculate native amounts for all objects.';
protected $description = 'Recalculate primary currency amounts for all objects.';
protected $signature = 'correction:recalculate-native-amounts';
protected $signature = 'correction:recalculate-pc-amounts';
/**
* Execute the console command.
@@ -66,8 +66,8 @@ class CorrectsNativeAmounts extends Command
return 0;
}
Log::debug('Will update all native amounts. This may take some time.');
$this->friendlyWarning('Recalculating native amounts for all objects. This may take some time!');
Log::debug('Will update all primary currency amounts. This may take some time.');
$this->friendlyWarning('Recalculating primary currency amounts for all objects. This may take some time!');
/** @var UserGroupRepositoryInterface $repository */
$repository = app(UserGroupRepositoryInterface::class);
@@ -76,7 +76,7 @@ class CorrectsNativeAmounts extends Command
foreach ($repository->getAll() as $userGroup) {
$this->recalculateForGroup($userGroup);
}
$this->friendlyInfo('Recalculated all native amounts.');
$this->friendlyInfo('Recalculated all primary currency amounts.');
return 0;
}
@@ -88,7 +88,7 @@ class CorrectsNativeAmounts extends Command
// do a check with the group's currency so we can skip some stuff.
Preferences::mark();
$currency = app('amount')->getNativeCurrencyByUserGroup($userGroup);
$currency = app('amount')->getPrimaryCurrencyByUserGroup($userGroup);
$this->recalculatePiggyBanks($userGroup, $currency);
$this->recalculateBudgets($userGroup, $currency);

View File

@@ -108,7 +108,7 @@ class UpgradesAccountCurrencies extends Command
$accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value]);
// get user's currency preference:
$defaultCurrency = app('amount')->getNativeCurrencyByUserGroup($user->userGroup);
$defaultCurrency = app('amount')->getPrimaryCurrencyByUserGroup($user->userGroup);
/** @var Account $account */
foreach ($accounts as $account) {

View File

@@ -66,7 +66,7 @@ class UpgradesBudgetLimits extends Command
/** @var null|User $user */
$user = $budget->user;
if (null !== $user) {
$currency = app('amount')->getNativeCurrencyByUserGroup($user->userGroup);
$currency = app('amount')->getPrimaryCurrencyByUserGroup($user->userGroup);
$budgetLimit->transaction_currency_id = $currency->id;
$budgetLimit->save();
$this->friendlyInfo(

View File

@@ -74,7 +74,7 @@ class UpgradesDatabase extends Command
'upgrade:610-currency-preferences',
'upgrade:610-currency-preferences',
'upgrade:620-piggy-banks',
'upgrade:620-native-amounts',
'upgrade:620-pc-amounts',
'firefly-iii:correct-database',
];
$args = [];

View File

@@ -96,7 +96,7 @@ class UpgradesMultiPiggyBanks extends Command
$this->repository->setUser($piggyBank->account->user);
$this->accountRepository->setUser($piggyBank->account->user);
$repetition = $this->repository->getRepetition($piggyBank, true);
$currency = $this->accountRepository->getAccountCurrency($piggyBank->account) ?? app('amount')->getNativeCurrencyByUserGroup($piggyBank->account->user->userGroup);
$currency = $this->accountRepository->getAccountCurrency($piggyBank->account) ?? app('amount')->getPrimaryCurrencyByUserGroup($piggyBank->account->user->userGroup);
// update piggy bank to have a currency.
$piggyBank->transaction_currency_id = $currency->id;

View File

@@ -2,7 +2,7 @@
/*
* UpgradesNativeAmounts.php
* UpgradesPrimaryCurrencyAmounts.php
* Copyright (c) 2025 james@firefly-iii.org.
*
* This file is part of Firefly III (https://github.com/firefly-iii).
@@ -29,15 +29,15 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
class UpgradesNativeAmounts extends Command
class UpgradesPrimaryCurrencyAmounts extends Command
{
use ShowsFriendlyMessages;
public const string CONFIG_NAME = '620_native_amounts';
public const string CONFIG_NAME = '620_pc_amounts';
protected $description = 'Runs the native amounts calculations.';
protected $description = 'Runs the primary currency amounts calculations.';
protected $signature = 'upgrade:620-native-amounts {--F|force : Force the execution of this command.}';
protected $signature = 'upgrade:620-pc-amounts {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -50,7 +50,7 @@ class UpgradesNativeAmounts extends Command
return 0;
}
Artisan::call('correction:recalculate-native-amounts');
Artisan::call('correction:recalculate-pc-amounts');
$this->markAsExecuted();