mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 02:26:58 +00:00
🤖 Auto commit for release 'develop' on 2025-08-10
This commit is contained in:
@@ -119,7 +119,7 @@ class ShowController extends Controller
|
|||||||
$firstTransaction = $this->repository->oldestJournalDate($account) ?? $start;
|
$firstTransaction = $this->repository->oldestJournalDate($account) ?? $start;
|
||||||
|
|
||||||
// go back max 3 years.
|
// go back max 3 years.
|
||||||
$threeYearsAgo = $start->subYears(3);
|
$threeYearsAgo = $start->subYears(3);
|
||||||
$firstTransaction = $firstTransaction->lt($threeYearsAgo) ? $threeYearsAgo : $firstTransaction;
|
$firstTransaction = $firstTransaction->lt($threeYearsAgo) ? $threeYearsAgo : $firstTransaction;
|
||||||
|
|
||||||
Log::debug('Start period overview');
|
Log::debug('Start period overview');
|
||||||
|
@@ -38,6 +38,7 @@ use Illuminate\Support\Facades\DB;
|
|||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use ValueError;
|
use ValueError;
|
||||||
|
|
||||||
use function Safe\parse_url;
|
use function Safe\parse_url;
|
||||||
use function Safe\preg_replace;
|
use function Safe\preg_replace;
|
||||||
|
|
||||||
@@ -65,10 +66,10 @@ class Steam
|
|||||||
// Log::debug(sprintf('Trying bcround("%s",%d)', $number, $precision));
|
// Log::debug(sprintf('Trying bcround("%s",%d)', $number, $precision));
|
||||||
if (str_contains($number, '.')) {
|
if (str_contains($number, '.')) {
|
||||||
if ('-' !== $number[0]) {
|
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;
|
return $number;
|
||||||
@@ -204,7 +205,7 @@ class Steam
|
|||||||
Log::debug(sprintf('finalAccountBalanceInRange(#%d, %s, %s)', $account->id, $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
Log::debug(sprintf('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
|
// set up cache
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($account->id);
|
$cache->addProperty($account->id);
|
||||||
$cache->addProperty('final-balance-in-range');
|
$cache->addProperty('final-balance-in-range');
|
||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
@@ -214,21 +215,21 @@ class Steam
|
|||||||
return $cache->get();
|
return $cache->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
$balances = [];
|
$balances = [];
|
||||||
$formatted = $start->format('Y-m-d');
|
$formatted = $start->format('Y-m-d');
|
||||||
/*
|
/*
|
||||||
* To make sure the start balance is correct, we need to get the balance at the exact end of the previous day.
|
* To make sure the start balance is correct, we need to get the balance at the exact end of the previous day.
|
||||||
* Since we just did "startOfDay" we can do subDay()->endOfDay() to get the correct moment.
|
* Since we just did "startOfDay" we can do subDay()->endOfDay() to get the correct moment.
|
||||||
* THAT will be the start balance.
|
* THAT will be the start balance.
|
||||||
*/
|
*/
|
||||||
$request = clone $start;
|
$request = clone $start;
|
||||||
$request->subDay()->endOfDay();
|
$request->subDay()->endOfDay();
|
||||||
Log::debug(sprintf('finalAccountBalanceInRange: Call finalAccountBalance with date/time "%s"', $request->toIso8601String()));
|
Log::debug(sprintf('finalAccountBalanceInRange: Call finalAccountBalance with date/time "%s"', $request->toIso8601String()));
|
||||||
$startBalance = $this->finalAccountBalance($account, $request);
|
$startBalance = $this->finalAccountBalance($account, $request);
|
||||||
$primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
$primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||||
$accountCurrency = $this->getAccountCurrency($account);
|
$accountCurrency = $this->getAccountCurrency($account);
|
||||||
$hasCurrency = $accountCurrency instanceof TransactionCurrency;
|
$hasCurrency = $accountCurrency instanceof TransactionCurrency;
|
||||||
$currency = $accountCurrency ?? $primaryCurrency;
|
$currency = $accountCurrency ?? $primaryCurrency;
|
||||||
Log::debug(sprintf('Currency is %s', $currency->code));
|
Log::debug(sprintf('Currency is %s', $currency->code));
|
||||||
|
|
||||||
|
|
||||||
@@ -241,7 +242,7 @@ class Steam
|
|||||||
Log::debug(sprintf('Also set start balance in %s', $primaryCurrency->code));
|
Log::debug(sprintf('Also set start balance in %s', $primaryCurrency->code));
|
||||||
$startBalance[$primaryCurrency->code] ??= '0';
|
$startBalance[$primaryCurrency->code] ??= '0';
|
||||||
}
|
}
|
||||||
$currencies = [
|
$currencies = [
|
||||||
$currency->id => $currency,
|
$currency->id => $currency,
|
||||||
$primaryCurrency->id => $primaryCurrency,
|
$primaryCurrency->id => $primaryCurrency,
|
||||||
];
|
];
|
||||||
@@ -251,47 +252,48 @@ class Steam
|
|||||||
|
|
||||||
// sums up the balance changes per day.
|
// 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')));
|
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()
|
$set = $account->transactions()
|
||||||
->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
->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', '>=', $start->format('Y-m-d H:i:s'))
|
||||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d H:i:s'))
|
->where('transaction_journals.date', '<=', $end->format('Y-m-d H:i:s'))
|
||||||
->groupBy('transaction_journals.date')
|
->groupBy('transaction_journals.date')
|
||||||
->groupBy('transactions.transaction_currency_id')
|
->groupBy('transactions.transaction_currency_id')
|
||||||
->orderBy('transaction_journals.date', 'ASC')
|
->orderBy('transaction_journals.date', 'ASC')
|
||||||
->whereNull('transaction_journals.deleted_at')
|
->whereNull('transaction_journals.deleted_at')
|
||||||
->get(
|
->get(
|
||||||
[ // @phpstan-ignore-line
|
[ // @phpstan-ignore-line
|
||||||
'transaction_journals.date',
|
'transaction_journals.date',
|
||||||
'transactions.transaction_currency_id',
|
'transactions.transaction_currency_id',
|
||||||
DB::raw('SUM(transactions.amount) AS sum_of_day'),
|
DB::raw('SUM(transactions.amount) AS sum_of_day'),
|
||||||
]
|
]
|
||||||
);
|
)
|
||||||
|
;
|
||||||
|
|
||||||
$currentBalance = $startBalance;
|
$currentBalance = $startBalance;
|
||||||
$converter = new ExchangeRateConverter();
|
$converter = new ExchangeRateConverter();
|
||||||
|
|
||||||
|
|
||||||
/** @var Transaction $entry */
|
/** @var Transaction $entry */
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
// get date object
|
// get date object
|
||||||
$carbon = new Carbon($entry->date, $entry->date_tz);
|
$carbon = new Carbon($entry->date, $entry->date_tz);
|
||||||
$carbonKey = $carbon->format('Y-m-d');
|
$carbonKey = $carbon->format('Y-m-d');
|
||||||
// make sure sum is a string:
|
// 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.
|
// #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.
|
// find currency of this entry, does not have to exist.
|
||||||
$currencies[$entry->transaction_currency_id] ??= TransactionCurrency::find($entry->transaction_currency_id);
|
$currencies[$entry->transaction_currency_id] ??= TransactionCurrency::find($entry->transaction_currency_id);
|
||||||
|
|
||||||
// make sure this $entry has its own $entryCurrency
|
// make sure this $entry has its own $entryCurrency
|
||||||
/** @var TransactionCurrency $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')));
|
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.
|
// 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]);
|
$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.
|
// if not requested to convert to primary currency, add the amount to "balance", do nothing else.
|
||||||
@@ -309,7 +311,7 @@ class Steam
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// add to final array.
|
// add to final array.
|
||||||
$balances[$carbonKey] = $currentBalance;
|
$balances[$carbonKey] = $currentBalance;
|
||||||
Log::debug(sprintf('Updated entry [%s]', $carbonKey), $currentBalance);
|
Log::debug(sprintf('Updated entry [%s]', $carbonKey), $currentBalance);
|
||||||
}
|
}
|
||||||
$cache->store($balances);
|
$cache->store($balances);
|
||||||
@@ -321,36 +323,37 @@ class Steam
|
|||||||
public function accountsBalancesOptimized(Collection $accounts, Carbon $date, ?TransactionCurrency $primary = null, ?bool $convertToPrimary = null): array
|
public function accountsBalancesOptimized(Collection $accounts, Carbon $date, ?TransactionCurrency $primary = null, ?bool $convertToPrimary = null): array
|
||||||
{
|
{
|
||||||
Log::debug(sprintf('accountsBalancesOptimized: Called with date/time "%s"', $date->toIso8601String()));
|
Log::debug(sprintf('accountsBalancesOptimized: Called with date/time "%s"', $date->toIso8601String()));
|
||||||
$result = [];
|
$result = [];
|
||||||
$convertToPrimary ??= Amount::convertToPrimary();
|
$convertToPrimary ??= Amount::convertToPrimary();
|
||||||
$primary ??= Amount::getPrimaryCurrency();
|
$primary ??= Amount::getPrimaryCurrency();
|
||||||
$currencies = $this->getCurrencies($accounts);
|
$currencies = $this->getCurrencies($accounts);
|
||||||
|
|
||||||
// balance(s) in all currencies for ALL accounts.
|
// balance(s) in all currencies for ALL accounts.
|
||||||
$array = Transaction::whereIn('account_id', $accounts->pluck('id')->toArray())
|
$array = Transaction::whereIn('account_id', $accounts->pluck('id')->toArray())
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->leftJoin('transaction_currencies', 'transaction_currencies.id', '=', 'transactions.transaction_currency_id')
|
->leftJoin('transaction_currencies', 'transaction_currencies.id', '=', 'transactions.transaction_currency_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d H:i:s'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d H:i:s'))
|
||||||
->get(['transactions.account_id', 'transaction_currencies.code', 'transactions.amount'])->toArray();
|
->get(['transactions.account_id', 'transaction_currencies.code', 'transactions.amount'])->toArray()
|
||||||
|
;
|
||||||
|
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
// filter array back to this account:
|
// filter array back to this account:
|
||||||
$filtered = array_filter($array, function ($item) use ($account) {
|
$filtered = array_filter($array, function ($item) use ($account) {
|
||||||
return (int)$item['account_id'] === $account->id;
|
return (int)$item['account_id'] === $account->id;
|
||||||
});
|
});
|
||||||
$currency = $currencies[$account->id];
|
$currency = $currencies[$account->id];
|
||||||
// this array is PER account, so we wait a bit before we change code here.
|
// this array is PER account, so we wait a bit before we change code here.
|
||||||
$return = [
|
$return = [
|
||||||
'pc_balance' => '0',
|
'pc_balance' => '0',
|
||||||
'balance' => '0', // this key is overwritten right away, but I must remember it is always created.
|
'balance' => '0', // this key is overwritten right away, but I must remember it is always created.
|
||||||
];
|
];
|
||||||
|
|
||||||
// balance(s) in all currencies.
|
// balance(s) in all currencies.
|
||||||
$others = $this->groupAndSumTransactions($filtered, 'code', 'amount');
|
$others = $this->groupAndSumTransactions($filtered, 'code', 'amount');
|
||||||
// Log::debug('All balances are (joined)', $others);
|
// Log::debug('All balances are (joined)', $others);
|
||||||
// if there is no request to convert, take this as "balance" and "pc_balance".
|
// if there is no request to convert, take this as "balance" and "pc_balance".
|
||||||
$return['balance'] = $others[$currency->code] ?? '0';
|
$return['balance'] = $others[$currency->code] ?? '0';
|
||||||
if (!$convertToPrimary) {
|
if (!$convertToPrimary) {
|
||||||
unset($return['pc_balance']);
|
unset($return['pc_balance']);
|
||||||
// Log::debug(sprintf('Set balance to %s, unset pc_balance', $return['balance']));
|
// Log::debug(sprintf('Set balance to %s, unset pc_balance', $return['balance']));
|
||||||
@@ -362,7 +365,7 @@ class Steam
|
|||||||
}
|
}
|
||||||
|
|
||||||
// either way, the balance is always combined with the virtual balance:
|
// 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) {
|
if ($convertToPrimary) {
|
||||||
// the primary currency balance is combined with a converted virtual_balance:
|
// the primary currency balance is combined with a converted virtual_balance:
|
||||||
@@ -400,7 +403,7 @@ class Steam
|
|||||||
public function finalAccountBalance(Account $account, Carbon $date, ?TransactionCurrency $primary = null, ?bool $convertToPrimary = null): array
|
public function finalAccountBalance(Account $account, Carbon $date, ?TransactionCurrency $primary = null, ?bool $convertToPrimary = null): array
|
||||||
{
|
{
|
||||||
|
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($account->id);
|
$cache->addProperty($account->id);
|
||||||
$cache->addProperty($date);
|
$cache->addProperty($date);
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
@@ -416,7 +419,7 @@ class Steam
|
|||||||
$primary = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
$primary = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||||
}
|
}
|
||||||
// account balance thing.
|
// 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) {
|
if ($currencyPresent) {
|
||||||
$accountCurrency = $account->meta['currency'];
|
$accountCurrency = $account->meta['currency'];
|
||||||
}
|
}
|
||||||
@@ -424,19 +427,20 @@ class Steam
|
|||||||
|
|
||||||
$accountCurrency = $this->getAccountCurrency($account);
|
$accountCurrency = $this->getAccountCurrency($account);
|
||||||
}
|
}
|
||||||
$hasCurrency = null !== $accountCurrency;
|
$hasCurrency = null !== $accountCurrency;
|
||||||
$currency = $hasCurrency ? $accountCurrency : $primary;
|
$currency = $hasCurrency ? $accountCurrency : $primary;
|
||||||
$return = [
|
$return = [
|
||||||
'pc_balance' => '0',
|
'pc_balance' => '0',
|
||||||
'balance' => '0', // this key is overwritten right away, but I must remember it is always created.
|
'balance' => '0', // this key is overwritten right away, but I must remember it is always created.
|
||||||
];
|
];
|
||||||
// balance(s) in all currencies.
|
// balance(s) in all currencies.
|
||||||
$array = $account->transactions()
|
$array = $account->transactions()
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->leftJoin('transaction_currencies', 'transaction_currencies.id', '=', 'transactions.transaction_currency_id')
|
->leftJoin('transaction_currencies', 'transaction_currencies.id', '=', 'transactions.transaction_currency_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d H:i:s'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d H:i:s'))
|
||||||
->get(['transaction_currencies.code', 'transactions.amount'])->toArray();
|
->get(['transaction_currencies.code', 'transactions.amount'])->toArray()
|
||||||
$others = $this->groupAndSumTransactions($array, 'code', 'amount');
|
;
|
||||||
|
$others = $this->groupAndSumTransactions($array, 'code', 'amount');
|
||||||
// Log::debug('All balances are (joined)', $others);
|
// Log::debug('All balances are (joined)', $others);
|
||||||
// if there is no request to convert, take this as "balance" and "pc_balance".
|
// if there is no request to convert, take this as "balance" and "pc_balance".
|
||||||
$return['balance'] = $others[$currency->code] ?? '0';
|
$return['balance'] = $others[$currency->code] ?? '0';
|
||||||
@@ -451,7 +455,7 @@ class Steam
|
|||||||
}
|
}
|
||||||
|
|
||||||
// either way, the balance is always combined with the virtual balance:
|
// 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) {
|
if ($convertToPrimary) {
|
||||||
// the primary currency balance is combined with a converted virtual_balance:
|
// the primary currency balance is combined with a converted virtual_balance:
|
||||||
@@ -465,7 +469,7 @@ class Steam
|
|||||||
$return['balance'] = bcadd($return['balance'], $virtualBalance);
|
$return['balance'] = bcadd($return['balance'], $virtualBalance);
|
||||||
// Log::debug(sprintf('Virtual balance makes the (primary currency) total %s', $return['balance']));
|
// 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);
|
// Log::debug('Final balance is', $final);
|
||||||
$cache->store($final);
|
$cache->store($final);
|
||||||
|
|
||||||
@@ -474,8 +478,8 @@ class Steam
|
|||||||
|
|
||||||
public function getAccountCurrency(Account $account): ?TransactionCurrency
|
public function getAccountCurrency(Account $account): ?TransactionCurrency
|
||||||
{
|
{
|
||||||
$type = $account->accountType->type;
|
$type = $account->accountType->type;
|
||||||
$list = config('firefly.valid_currency_account_types');
|
$list = config('firefly.valid_currency_account_types');
|
||||||
|
|
||||||
// return null if not in this list.
|
// return null if not in this list.
|
||||||
if (!in_array($type, $list, true)) {
|
if (!in_array($type, $list, true)) {
|
||||||
@@ -515,12 +519,12 @@ class Steam
|
|||||||
if (null === $preference) {
|
if (null === $preference) {
|
||||||
$singleton->setPreference($key, $currency);
|
$singleton->setPreference($key, $currency);
|
||||||
}
|
}
|
||||||
$current = $amount;
|
$current = $amount;
|
||||||
if ($currency->id !== $primary->id) {
|
if ($currency->id !== $primary->id) {
|
||||||
$current = $converter->convert($currency, $primary, $date, $amount);
|
$current = $converter->convert($currency, $primary, $date, $amount);
|
||||||
Log::debug(sprintf('Convert %s %s to %s %s', $currency->code, $amount, $primary->code, $current));
|
Log::debug(sprintf('Convert %s %s to %s %s', $currency->code, $amount, $primary->code, $current));
|
||||||
}
|
}
|
||||||
$total = bcadd($current, $total);
|
$total = bcadd($current, $total);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $total;
|
return $total;
|
||||||
@@ -551,15 +555,15 @@ class Steam
|
|||||||
{
|
{
|
||||||
$list = [];
|
$list = [];
|
||||||
|
|
||||||
$set = auth()->user()->transactions()
|
$set = auth()->user()->transactions()
|
||||||
->whereIn('transactions.account_id', $accounts)
|
->whereIn('transactions.account_id', $accounts)
|
||||||
->groupBy(['transactions.account_id', 'transaction_journals.user_id'])
|
->groupBy(['transactions.account_id', 'transaction_journals.user_id'])
|
||||||
->get(['transactions.account_id', DB::raw('MAX(transaction_journals.date) AS max_date')]) // @phpstan-ignore-line
|
->get(['transactions.account_id', DB::raw('MAX(transaction_journals.date) AS max_date')]) // @phpstan-ignore-line
|
||||||
;
|
;
|
||||||
|
|
||||||
/** @var Transaction $entry */
|
/** @var Transaction $entry */
|
||||||
foreach ($set as $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'));
|
$date->setTimezone(config('app.timezone'));
|
||||||
$list[(int)$entry->account_id] = $date;
|
$list[(int)$entry->account_id] = $date;
|
||||||
}
|
}
|
||||||
@@ -634,9 +638,9 @@ class Steam
|
|||||||
public function getSafeUrl(string $unknownUrl, string $safeUrl): string
|
public function getSafeUrl(string $unknownUrl, string $safeUrl): string
|
||||||
{
|
{
|
||||||
// Log::debug(sprintf('getSafeUrl(%s, %s)', $unknownUrl, $safeUrl));
|
// Log::debug(sprintf('getSafeUrl(%s, %s)', $unknownUrl, $safeUrl));
|
||||||
$returnUrl = $safeUrl;
|
$returnUrl = $safeUrl;
|
||||||
$unknownHost = parse_url($unknownUrl, PHP_URL_HOST);
|
$unknownHost = parse_url($unknownUrl, PHP_URL_HOST);
|
||||||
$safeHost = parse_url($safeUrl, PHP_URL_HOST);
|
$safeHost = parse_url($safeUrl, PHP_URL_HOST);
|
||||||
|
|
||||||
if (null !== $unknownHost && $unknownHost === $safeHost) {
|
if (null !== $unknownHost && $unknownHost === $safeHost) {
|
||||||
$returnUrl = $unknownUrl;
|
$returnUrl = $unknownUrl;
|
||||||
@@ -673,7 +677,7 @@ class Steam
|
|||||||
*/
|
*/
|
||||||
public function floatalize(string $value): string
|
public function floatalize(string $value): string
|
||||||
{
|
{
|
||||||
$value = strtoupper($value);
|
$value = strtoupper($value);
|
||||||
if (!str_contains($value, 'E')) {
|
if (!str_contains($value, 'E')) {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
@@ -760,8 +764,8 @@ class Steam
|
|||||||
$primary = Amount::getPrimaryCurrency();
|
$primary = Amount::getPrimaryCurrency();
|
||||||
$currencies[$primary->id] = $primary;
|
$currencies[$primary->id] = $primary;
|
||||||
|
|
||||||
$ids = $accounts->pluck('id')->toArray();
|
$ids = $accounts->pluck('id')->toArray();
|
||||||
$result = AccountMeta::whereIn('account_id', $ids)->where('name', 'currency_id')->get();
|
$result = AccountMeta::whereIn('account_id', $ids)->where('name', 'currency_id')->get();
|
||||||
|
|
||||||
/** @var AccountMeta $item */
|
/** @var AccountMeta $item */
|
||||||
foreach ($result as $item) {
|
foreach ($result as $item) {
|
||||||
@@ -771,7 +775,7 @@ class Steam
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// collect those currencies, skip primary because we already have it.
|
// 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) {
|
foreach ($set as $item) {
|
||||||
$currencies[$item->id] = $item;
|
$currencies[$item->id] = $item;
|
||||||
}
|
}
|
||||||
@@ -782,7 +786,7 @@ class Steam
|
|||||||
$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) {
|
if ($currencyPresent) {
|
||||||
$currencyId = $account->meta['currency']->id;
|
$currencyId = $account->meta['currency']->id;
|
||||||
$currencies[$currencyId] ??= $account->meta['currency'];
|
$currencies[$currencyId] ??= $account->meta['currency'];
|
||||||
$accountCurrencies[$accountId] = $account->meta['currency'];
|
$accountCurrencies[$accountId] = $account->meta['currency'];
|
||||||
}
|
}
|
||||||
if (!$currencyPresent && !array_key_exists($accountId, $accountPreferences)) {
|
if (!$currencyPresent && !array_key_exists($accountId, $accountPreferences)) {
|
||||||
|
@@ -79,7 +79,7 @@ return [
|
|||||||
// see cer.php for exchange rates feature flag.
|
// see cer.php for exchange rates feature flag.
|
||||||
],
|
],
|
||||||
'version' => 'develop/2025-08-10',
|
'version' => 'develop/2025-08-10',
|
||||||
'build_time' => 1754800876,
|
'build_time' => 1754802049,
|
||||||
'api_version' => '2.1.0', // field is no longer used.
|
'api_version' => '2.1.0', // field is no longer used.
|
||||||
'db_version' => 26,
|
'db_version' => 26,
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user