diff --git a/app/Jobs/Setting/DeleteCurrency.php b/app/Jobs/Setting/DeleteCurrency.php index 0c0c56cc9..7ea36011f 100644 --- a/app/Jobs/Setting/DeleteCurrency.php +++ b/app/Jobs/Setting/DeleteCurrency.php @@ -56,6 +56,12 @@ class DeleteCurrency extends Job 'transactions' => 'transactions', ]; - return $this->countRelationships($this->currency, $rels); + $relationships = $this->countRelationships($this->currency, $rels); + + if ($this->currency->code == setting('default.currency')) { + $relationships[] = strtolower(trans_choice('general.companies', 1)); + } + + return $relationships; } } diff --git a/app/Jobs/Setting/UpdateCurrency.php b/app/Jobs/Setting/UpdateCurrency.php index 056283299..b11410436 100644 --- a/app/Jobs/Setting/UpdateCurrency.php +++ b/app/Jobs/Setting/UpdateCurrency.php @@ -32,8 +32,19 @@ class UpdateCurrency extends Job { $this->authorize(); + // Force the rate to be 1 for default currency + if ($this->request->get('default_currency')) { + $this->request['rate'] = '1'; + } + $this->currency->update($this->request->all()); + // Update default currency setting + if ($this->request->get('default_currency')) { + setting()->set('default.currency', $this->request->get('code')); + setting()->save(); + } + return $this->currency; }