Skip to content

Firefly III: a personal finances manager

🤖 Auto commit for release 'develop' on 2025-12-19

JC5476a9ac6e4b6
diff --git a/.ci/php-cs-fixer/composer.lock b/.ci/php-cs-fixer/composer.lock
index a96ebd6740..882c19b221 100644
--- a/.ci/php-cs-fixer/composer.lock
+++ b/.ci/php-cs-fixer/composer.lock
@@ -402,16 +402,16 @@
},
{
"name": "friendsofphp/php-cs-fixer",
- "version": "v3.92.2",
+ "version": "v3.92.3",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
- "reference": "64fab3553dce507ce247f7d1a7d65f74ef658c3f"
+ "reference": "2ba8f5a60f6f42fb65758cfb3768434fa2d1c7e8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/64fab3553dce507ce247f7d1a7d65f74ef658c3f",
- "reference": "64fab3553dce507ce247f7d1a7d65f74ef658c3f",
+ "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/2ba8f5a60f6f42fb65758cfb3768434fa2d1c7e8",
+ "reference": "2ba8f5a60f6f42fb65758cfb3768434fa2d1c7e8",
"shasum": ""
},
"require": {
@@ -494,7 +494,7 @@
],
"support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
- "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.92.2"
+ "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.92.3"
},
"funding": [
{
@@ -502,7 +502,7 @@
"type": "github"
}
],
- "time": "2025-12-17T00:04:16+00:00"
+ "time": "2025-12-18T10:45:02+00:00"
},
{
"name": "psr/container",
diff --git a/app/Console/Commands/Correction/CorrectsAmounts.php b/app/Console/Commands/Correction/CorrectsAmounts.php
index b140344b17..785df6803e 100644
--- a/app/Console/Commands/Correction/CorrectsAmounts.php
+++ b/app/Console/Commands/Correction/CorrectsAmounts.php
@@ -100,7 +100,7 @@ class CorrectsAmounts extends Command
if (null === $source->foreign_currency_id || null === $destination->foreign_currency_id) {
continue;
}
- if(null === $source->foreign_amount || null === $destination->foreign_amount) {
+ if (null === $source->foreign_amount || null === $destination->foreign_amount) {
continue;
}
diff --git a/app/Console/Commands/Upgrade/RemovesDatabaseDecryption.php b/app/Console/Commands/Upgrade/RemovesDatabaseDecryption.php
index 6ef235f0be..e1451c94a5 100644
--- a/app/Console/Commands/Upgrade/RemovesDatabaseDecryption.php
+++ b/app/Console/Commands/Upgrade/RemovesDatabaseDecryption.php
@@ -34,6 +34,7 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use JsonException;
use stdClass;
+
use function Safe\json_decode;
class RemovesDatabaseDecryption extends Command
@@ -119,8 +120,8 @@ class RemovesDatabaseDecryption extends Command
if (null === $original) {
return;
}
- $id = (int)$row->id;
- $value = '';
+ $id = (int)$row->id;
+ $value = '';
try {
$value = $this->tryDecrypt($original);
diff --git a/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.php b/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.php
index 6fa32bbfa8..fc986e5260 100644
--- a/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.php
+++ b/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.php
@@ -42,8 +42,8 @@ class UpgradesLiabilitiesEight extends Command
use ShowsFriendlyMessages;
public const string CONFIG_NAME = '600_upgrade_liabilities';
- protected $description = 'Upgrade liabilities to new 6.0.0 structure.';
- protected $signature = 'upgrade:600-liabilities {--F|force : Force the execution of this command.}';
+ protected $description = 'Upgrade liabilities to new 6.0.0 structure.';
+ protected $signature = 'upgrade:600-liabilities {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -82,9 +82,10 @@ class UpgradesLiabilitiesEight extends Command
private function upgradeForUser(User $user): void
{
$accounts = $user->accounts()
- ->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
- ->whereIn('account_types.type', config('firefly.valid_liabilities'))
- ->get(['accounts.*']);
+ ->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
+ ->whereIn('account_types.type', config('firefly.valid_liabilities'))
+ ->get(['accounts.*'])
+ ;
/** @var Account $account */
foreach ($accounts as $account) {
@@ -101,7 +102,7 @@ class UpgradesLiabilitiesEight extends Command
$repository = app(AccountRepositoryInterface::class);
$repository->setUser($account->user);
- $direction = $repository->getMetaValue($account, 'liability_direction');
+ $direction = $repository->getMetaValue($account, 'liability_direction');
if ('credit' === $direction && $this->hasBadOpening($account)) {
$this->deleteCreditTransaction($account);
$this->reverseOpeningBalance($account);
@@ -120,16 +121,18 @@ class UpgradesLiabilitiesEight extends Command
$openingBalanceType = TransactionType::whereType(TransactionTypeEnum::OPENING_BALANCE->value)->first();
$liabilityType = TransactionType::whereType(TransactionTypeEnum::LIABILITY_CREDIT->value)->first();
$openingJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
- ->where('transactions.account_id', $account->id)
- ->where('transaction_journals.transaction_type_id', $openingBalanceType->id)
- ->first(['transaction_journals.*']);
+ ->where('transactions.account_id', $account->id)
+ ->where('transaction_journals.transaction_type_id', $openingBalanceType->id)
+ ->first(['transaction_journals.*'])
+ ;
if (null === $openingJournal) {
return false;
}
- $liabilityJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
- ->where('transactions.account_id', $account->id)
- ->where('transaction_journals.transaction_type_id', $liabilityType->id)
- ->first(['transaction_journals.*']);
+ $liabilityJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
+ ->where('transactions.account_id', $account->id)
+ ->where('transaction_journals.transaction_type_id', $liabilityType->id)
+ ->first(['transaction_journals.*'])
+ ;
if (null === $liabilityJournal) {
return false;
}
@@ -141,9 +144,10 @@ class UpgradesLiabilitiesEight extends Command
{
$liabilityType = TransactionType::whereType(TransactionTypeEnum::LIABILITY_CREDIT->value)->first();
$liabilityJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
- ->where('transactions.account_id', $account->id)
- ->where('transaction_journals.transaction_type_id', $liabilityType->id)
- ->first(['transaction_journals.*']);
+ ->where('transactions.account_id', $account->id)
+ ->where('transaction_journals.transaction_type_id', $liabilityType->id)
+ ->first(['transaction_journals.*'])
+ ;
if (null !== $liabilityJournal && null !== $liabilityJournal->transactionGroup) {
$group = $liabilityJournal->transactionGroup;
$service = new TransactionGroupDestroyService();
@@ -157,16 +161,17 @@ class UpgradesLiabilitiesEight extends Command
$openingBalanceType = TransactionType::whereType(TransactionTypeEnum::OPENING_BALANCE->value)->first();
/** @var TransactionJournal $openingJournal */
- $openingJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
- ->where('transactions.account_id', $account->id)
- ->where('transaction_journals.transaction_type_id', $openingBalanceType->id)
- ->first(['transaction_journals.*']);
+ $openingJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
+ ->where('transactions.account_id', $account->id)
+ ->where('transaction_journals.transaction_type_id', $openingBalanceType->id)
+ ->first(['transaction_journals.*'])
+ ;
/** @var null|Transaction $source */
- $source = $openingJournal->transactions()->where('amount', '<', 0)->first();
+ $source = $openingJournal->transactions()->where('amount', '<', 0)->first();
/** @var null|Transaction $dest */
- $dest = $openingJournal->transactions()->where('amount', '>', 0)->first();
+ $dest = $openingJournal->transactions()->where('amount', '>', 0)->first();
if (null !== $source && null !== $dest) {
$sourceId = $source->account_id;
$destId = $dest->account_id;
@@ -184,9 +189,10 @@ class UpgradesLiabilitiesEight extends Command
{
$count = 0;
$journals = TransactionJournal::leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
- ->where('transactions.account_id', $account->id)->get(['transaction_journals.*']);
+ ->where('transactions.account_id', $account->id)->get(['transaction_journals.*'])
+ ;
- $service = app(TransactionGroupDestroyService::class);
+ $service = app(TransactionGroupDestroyService::class);
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php
index a4276e461b..59c02428e1 100644
--- a/app/Http/Controllers/Auth/LoginController.php
+++ b/app/Http/Controllers/Auth/LoginController.php
@@ -69,7 +69,7 @@ class LoginController extends Controller
protected string $redirectTo = RouteServiceProvider::HOME;
private UserRepositoryInterface $repository;
- private string $username = 'email';
+ private string $username = 'email';
/**
* Create a new controller instance.
@@ -86,7 +86,7 @@ class LoginController extends Controller
*
* @throws ValidationException
*/
- public function login(Request $request): JsonResponse | RedirectResponse
+ public function login(Request $request): JsonResponse|RedirectResponse
{
$username = $request->get($this->username());
Log::channel('audit')->info(sprintf('User is trying to login using "%s"', $username));
@@ -104,7 +104,8 @@ class LoginController extends Controller
$this->username => trans('auth.failed'),
]
)
- ->onlyInput($this->username);
+ ->onlyInput($this->username)
+ ;
}
Log::debug('Login data is present.');
@@ -128,6 +129,7 @@ class LoginController extends Controller
// send a custom login event because laravel will also fire a login event if a "remember me"-cookie
// restores the event.
event(new ActuallyLoggedIn($this->guard()->user()));
+
return $this->sendLoginResponse($request);
}
Log::warning('Login attempt failed.');
@@ -184,10 +186,10 @@ class LoginController extends Controller
/**
* Log the user out of the application.
*/
- public function logout(Request $request): Redirector | RedirectResponse | Response
+ public function logout(Request $request): Redirector|RedirectResponse|Response
{
- $authGuard = config('firefly.authentication_guard');
- $logoutUrl = config('firefly.custom_logout_url');
+ $authGuard = config('firefly.authentication_guard');
+ $logoutUrl = config('firefly.custom_logout_url');
if ('remote_user_guard' === $authGuard && '' !== $logoutUrl) {
return redirect($logoutUrl);
}
@@ -221,13 +223,13 @@ class LoginController extends Controller
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
- public function showLoginForm(Request $request): Factory | Redirector | RedirectResponse | View
+ public function showLoginForm(Request $request): Factory|Redirector|RedirectResponse|View
{
Log::channel('audit')->info('Show login form (1.1).');
- $count = DB::table('users')->count();
- $guard = config('auth.defaults.guard');
- $title = (string)trans('firefly.login_page_title');
+ $count = DB::table('users')->count();
+ $guard = config('auth.defaults.guard');
+ $title = (string)trans('firefly.login_page_title');
if (0 === $count && 'web' === $guard) {
return redirect(route('register'));
@@ -247,15 +249,15 @@ class LoginController extends Controller
$allowReset = false;
}
- $email = $request->old('email');
- $remember = $request->old('remember');
+ $email = $request->old('email');
+ $remember = $request->old('remember');
- $storeInCookie = config('google2fa.store_in_cookie', false);
+ $storeInCookie = config('google2fa.store_in_cookie', false);
if (false !== $storeInCookie) {
$cookieName = config('google2fa.cookie_name', 'google2fa_token');
- Cookie::queue(Cookie::make($cookieName, 'invalid-' . Carbon::now()->getTimestamp()));
+ Cookie::queue(Cookie::make($cookieName, 'invalid-'.Carbon::now()->getTimestamp()));
}
- $usernameField = $this->username();
+ $usernameField = $this->username();
return view('auth.login', ['allowRegistration' => $allowRegistration, 'email' => $email, 'remember' => $remember, 'allowReset' => $allowReset, 'title' => $title, 'usernameField' => $usernameField]);
}
@@ -263,9 +265,7 @@ class LoginController extends Controller
/**
* Send the response after the user was authenticated.
*
- * @param \Illuminate\Http\Request $request
- *
- * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
+ * @return JsonResponse|RedirectResponse
*/
protected function sendLoginResponse(Request $request)
{
@@ -277,7 +277,7 @@ class LoginController extends Controller
}
$path = Steam::getSafeUrl(session()->pull('url.intended', route('index')), route('index'));
Log::debug(sprintf('SafeURL is %s', $path));
+
return $request->wantsJson() ? new JsonResponse([], 204) : redirect()->to($path);
}
-
}
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index 14d61f3791..e2572d9450 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -167,7 +167,6 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
return $account;
}
-
/**
* Return account type or null if not found.
*/
diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php
index 97a0e69c03..43b3334f15 100644
--- a/app/Repositories/Account/AccountRepositoryInterface.php
+++ b/app/Repositories/Account/AccountRepositoryInterface.php
@@ -71,7 +71,6 @@ interface AccountRepositoryInterface
public function findByName(string $name, array $types): ?Account;
-
public function getAccountCurrency(Account $account): ?TransactionCurrency;
/**
diff --git a/app/Support/Balance.php b/app/Support/Balance.php
index 2c400e7c81..96fc7d35e6 100644
--- a/app/Support/Balance.php
+++ b/app/Support/Balance.php
@@ -34,6 +34,7 @@ class Balance
{
/**
* Returns the accounts balances as an array, on the account ID.
+ *
* @deprecated
*/
public function getAccountBalances(Collection $accounts, Carbon $date): array
diff --git a/app/Support/Steam.php b/app/Support/Steam.php
index f89c94d349..9bff484fe4 100644
--- a/app/Support/Steam.php
+++ b/app/Support/Steam.php
@@ -43,6 +43,7 @@ use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Safe\Exceptions\UrlException;
use ValueError;
+
use function Safe\parse_url;
use function Safe\preg_replace;
@@ -54,37 +55,38 @@ class Steam
public function accountsBalancesOptimized(Collection $accounts, Carbon $date, ?TransactionCurrency $primary = null, ?bool $convertToPrimary = null, bool $inclusive = true): array
{
Log::debug(sprintf('accountsBalancesOptimized: Called for %d account(s) with date/time "%s" (inclusive: %s)', $accounts->count(), $date->toIso8601String(), var_export($inclusive, true)));
- $result = [];
+ $result = [];
$convertToPrimary ??= Amount::convertToPrimary();
$primary ??= Amount::getPrimaryCurrency();
- $currencies = $this->getCurrencies($accounts);
+ $currencies = $this->getCurrencies($accounts);
// balance(s) in all currencies for ALL accounts.
$arrayOfSums = Transaction::whereIn('account_id', $accounts->pluck('id')->toArray())
- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
- ->leftJoin('transaction_currencies', 'transaction_currencies.id', '=', 'transactions.transaction_currency_id')
- ->where('transaction_journals.date', $inclusive ? '<=' : '<', $date->format('Y-m-d H:i:s'))
- ->groupBy(['transactions.account_id', 'transaction_currencies.code'])
- ->get(['transactions.account_id', 'transaction_currencies.code', DB::raw('SUM(transactions.amount) as sum_of_amount')])->toArray();
+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
+ ->leftJoin('transaction_currencies', 'transaction_currencies.id', '=', 'transactions.transaction_currency_id')
+ ->where('transaction_journals.date', $inclusive ? '<=' : '<', $date->format('Y-m-d H:i:s'))
+ ->groupBy(['transactions.account_id', 'transaction_currencies.code'])
+ ->get(['transactions.account_id', 'transaction_currencies.code', DB::raw('SUM(transactions.amount) as sum_of_amount')])->toArray()
+ ;
Log::debug('Array of sums: ', $arrayOfSums);
/** @var Account $account */
foreach ($accounts as $account) {
- $return = [
+ $return = [
'pc_balance' => '0',
'balance' => '0', // this key is overwritten right away, but I must remember it is always created.
];
- $currency = $currencies[$account->id];
+ $currency = $currencies[$account->id];
// second array
- $accountSums = array_filter($arrayOfSums, fn(array $entry): bool => $entry['account_id'] === $account->id);
+ $accountSums = array_filter($arrayOfSums, fn (array $entry): bool => $entry['account_id'] === $account->id);
if (0 === count($accountSums)) {
$result[$account->id] = $return;
continue;
}
- $sumsByCode = [];
+ $sumsByCode = [];
foreach ($accountSums as $accountSum) {
// $accountSum = array_values($accountSum)[0];
$sumOfAmount = (string)$accountSum['sum_of_amount'];
@@ -93,7 +95,7 @@ class Steam
}
// Log::debug('All balances are (joined)', $others);
// if there is no request to convert, take this as "balance" and "pc_balance".
- $return['balance'] = $sumsByCode[$currency->code] ?? '0';
+ $return['balance'] = $sumsByCode[$currency->code] ?? '0';
if (!$convertToPrimary) {
unset($return['pc_balance']);
// Log::debug(sprintf('Set balance to %s, unset pc_balance', $return['balance']));
@@ -106,7 +108,7 @@ class Steam
}
// either way, the balance is always combined with the virtual balance:
- $virtualBalance = (string)('' === (string)$account->virtual_balance ? '0' : $account->virtual_balance);
+ $virtualBalance = (string)('' === (string)$account->virtual_balance ? '0' : $account->virtual_balance);
if ($convertToPrimary) {
// the primary currency balance is combined with a converted virtual_balance:
@@ -159,10 +161,10 @@ class Steam
// Log::debug(sprintf('Trying bcround("%s",%d)', $number, $precision));
if (str_contains($number, '.')) {
if ('-' !== $number[0]) {
- return bcadd($number, '0.' . str_repeat('0', $precision) . '5', $precision);
+ return bcadd($number, '0.'.str_repeat('0', $precision).'5', $precision);
}
- return bcsub($number, '0.' . str_repeat('0', $precision) . '5', $precision);
+ return bcsub($number, '0.'.str_repeat('0', $precision).'5', $precision);
}
return $number;
@@ -290,26 +292,27 @@ class Steam
return str_replace($search, '', $string);
}
- #[Deprecated(message: <<<'TXT'
+ #[Deprecated(
+ message: <<<'TXT'
- By default this method returns "smaller than or equal to", so be careful with END OF DAY.
- If you need end of day balance, use "inclusive = false".
+ By default this method returns "smaller than or equal to", so be careful with END OF DAY.
+ If you need end of day balance, use "inclusive = false".
- Returns the balance of an account at exact moment given. Array with at least one value.
- Always returns:
- "balance": balance in the account's currency OR user's primary currency if the account has no currency
- "EUR": balance in EUR (or whatever currencies the account has balance in)
+ Returns the balance of an account at exact moment given. Array with at least one value.
+ Always returns:
+ "balance": balance in the account's currency OR user's primary currency if the account has no currency
+ "EUR": balance in EUR (or whatever currencies the account has balance in)
- If the user has $convertToPrimary:
- "balance": balance in the account's currency OR user's primary currency if the account has no currency
- --> "pc_balance": balance in the user's primary currency, with all amounts converted to the primary currency.
- "EUR": balance in EUR (or whatever currencies the account has balance in)
- TXT
+ If the user has $convertToPrimary:
+ "balance": balance in the account's currency OR user's primary currency if the account has no currency
+ --> "pc_balance": balance in the user's primary currency, with all amounts converted to the primary currency.
+ "EUR": balance in EUR (or whatever currencies the account has balance in)
+ TXT
)]
public function finalAccountBalance(Account $account, Carbon $date, ?TransactionCurrency $primary = null, ?bool $convertToPrimary = null, bool $inclusive = true): array
{
- $cache = new CacheProperties();
+ $cache = new CacheProperties();
$cache->addProperty($account->id);
$cache->addProperty($date);
if ($cache->has()) {
@@ -324,26 +327,27 @@ class Steam
$primary = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
}
// account balance thing.
- $currencyPresent = isset($account->meta) && array_key_exists('currency', $account->meta) && null !== $account->meta['currency'];
+ $currencyPresent = isset($account->meta) && array_key_exists('currency', $account->meta) && null !== $account->meta['currency'];
if ($currencyPresent) {
$accountCurrency = $account->meta['currency'];
}
if (!$currencyPresent) {
$accountCurrency = $this->getAccountCurrency($account);
}
- $hasCurrency = null !== $accountCurrency;
- $currency = $hasCurrency ? $accountCurrency : $primary;
- $return = [
+ $hasCurrency = null !== $accountCurrency;
+ $currency = $hasCurrency ? $accountCurrency : $primary;
+ $return = [
'pc_balance' => '0',
'balance' => '0', // this key is overwritten right away, but I must remember it is always created.
];
// balance(s) in all currencies.
- $array = $account->transactions()
- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
- ->leftJoin('transaction_currencies', 'transaction_currencies.id', '=', 'transactions.transaction_currency_id')
- ->where('transaction_journals.date', $inclusive ? '<=' : '<', $date->format('Y-m-d H:i:s'))
- ->get(['transaction_currencies.code', 'transactions.amount'])->toArray();
- $others = $this->groupAndSumTransactions($array, 'code', 'amount');
+ $array = $account->transactions()
+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
+ ->leftJoin('transaction_currencies', 'transaction_currencies.id', '=', 'transactions.transaction_currency_id')
+ ->where('transaction_journals.date', $inclusive ? '<=' : '<', $date->format('Y-m-d H:i:s'))
+ ->get(['transaction_currencies.code', 'transactions.amount'])->toArray()
+ ;
+ $others = $this->groupAndSumTransactions($array, 'code', 'amount');
Log::debug('All balances are (joined)', $others);
// if there is no request to convert, take this as "balance" and "pc_balance".
$return['balance'] = $others[$currency->code] ?? '0';
@@ -358,7 +362,7 @@ class Steam
}
// either way, the balance is always combined with the virtual balance:
- $virtualBalance = (string)('' === (string)$account->virtual_balance ? '0' : $account->virtual_balance);
+ $virtualBalance = (string)('' === (string)$account->virtual_balance ? '0' : $account->virtual_balance);
if ($convertToPrimary) {
// the primary currency balance is combined with a converted virtual_balance:
@@ -372,7 +376,7 @@ class Steam
$return['balance'] = bcadd($return['balance'], $virtualBalance);
// Log::debug(sprintf('Virtual balance makes the (primary currency) total %s', $return['balance']));
}
- $final = array_merge($return, $others);
+ $final = array_merge($return, $others);
Log::debug('Final balance is', $final);
$cache->store($final);
@@ -390,7 +394,7 @@ class Steam
Log::debug(sprintf('called finalAccountBalanceInRange(#%d, %s, %s)', $account->id, $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
// set up cache
- $cache = new CacheProperties();
+ $cache = new CacheProperties();
$cache->addProperty($account->id);
$cache->addProperty('final-balance-in-range');
$cache->addProperty($start);
@@ -401,15 +405,15 @@ class Steam
// return $cache->get();
}
- $balances = [];
- $formatted = $start->format('Y-m-d');
+ $balances = [];
+ $formatted = $start->format('Y-m-d');
Log::debug('Get first balance to start.');
// 2025-10-08 replaced finalAccountBalance with accountsBalancesOptimized:
- $primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
- $startBalance = $this->accountsBalancesOptimized(new Collection()->push($account), $start, $primaryCurrency, $convertToPrimary, false)[$account->id];
- $accountCurrency = $this->getAccountCurrency($account);
- $hasCurrency = $accountCurrency instanceof TransactionCurrency;
- $currency = $accountCurrency ?? $primaryCurrency;
+ $primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
+ $startBalance = $this->accountsBalancesOptimized(new Collection()->push($account), $start, $primaryCurrency, $convertToPrimary, false)[$account->id];
+ $accountCurrency = $this->getAccountCurrency($account);
+ $hasCurrency = $accountCurrency instanceof TransactionCurrency;
+ $currency = $accountCurrency ?? $primaryCurrency;
Log::debug(sprintf('Currency is %s', $currency->code));
// set start balances:
@@ -421,7 +425,7 @@ class Steam
Log::debug(sprintf('Also set start balance in %s', $primaryCurrency->code));
$startBalance[$primaryCurrency->code] ??= '0';
}
- $currencies = [
+ $currencies = [
$currency->id => $currency,
$primaryCurrency->id => $primaryCurrency,
];
@@ -431,47 +435,48 @@ class Steam
// sums up the balance changes per day.
Log::debug(sprintf('Date >= %s and <= %s', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
- $set = $account->transactions()
- ->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
- ->where('transaction_journals.date', '>=', $start->format('Y-m-d H:i:s'))
- ->where('transaction_journals.date', '<=', $end->format('Y-m-d H:i:s'))
- ->groupBy('transaction_journals.date')
- ->groupBy('transactions.transaction_currency_id')
- ->orderBy('transaction_journals.date', 'ASC')
- ->whereNull('transaction_journals.deleted_at')
- ->get(
- [ // @phpstan-ignore-line
- 'transaction_journals.date',
- 'transactions.transaction_currency_id',
- DB::raw('SUM(transactions.amount) AS sum_of_day'),
- ]
- );
-
- $currentBalance = $startBalance;
- $converter = new ExchangeRateConverter();
+ $set = $account->transactions()
+ ->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
+ ->where('transaction_journals.date', '>=', $start->format('Y-m-d H:i:s'))
+ ->where('transaction_journals.date', '<=', $end->format('Y-m-d H:i:s'))
+ ->groupBy('transaction_journals.date')
+ ->groupBy('transactions.transaction_currency_id')
+ ->orderBy('transaction_journals.date', 'ASC')
+ ->whereNull('transaction_journals.deleted_at')
+ ->get(
+ [ // @phpstan-ignore-line
+ 'transaction_journals.date',
+ 'transactions.transaction_currency_id',
+ DB::raw('SUM(transactions.amount) AS sum_of_day'),
+ ]
+ )
+ ;
+
+ $currentBalance = $startBalance;
+ $converter = new ExchangeRateConverter();
/** @var Transaction $entry */
foreach ($set as $entry) {
// get date object
- $carbon = new Carbon($entry->date, $entry->date_tz);
- $carbonKey = $carbon->format('Y-m-d');
+ $carbon = new Carbon($entry->date, $entry->date_tz);
+ $carbonKey = $carbon->format('Y-m-d');
// make sure sum is a string:
- $sumOfDay = (string)($entry->sum_of_day ?? '0');
+ $sumOfDay = (string)($entry->sum_of_day ?? '0');
// #10426 make sure sum is not in scientific notation.
- $sumOfDay = $this->floatalize($sumOfDay);
+ $sumOfDay = $this->floatalize($sumOfDay);
// find currency of this entry, does not have to exist.
$currencies[$entry->transaction_currency_id] ??= Amount::getTransactionCurrencyById($entry->transaction_currency_id);
// make sure this $entry has its own $entryCurrency
/** @var TransactionCurrency $entryCurrency */
- $entryCurrency = $currencies[$entry->transaction_currency_id];
+ $entryCurrency = $currencies[$entry->transaction_currency_id];
Log::debug(sprintf('Processing transaction(s) on moment %s', $carbon->format('Y-m-d H:i:s')));
// add amount to current balance in currency code.
- $currentBalance[$entryCurrency->code] ??= '0';
+ $currentBalance[$entryCurrency->code] ??= '0';
$currentBalance[$entryCurrency->code] = bcadd($sumOfDay, (string)$currentBalance[$entryCurrency->code]);
// if not requested to convert to primary currency, add the amount to "balance", do nothing else.
@@ -489,7 +494,7 @@ class Steam
}
}
// add to final array.
- $balances[$carbonKey] = $currentBalance;
+ $balances[$carbonKey] = $currentBalance;
Log::debug(sprintf('Updated entry [%s]', $carbonKey), $currentBalance);
}
$cache->store($balances);
@@ -506,7 +511,7 @@ class Steam
*/
public function floatalize(string $value): string
{
- $value = strtoupper($value);
+ $value = strtoupper($value);
if (!str_contains($value, 'E')) {
return $value;
}
@@ -530,8 +535,8 @@ class Steam
public function getAccountCurrency(Account $account): ?TransactionCurrency
{
- $type = $account->accountType->type;
- $list = config('firefly.valid_currency_account_types');
+ $type = $account->accountType->type;
+ $list = config('firefly.valid_currency_account_types');
// return null if not in this list.
if (!in_array($type, $list, true)) {
@@ -584,15 +589,15 @@ class Steam
{
$list = [];
- $set = auth()->user()->transactions()
- ->whereIn('transactions.account_id', $accounts)
- ->groupBy(['transactions.account_id', 'transaction_journals.user_id'])
- ->get(['transactions.account_id', DB::raw('MAX(transaction_journals.date) AS max_date')]) // @phpstan-ignore-line
+ $set = auth()->user()->transactions()
+ ->whereIn('transactions.account_id', $accounts)
+ ->groupBy(['transactions.account_id', 'transaction_journals.user_id'])
+ ->get(['transactions.account_id', DB::raw('MAX(transaction_journals.date) AS max_date')]) // @phpstan-ignore-line
;
/** @var Transaction $entry */
foreach ($set as $entry) {
- $date = new Carbon($entry->max_date, config('app.timezone'));
+ $date = new Carbon($entry->max_date, config('app.timezone'));
$date->setTimezone(config('app.timezone'));
$list[(int)$entry->account_id] = $date;
}
@@ -610,14 +615,14 @@ class Steam
if (null !== $cached) {
return $cached;
}
- $locale = Preferences::get('locale', config('firefly.default_locale', 'equal'))->data;
+ $locale = Preferences::get('locale', config('firefly.default_locale', 'equal'))->data;
if (is_array($locale)) {
$locale = 'equal';
}
if ('equal' === $locale) {
$locale = $this->getLanguage();
}
- $locale = (string)$locale;
+ $locale = (string)$locale;
// Check for Windows to replace the locale correctly.
if ('WIN' === strtoupper(substr(PHP_OS, 0, 3))) {
@@ -671,8 +676,9 @@ class Steam
public function getSafeUrl(string $unknownUrl, string $safeUrl): string
{
// Log::debug(sprintf('getSafeUrl(%s, %s)', $unknownUrl, $safeUrl));
- $returnUrl = $safeUrl;
-// die('in get safe url');
+ $returnUrl = $safeUrl;
+
+ // die('in get safe url');
try {
$unknownHost = parse_url($unknownUrl, PHP_URL_HOST);
} catch (UrlException $e) {
@@ -789,12 +795,12 @@ class Steam
if (null === $preference) {
$singleton->setPreference($key, $currency);
}
- $current = $amount;
+ $current = $amount;
if ($currency->id !== $primary->id) {
$current = $converter->convert($currency, $primary, $date, $amount);
Log::debug(sprintf('Convert %s %s to %s %s', $currency->code, $amount, $primary->code, $current));
}
- $total = bcadd((string)$current, $total);
+ $total = bcadd((string)$current, $total);
}
return $total;
@@ -808,8 +814,8 @@ class Steam
$primary = Amount::getPrimaryCurrency();
$currencies[$primary->id] = $primary;
- $ids = $accounts->pluck('id')->toArray();
- $result = AccountMeta::whereIn('account_id', $ids)->where('name', 'currency_id')->get();
+ $ids = $accounts->pluck('id')->toArray();
+ $result = AccountMeta::whereIn('account_id', $ids)->where('name', 'currency_id')->get();
/** @var AccountMeta $item */
foreach ($result as $item) {
@@ -819,7 +825,7 @@ class Steam
}
}
// collect those currencies, skip primary because we already have it.
- $set = TransactionCurrency::whereIn('id', $accountPreferences)->where('id', '!=', $primary->id)->get();
+ $set = TransactionCurrency::whereIn('id', $accountPreferences)->where('id', '!=', $primary->id)->get();
foreach ($set as $item) {
$currencies[$item->id] = $item;
}
@@ -830,7 +836,7 @@ class Steam
$currencyPresent = isset($account->meta) && array_key_exists('currency', $account->meta) && null !== $account->meta['currency'];
if ($currencyPresent) {
$currencyId = $account->meta['currency']->id;
- $currencies[$currencyId] ??= $account->meta['currency'];
+ $currencies[$currencyId] ??= $account->meta['currency'];
$accountCurrencies[$accountId] = $account->meta['currency'];
}
if (!$currencyPresent && !array_key_exists($accountId, $accountPreferences)) {
diff --git a/composer.lock b/composer.lock
index 257ba749b2..3d41f1cc0b 100644
--- a/composer.lock
+++ b/composer.lock
@@ -10515,16 +10515,16 @@
},
{
"name": "driftingly/rector-laravel",
- "version": "2.1.7",
+ "version": "2.1.8",
"source": {
"type": "git",
"url": "https://github.com/driftingly/rector-laravel.git",
- "reference": "2a64c96fa363bc85e4e6d4162c6a6bb7a78fd122"
+ "reference": "5c5f97354e562b6742b2b7989959061bde60fa71"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/driftingly/rector-laravel/zipball/2a64c96fa363bc85e4e6d4162c6a6bb7a78fd122",
- "reference": "2a64c96fa363bc85e4e6d4162c6a6bb7a78fd122",
+ "url": "https://api.github.com/repos/driftingly/rector-laravel/zipball/5c5f97354e562b6742b2b7989959061bde60fa71",
+ "reference": "5c5f97354e562b6742b2b7989959061bde60fa71",
"shasum": ""
},
"require": {
@@ -10545,9 +10545,9 @@
"description": "Rector upgrades rules for Laravel Framework",
"support": {
"issues": "https://github.com/driftingly/rector-laravel/issues",
- "source": "https://github.com/driftingly/rector-laravel/tree/2.1.7"
+ "source": "https://github.com/driftingly/rector-laravel/tree/2.1.8"
},
- "time": "2025-12-10T11:30:42+00:00"
+ "time": "2025-12-17T15:29:24+00:00"
},
{
"name": "fakerphp/faker",
diff --git a/config/firefly.php b/config/firefly.php
index b31e10e7c3..7dd4f7c48a 100644
--- a/config/firefly.php
+++ b/config/firefly.php
@@ -78,8 +78,8 @@ return [
'running_balance_column' => env('USE_RUNNING_BALANCE', false),
// see cer.php for exchange rates feature flag.
],
- 'version' => 'develop/2025-12-17',
- 'build_time' => 1765957552,
+ 'version' => 'develop/2025-12-19',
+ 'build_time' => 1766158365,
'api_version' => '2.1.0', // field is no longer used.
'db_version' => 28, // field is no longer used.
diff --git a/package-lock.json b/package-lock.json
index ed1fda10ec..78072dae5f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -3294,42 +3294,42 @@
}
},
"node_modules/@vue/compiler-core": {
- "version": "3.5.25",
- "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.25.tgz",
- "integrity": "sha512-vay5/oQJdsNHmliWoZfHPoVZZRmnSWhug0BYT34njkYTPqClh3DNWLkZNJBVSjsNMrg0CCrBfoKkjZQPM/QVUw==",
+ "version": "3.5.26",
+ "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.26.tgz",
+ "integrity": "sha512-vXyI5GMfuoBCnv5ucIT7jhHKl55Y477yxP6fc4eUswjP8FG3FFVFd41eNDArR+Uk3QKn2Z85NavjaxLxOC19/w==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/parser": "^7.28.5",
- "@vue/shared": "3.5.25",
- "entities": "^4.5.0",
+ "@vue/shared": "3.5.26",
+ "entities": "^7.0.0",
"estree-walker": "^2.0.2",
"source-map-js": "^1.2.1"
}
},
"node_modules/@vue/compiler-dom": {
- "version": "3.5.25",
- "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.25.tgz",
- "integrity": "sha512-4We0OAcMZsKgYoGlMjzYvaoErltdFI2/25wqanuTu+S4gismOTRTBPi4IASOjxWdzIwrYSjnqONfKvuqkXzE2Q==",
+ "version": "3.5.26",
+ "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.26.tgz",
+ "integrity": "sha512-y1Tcd3eXs834QjswshSilCBnKGeQjQXB6PqFn/1nxcQw4pmG42G8lwz+FZPAZAby6gZeHSt/8LMPfZ4Rb+Bd/A==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@vue/compiler-core": "3.5.25",
- "@vue/shared": "3.5.25"
+ "@vue/compiler-core": "3.5.26",
+ "@vue/shared": "3.5.26"
}
},
"node_modules/@vue/compiler-sfc": {
- "version": "3.5.25",
- "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.25.tgz",
- "integrity": "sha512-PUgKp2rn8fFsI++lF2sO7gwO2d9Yj57Utr5yEsDf3GNaQcowCLKL7sf+LvVFvtJDXUp/03+dC6f2+LCv5aK1ag==",
+ "version": "3.5.26",
+ "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.26.tgz",
+ "integrity": "sha512-egp69qDTSEZcf4bGOSsprUr4xI73wfrY5oRs6GSgXFTiHrWj4Y3X5Ydtip9QMqiCMCPVwLglB9GBxXtTadJ3mA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/parser": "^7.28.5",
- "@vue/compiler-core": "3.5.25",
- "@vue/compiler-dom": "3.5.25",
- "@vue/compiler-ssr": "3.5.25",
- "@vue/shared": "3.5.25",
+ "@vue/compiler-core": "3.5.26",
+ "@vue/compiler-dom": "3.5.26",
+ "@vue/compiler-ssr": "3.5.26",
+ "@vue/shared": "3.5.26",
"estree-walker": "^2.0.2",
"magic-string": "^0.30.21",
"postcss": "^8.5.6",
@@ -3337,14 +3337,14 @@
}
},
"node_modules/@vue/compiler-ssr": {
- "version": "3.5.25",
- "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.25.tgz",
- "integrity": "sha512-ritPSKLBcParnsKYi+GNtbdbrIE1mtuFEJ4U1sWeuOMlIziK5GtOL85t5RhsNy4uWIXPgk+OUdpnXiTdzn8o3A==",
+ "version": "3.5.26",
+ "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.26.tgz",
+ "integrity": "sha512-lZT9/Y0nSIRUPVvapFJEVDbEXruZh2IYHMk2zTtEgJSlP5gVOqeWXH54xDKAaFS4rTnDeDBQUYDtxKyoW9FwDw==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@vue/compiler-dom": "3.5.25",
- "@vue/shared": "3.5.25"
+ "@vue/compiler-dom": "3.5.26",
+ "@vue/shared": "3.5.26"
}
},
"node_modules/@vue/component-compiler-utils": {
@@ -3426,9 +3426,9 @@
"license": "MIT"
},
"node_modules/@vue/shared": {
- "version": "3.5.25",
- "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.25.tgz",
- "integrity": "sha512-AbOPdQQnAnzs58H2FrrDxYj/TJfmeS2jdfEEhgiKINy+bnOANmVizIEgq1r+C5zsbs6l1CCQxtcj71rwNQ4jWg==",
+ "version": "3.5.26",
+ "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.26.tgz",
+ "integrity": "sha512-7Z6/y3uFI5PRoKeorTOSXKcDj0MSasfNNltcslbFrPpcw6aXRUALq4IfJlaTRspiWIUOEZbrpM+iQGmCOiWe4A==",
"dev": true,
"license": "MIT"
},
@@ -4075,9 +4075,9 @@
"license": "MIT"
},
"node_modules/baseline-browser-mapping": {
- "version": "2.9.8",
- "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.8.tgz",
- "integrity": "sha512-Y1fOuNDowLfgKOypdc9SPABfoWXuZHBOyCS4cD52IeZBhr4Md6CLLs6atcxVrzRmQ06E7hSlm5bHHApPKR/byA==",
+ "version": "2.9.11",
+ "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.11.tgz",
+ "integrity": "sha512-Sg0xJUNDU1sJNGdfGWhVHX0kkZ+HWcvmVymJbj6NSgZZmW/8S9Y2HQ5euytnIgakgxN6papOAWiwDo1ctFDcoQ==",
"dev": true,
"license": "Apache-2.0",
"bin": {
@@ -4508,9 +4508,9 @@
}
},
"node_modules/caniuse-lite": {
- "version": "1.0.30001760",
- "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001760.tgz",
- "integrity": "sha512-7AAMPcueWELt1p3mi13HR/LHH0TJLT11cnwDJEs3xA4+CK/PLKeO9Kl1oru24htkyUKtkGCvAx4ohB0Ttry8Dw==",
+ "version": "1.0.30001761",
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001761.tgz",
+ "integrity": "sha512-JF9ptu1vP2coz98+5051jZ4PwQgd2ni8A+gYSN7EA7dPKIMf0pDlSUxhdmVOaV3/fYK5uWBkgSXJaRLr4+3A6g==",
"dev": true,
"funding": [
{
@@ -5787,9 +5787,9 @@
}
},
"node_modules/entities": {
- "version": "4.5.0",
- "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
- "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/entities/-/entities-7.0.0.tgz",
+ "integrity": "sha512-FDWG5cmEYf2Z00IkYRhbFrwIwvdFKH07uV8dvNy0omp/Qb1xcyCWp2UDtcwJF4QZZvk0sLudP6/hAu42TaqVhQ==",
"dev": true,
"license": "BSD-2-Clause",
"engines": {
@@ -11740,9 +11740,9 @@
"license": "BSD-2-Clause"
},
"node_modules/webpack": {
- "version": "5.104.0",
- "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.104.0.tgz",
- "integrity": "sha512-5DeICTX8BVgNp6afSPYXAFjskIgWGlygQH58bcozPOXgo2r/6xx39Y1+cULZ3gTxUYQP88jmwLj2anu4Xaq84g==",
+ "version": "5.104.1",
+ "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.104.1.tgz",
+ "integrity": "sha512-Qphch25abbMNtekmEGJmeRUhLDbe+QfiWTiqpKYkpCOWY64v9eyl+KRRLmqOFA2AvKPpc9DC6+u2n76tQLBoaA==",
"dev": true,
"license": "MIT",
"dependencies": {