mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Last attempt I hope for #2125
This commit is contained in:
parent
39321b320e
commit
3379b723cf
@ -224,23 +224,6 @@ class Amount
|
||||
return $this->getDefaultCurrencyByUser($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function tryDecrypt(string $value): string
|
||||
{
|
||||
try {
|
||||
$value = Crypt::decrypt($value);
|
||||
} catch (DecryptException $e) {
|
||||
Log::debug(sprintf('Could not decrypt. %s', $e->getMessage()));
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*
|
||||
@ -260,7 +243,13 @@ class Amount
|
||||
|
||||
// at this point the currency preference could be encrypted, if coming from an old version.
|
||||
$currencyCode = $this->tryDecrypt((string)$currencyPreference->data);
|
||||
$currency = TransactionCurrency::where('code', $currencyCode)->first();
|
||||
|
||||
// could still be json encoded:
|
||||
if (\strlen($currencyCode) > 3) {
|
||||
$currencyCode = null === json_decode($currencyCode) ? 'EUR' : $currencyCode;
|
||||
}
|
||||
|
||||
$currency = TransactionCurrency::where('code', $currencyCode)->first();
|
||||
if (null === $currency) {
|
||||
throw new FireflyException(sprintf('No currency found with code "%s"', $currencyCode));
|
||||
}
|
||||
@ -288,4 +277,20 @@ class Amount
|
||||
'zero' => $positive,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function tryDecrypt(string $value): string
|
||||
{
|
||||
try {
|
||||
$value = Crypt::decrypt($value);
|
||||
} catch (DecryptException $e) {
|
||||
Log::debug(sprintf('Could not decrypt. %s', $e->getMessage()));
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user