Always ensure the client has a currency set

This commit is contained in:
David Bomba 2021-01-06 19:50:13 +11:00
parent 47f42b804d
commit 65afd70b38
3 changed files with 7 additions and 2 deletions

View File

@ -108,7 +108,7 @@ class PaymentController extends Controller
$settings = auth()->user()->client->getMergedSettings(); $settings = auth()->user()->client->getMergedSettings();
//nlog($settings); nlog($settings);
/* This loop checks for under / over payments and returns the user if a check fails */ /* This loop checks for under / over payments and returns the user if a check fails */

View File

@ -90,6 +90,11 @@ class UpdateClientRequest extends Request
$input['group_settings_id'] = $this->decodePrimaryKey($input['group_settings_id']); $input['group_settings_id'] = $this->decodePrimaryKey($input['group_settings_id']);
} }
/* If the user removes the currency we must always set the default */
if (array_key_exists('settings', $input) && ! array_key_exists('currency_id', $input['settings'])) {
$input['settings']['currency_id'] = (string) auth()->user()->company()->settings->currency_id;
}
$input = $this->decodePrimaryKeys($input); $input = $this->decodePrimaryKeys($input);
if (array_key_exists('settings', $input)) { if (array_key_exists('settings', $input)) {

View File

@ -57,7 +57,7 @@ class UpdateCompanyRequest extends Request
protected function prepareForValidation() protected function prepareForValidation()
{ {
$input = $this->all(); $input = $this->all();
// nlog($input);
if (array_key_exists('settings', $input)) { if (array_key_exists('settings', $input)) {
$input['settings'] = $this->filterSaveableSettings($input['settings']); $input['settings'] = $this->filterSaveableSettings($input['settings']);
} }