mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-25 16:31:15 -06:00
Fix #3118
This commit is contained in:
parent
8d806e6a1d
commit
529cb3d387
@ -318,6 +318,10 @@ class CurrencyController extends Controller
|
||||
if ($this->repository->currencyInUse($currency)) {
|
||||
throw new FireflyException('200006: Currency in use.'); // @codeCoverageIgnore
|
||||
}
|
||||
if ($this->repository->isFallbackCurrency($currency)) {
|
||||
throw new FireflyException('200026: Currency is fallback.'); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$this->repository->destroy($currency);
|
||||
|
||||
return response()->json([], 204);
|
||||
|
@ -183,6 +183,14 @@ class CurrencyController extends Controller
|
||||
|
||||
return redirect(route('currencies.index'));
|
||||
}
|
||||
|
||||
if ($this->repository->isFallbackCurrency($currency)) {
|
||||
$request->session()->flash('error', (string)trans('firefly.cannot_delete_fallback_currency', ['name' => e($currency->name)]));
|
||||
Log::channel('audit')->info(sprintf('Tried to delete currency %s but is FALLBACK.', $currency->code));
|
||||
|
||||
return redirect(route('currencies.index'));
|
||||
}
|
||||
|
||||
Log::channel('audit')->info(sprintf('Deleted currency %s.', $currency->code));
|
||||
$this->repository->destroy($currency);
|
||||
|
||||
|
@ -537,4 +537,12 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
|
||||
return $service->update($currency, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function isFallbackCurrency(TransactionCurrency $currency): bool
|
||||
{
|
||||
return $currency->code === config('firefly.default_currency', 'EUR');
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,14 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
interface CurrencyRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isFallbackCurrency(TransactionCurrency $currency): bool;
|
||||
|
||||
/**
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user