mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-20 11:48:27 -06:00
Fix issue with budgets.
This commit is contained in:
parent
2c0d8b9cb3
commit
144bc29eb3
@ -236,6 +236,7 @@ class IndexController extends Controller
|
||||
$repository->setBudgetOrder($budget, $index + 1);
|
||||
}
|
||||
}
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json(['OK']);
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
{
|
||||
/** @var Collection $set */
|
||||
$set = $this->user->budgets()->where('active', 1)
|
||||
->orderBy('order', 'ASC')
|
||||
->orderBy('order', 'DESC')
|
||||
->orderBy('name', 'ASC')
|
||||
->get();
|
||||
|
||||
|
@ -25,11 +25,9 @@ namespace FireflyIII\Support;
|
||||
use Crypt;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Preferences as Prefs;
|
||||
|
||||
/**
|
||||
* Class Amount.
|
||||
@ -204,7 +202,7 @@ class Amount
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
$currencyPreference = Prefs::get('currencyPreference', config('firefly.default_currency', 'EUR'));
|
||||
$currencyPreference = app('preferences')->get('currencyPreference', config('firefly.default_currency', 'EUR'));
|
||||
|
||||
$currency = TransactionCurrency::where('code', $currencyPreference->data)->first();
|
||||
if ($currency) {
|
||||
@ -230,7 +228,7 @@ class Amount
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
$currencyPreference = Prefs::get('currencyPreference', config('firefly.default_currency', 'EUR'));
|
||||
$currencyPreference = app('preferences')->get('currencyPreference', config('firefly.default_currency', 'EUR'));
|
||||
$currency = TransactionCurrency::where('code', $currencyPreference->data)->first();
|
||||
|
||||
$cache->store($currency->symbol);
|
||||
@ -252,6 +250,18 @@ class Amount
|
||||
return $this->getDefaultCurrencyByUser($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \FireflyIII\Models\TransactionCurrency
|
||||
*/
|
||||
public function getSystemCurrency(): TransactionCurrency
|
||||
{
|
||||
if ('testing' === config('app.env')) {
|
||||
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
|
||||
}
|
||||
|
||||
return TransactionCurrency::where('code', 'EUR')->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*
|
||||
@ -268,17 +278,18 @@ class Amount
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
$currencyPreference = Prefs::getForUser($user, 'currencyPreference', config('firefly.default_currency', 'EUR'));
|
||||
$currencyPreference = app('preferences')->getForUser($user, 'currencyPreference', config('firefly.default_currency', 'EUR'));
|
||||
$currencyPrefStr = $currencyPreference ? $currencyPreference->data : 'EUR';
|
||||
|
||||
// at this point the currency preference could be encrypted, if coming from an old version.
|
||||
Log::debug('Going to try to decrypt users currency preference.');
|
||||
$currencyCode = $this->tryDecrypt((string)$currencyPreference->data);
|
||||
$currencyCode = $this->tryDecrypt((string) $currencyPrefStr);
|
||||
|
||||
// could still be json encoded:
|
||||
if (strlen($currencyCode) > 3) {
|
||||
$currencyCode = json_decode($currencyCode, true) ?? 'EUR';
|
||||
$currencyCode = json_decode($currencyCode, true, 512, JSON_THROW_ON_ERROR) ?? 'EUR';
|
||||
}
|
||||
|
||||
/** @var TransactionCurrency $currency */
|
||||
$currency = TransactionCurrency::where('code', $currencyCode)->first();
|
||||
if (null === $currency) {
|
||||
// get EUR
|
||||
|
Loading…
Reference in New Issue
Block a user