James Cole 2025-02-01 13:01:13 +01:00
parent f8ded66869
commit 695bb31894
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
3 changed files with 7 additions and 3 deletions

View File

@ -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

View File

@ -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);

View File

@ -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',