Respond to currency changes.

This commit is contained in:
James Cole
2024-12-21 07:12:11 +01:00
parent 7fd5a88122
commit b52a1f3eb1
15 changed files with 234 additions and 45 deletions

View File

@@ -48,7 +48,10 @@ class PiggyBankObserver
private function updateNativeAmount(PiggyBank $piggyBank): void
{
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($piggyBank->accounts()->first()->user->userGroup);
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($piggyBank->accounts()->first()?->user->userGroup);
if(null === $userCurrency) {
return;
}
$piggyBank->native_target_amount = null;
if ($piggyBank->transactionCurrency->id !== $userCurrency->id) {
$converter = new ExchangeRateConverter();