Inform user on currency disabling and where a currency may still be used. #2432

This commit is contained in:
James Cole
2019-08-18 08:46:36 +02:00
parent 4d2c5c1b58
commit 525f69cf63
4 changed files with 76 additions and 35 deletions

View File

@@ -212,7 +212,11 @@ class CurrencyController extends Controller
}
if ($this->repository->currencyInUse($currency)) {
$request->session()->flash('error', (string)trans('firefly.cannot_disable_currency', ['name' => e($currency->name)]));
$location = $this->repository->currencyInUseAt($currency);
$message = (string)trans(sprintf('firefly.cannot_disable_currency_%s', $location), ['name' => e($currency->name)]);
$request->session()->flash('error', $message);
Log::channel('audit')->info(sprintf('Tried to disable currency %s but is in use.', $currency->code));
return redirect(route('currencies.index'));
@@ -233,6 +237,10 @@ class CurrencyController extends Controller
app('preferences')->mark();
}
if ('EUR' === $currency->code) {
session()->flash('warning', (string)trans('firefly.disable_EUR_side_effects'));
}
session()->flash('success', (string)trans('firefly.currency_is_now_disabled', ['name' => $currency->name]));
return redirect(route('currencies.index'));