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

# Conflicts:
#	app/Support/Steam.php
This commit is contained in:
James Cole 2024-12-31 08:19:47 +01:00
commit 6fde693e7a
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
7 changed files with 43 additions and 40 deletions

View File

@ -137,13 +137,13 @@ class AccountController extends Controller
continue; continue;
} }
//Log::debug(sprintf('Will process expense array "%s" with amount %s', $key, $endBalance)); // Log::debug(sprintf('Will process expense array "%s" with amount %s', $key, $endBalance));
$searchCode = $this->convertToNative ? $this->defaultCurrency->code : $key; $searchCode = $this->convertToNative ? $this->defaultCurrency->code : $key;
//Log::debug(sprintf('Search code is %s', $searchCode)); // Log::debug(sprintf('Search code is %s', $searchCode));
// see if there is an accompanying start amount. // see if there is an accompanying start amount.
// grab the difference and find the currency. // grab the difference and find the currency.
$startBalance = ($startBalances[$account->id][$key] ?? '0'); $startBalance = ($startBalances[$account->id][$key] ?? '0');
// Log::debug(sprintf('Start balance is %s', $startBalance)); // Log::debug(sprintf('Start balance is %s', $startBalance));
$diff = bcsub($endBalance, $startBalance); $diff = bcsub($endBalance, $startBalance);
$currencies[$searchCode] ??= $this->currencyRepository->findByCode($searchCode); $currencies[$searchCode] ??= $this->currencyRepository->findByCode($searchCode);
if (0 !== bccomp($diff, '0')) { if (0 !== bccomp($diff, '0')) {
@ -596,13 +596,13 @@ class AccountController extends Controller
continue; continue;
} }
//Log::debug(sprintf('Will process expense array "%s" with amount %s', $key, $endBalance)); // Log::debug(sprintf('Will process expense array "%s" with amount %s', $key, $endBalance));
$searchCode = $this->convertToNative ? $this->defaultCurrency->code : $key; $searchCode = $this->convertToNative ? $this->defaultCurrency->code : $key;
//Log::debug(sprintf('Search code is %s', $searchCode)); // Log::debug(sprintf('Search code is %s', $searchCode));
// see if there is an accompanying start amount. // see if there is an accompanying start amount.
// grab the difference and find the currency. // grab the difference and find the currency.
$startBalance = ($startBalances[$account->id][$key] ?? '0'); $startBalance = ($startBalances[$account->id][$key] ?? '0');
//Log::debug(sprintf('Start balance is %s', $startBalance)); // Log::debug(sprintf('Start balance is %s', $startBalance));
$diff = bcsub($endBalance, $startBalance); $diff = bcsub($endBalance, $startBalance);
$currencies[$searchCode] ??= $this->currencyRepository->findByCode($searchCode); $currencies[$searchCode] ??= $this->currencyRepository->findByCode($searchCode);
if (0 !== bccomp($diff, '0')) { if (0 !== bccomp($diff, '0')) {

View File

@ -550,9 +550,9 @@ class BillRepository implements BillRepositoryInterface
foreach ($set as $transactionJournal) { foreach ($set as $transactionJournal) {
$setAmount = bcadd($setAmount, Amount::getAmountFromJournalObject($transactionJournal)); $setAmount = bcadd($setAmount, Amount::getAmountFromJournalObject($transactionJournal));
} }
//Log::debug(sprintf('Bill #%d ("%s") with %d transaction(s) and sum %s %s', $bill->id, $bill->name, $set->count(), $currency->code, $setAmount)); // Log::debug(sprintf('Bill #%d ("%s") with %d transaction(s) and sum %s %s', $bill->id, $bill->name, $set->count(), $currency->code, $setAmount));
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $setAmount); $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $setAmount);
//Log::debug(sprintf('Total sum is now %s', $return[$currency->id]['sum'])); // Log::debug(sprintf('Total sum is now %s', $return[$currency->id]['sum']));
} }
return $return; return $return;

View File

@ -52,10 +52,11 @@ class Preferences
$q->whereNull('user_group_id'); $q->whereNull('user_group_id');
$q->orWhere('user_group_id', $user->user_group_id); $q->orWhere('user_group_id', $user->user_group_id);
}) })
->get(); ->get()
;
} }
public function get(string $name, null | array | bool | int | string $default = null): ?Preference public function get(string $name, null|array|bool|int|string $default = null): ?Preference
{ {
/** @var null|User $user */ /** @var null|User $user */
$user = auth()->user(); $user = auth()->user();
@ -69,7 +70,7 @@ class Preferences
return $this->getForUser($user, $name, $default); return $this->getForUser($user, $name, $default);
} }
public function getForUser(User $user, string $name, null | array | bool | int | string $default = null): ?Preference public function getForUser(User $user, string $name, null|array|bool|int|string $default = null): ?Preference
{ {
// don't care about user group ID, except for some specific preferences. // don't care about user group ID, except for some specific preferences.
$userGroupId = $this->getUserGroupId($user, $name); $userGroupId = $this->getUserGroupId($user, $name);
@ -121,7 +122,7 @@ class Preferences
Cache::put($key, '', 5); Cache::put($key, '', 5);
} }
public function setForUser(User $user, string $name, null | array | bool | int | string $value): Preference public function setForUser(User $user, string $name, null|array|bool|int|string $value): Preference
{ {
$fullName = sprintf('preference%s%s', $user->id, $name); $fullName = sprintf('preference%s%s', $user->id, $name);
$groupId = $this->getUserGroupId($user, $name); $groupId = $this->getUserGroupId($user, $name);
@ -178,7 +179,8 @@ class Preferences
$q->orWhere('user_group_id', $user->user_group_id); $q->orWhere('user_group_id', $user->user_group_id);
}) })
->whereIn('name', $list) ->whereIn('name', $list)
->get(['id', 'name', 'data']); ->get(['id', 'name', 'data'])
;
/** @var Preference $preference */ /** @var Preference $preference */
foreach ($preferences as $preference) { foreach ($preferences as $preference) {
@ -220,7 +222,7 @@ class Preferences
return $result; return $result;
} }
public function getEncryptedForUser(User $user, string $name, null | array | bool | int | string $default = null): ?Preference public function getEncryptedForUser(User $user, string $name, null|array|bool|int|string $default = null): ?Preference
{ {
$result = $this->getForUser($user, $name, $default); $result = $this->getForUser($user, $name, $default);
if ('' === $result->data) { if ('' === $result->data) {
@ -245,7 +247,7 @@ class Preferences
return $result; return $result;
} }
public function getFresh(string $name, null | array | bool | int | string $default = null): ?Preference public function getFresh(string $name, null|array|bool|int|string $default = null): ?Preference
{ {
/** @var null|User $user */ /** @var null|User $user */
$user = auth()->user(); $user = auth()->user();
@ -283,7 +285,7 @@ class Preferences
Session::forget('first'); Session::forget('first');
} }
public function set(string $name, null | array | bool | int | string $value): Preference public function set(string $name, null|array|bool|int|string $value): Preference
{ {
/** @var null|User $user */ /** @var null|User $user */
$user = auth()->user(); $user = auth()->user();

View File

@ -339,7 +339,7 @@ class Steam
if ($native->id === $accountCurrency?->id) { if ($native->id === $accountCurrency?->id) {
$return['balance'] = bcadd('' === (string) $account->virtual_balance ? '0' : $account->virtual_balance, $return['balance']); $return['balance'] = bcadd('' === (string) $account->virtual_balance ? '0' : $account->virtual_balance, $return['balance']);
} }
//Log::debug(sprintf('balance is (%s only) %s (with virtual balance)', $native->code, $this->bcround($return['balance'], 2))); // Log::debug(sprintf('balance is (%s only) %s (with virtual balance)', $native->code, $this->bcround($return['balance'], 2)));
// native balance // native balance
$return['native_balance'] = (string) $account->transactions() $return['native_balance'] = (string) $account->transactions()
@ -350,7 +350,7 @@ class Steam
; ;
// plus native virtual balance. // plus native virtual balance.
$return['native_balance'] = bcadd('' === (string) $account->native_virtual_balance ? '0' : $account->native_virtual_balance, $return['native_balance']); $return['native_balance'] = bcadd('' === (string) $account->native_virtual_balance ? '0' : $account->native_virtual_balance, $return['native_balance']);
//Log::debug(sprintf('native_balance is (all transactions to %s) %s (with virtual balance)', $native->code, $this->bcround($return['native_balance']))); // Log::debug(sprintf('native_balance is (all transactions to %s) %s (with virtual balance)', $native->code, $this->bcround($return['native_balance'])));
// plus foreign transactions in THIS currency. // plus foreign transactions in THIS currency.
$sum = (string) $account->transactions() $sum = (string) $account->transactions()
@ -387,9 +387,9 @@ class Steam
// } // }
if (!$hasCurrency && array_key_exists('balance', $return) && array_key_exists('native_balance', $return)) { if (!$hasCurrency && array_key_exists('balance', $return) && array_key_exists('native_balance', $return)) {
// Log::debug('Account has no currency preference, dropping balance in favor of native balance.'); // Log::debug('Account has no currency preference, dropping balance in favor of native balance.');
$sum = bcadd($return['balance'], $return['native_balance']); $sum = bcadd($return['balance'], $return['native_balance']);
// Log::debug(sprintf('%s + %s = %s', $return['balance'], $return['native_balance'], $sum)); // Log::debug(sprintf('%s + %s = %s', $return['balance'], $return['native_balance'], $sum));
$return['native_balance'] = $sum; $return['native_balance'] = $sum;
unset($return['balance']); unset($return['balance']);
} }
@ -397,7 +397,8 @@ class Steam
// Log::debug('Return is', $final); // Log::debug('Return is', $final);
$cache->store($final); $cache->store($final);
return $final; return array_merge($return, $others);
// Log::debug('Return is', $final);
} }
public function filterAccountBalances(array $total, Account $account, bool $convertToNative, ?TransactionCurrency $currency = null): array public function filterAccountBalances(array $total, Account $account, bool $convertToNative, ?TransactionCurrency $currency = null): array

View File

@ -81,7 +81,7 @@ return [
'running_balance_column' => env('USE_RUNNING_BALANCE', false), 'running_balance_column' => env('USE_RUNNING_BALANCE', false),
// see cer.php for exchange rates feature flag. // see cer.php for exchange rates feature flag.
], ],
'version' => '6.2.0-alpha.1', 'version' => 'develop/2024-12-31',
'api_version' => '2.1.0', // field is no longer used. 'api_version' => '2.1.0', // field is no longer used.
'db_version' => 25, 'db_version' => 25,

6
package-lock.json generated
View File

@ -12114,9 +12114,9 @@
"license": "ISC" "license": "ISC"
}, },
"node_modules/yaml": { "node_modules/yaml": {
"version": "2.6.1", "version": "2.7.0",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.6.1.tgz", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.7.0.tgz",
"integrity": "sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==", "integrity": "sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA==",
"dev": true, "dev": true,
"license": "ISC", "license": "ISC",
"bin": { "bin": {