Skip to content

Firefly III: a personal finances manager

Fix https://github.com/firefly-iii/firefly-iii/issues/9723

James Cole695bb3189493
diff --git a/app/Handlers/Events/PreferencesEventHandler.php b/app/Handlers/Events/PreferencesEventHandler.php
index a18dcc75f7..dc1d124aa5 100644
--- a/app/Handlers/Events/PreferencesEventHandler.php
+++ b/app/Handlers/Events/PreferencesEventHandler.php
@@ -61,8 +61,11 @@ class PreferencesEventHandler
$this->resetTransactions($event->userGroup);
// fire laravel command to recalculate them all.
if (Amount::convertToNative()) {
+ Log::debug('Will now convert to native.');
Artisan::call('correction:recalculate-native-amounts');
+ return;
}
+ Log::debug('Will NOT convert to native.');
}
private function resetPiggyBanks(UserGroup $userGroup): void
diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php
index ee7872be93..bf8b12af22 100644
--- a/app/Http/Controllers/PreferencesController.php
+++ b/app/Http/Controllers/PreferencesController.php
@@ -264,6 +264,7 @@ class PreferencesController extends Controller
if ($convertToNative && !$this->convertToNative) {
// set to true!
Log::debug('User sets convertToNative to true.');
+ Preferences::set('convert_to_native', $convertToNative);
event(new UserGroupChangedDefaultCurrency(auth()->user()->userGroup));
}
Preferences::set('convert_to_native', $convertToNative);
diff --git a/app/Support/Http/Controllers/PeriodOverview.php b/app/Support/Http/Controllers/PeriodOverview.php
index f9b54c09a7..baad36e7f9 100644
--- a/app/Support/Http/Controllers/PeriodOverview.php
+++ b/app/Support/Http/Controllers/PeriodOverview.php
@@ -203,11 +203,11 @@ trait PeriodOverview
$currencySymbol = $journal['currency_symbol'];
$currencyDecimalPlaces = $journal['currency_decimal_places'];
$foreignCurrencyId = $journal['foreign_currency_id'];
- $amount = $journal['amount'];
+ $amount = $journal['amount'] ?? '0';
if ($this->convertToNative && $currencyId !== $this->defaultCurrency->id && $foreignCurrencyId !== $this->defaultCurrency->id) {
- $amount = $journal['native_amount'];
+ $amount = $journal['native_amount'] ?? '0';
$currencyId = $this->defaultCurrency->id;
$currencyCode = $this->defaultCurrency->code;
$currencyName = $this->defaultCurrency->name;
@@ -220,7 +220,7 @@ trait PeriodOverview
$currencyName = $journal['foreign_currency_name'];
$currencySymbol = $journal['foreign_currency_symbol'];
$currencyDecimalPlaces = $journal['foreign_currency_decimal_places'];
- $amount = $journal['foreign_amount'];
+ $amount = $journal['foreign_amount'] ?? '0';
}
$return[$currencyId] ??= [
'amount' => '0',