mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -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)) {
|
if ($this->repository->currencyInUse($currency)) {
|
||||||
throw new FireflyException('200006: Currency in use.'); // @codeCoverageIgnore
|
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);
|
$this->repository->destroy($currency);
|
||||||
|
|
||||||
return response()->json([], 204);
|
return response()->json([], 204);
|
||||||
|
@ -183,6 +183,14 @@ class CurrencyController extends Controller
|
|||||||
|
|
||||||
return redirect(route('currencies.index'));
|
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));
|
Log::channel('audit')->info(sprintf('Deleted currency %s.', $currency->code));
|
||||||
$this->repository->destroy($currency);
|
$this->repository->destroy($currency);
|
||||||
|
|
||||||
|
@ -537,4 +537,12 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
|||||||
|
|
||||||
return $service->update($currency, $data);
|
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
|
interface CurrencyRepositoryInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TransactionCurrency $currency
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isFallbackCurrency(TransactionCurrency $currency): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TransactionCurrency $currency
|
* @param TransactionCurrency $currency
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user