From 65afd70b3860307027d36366198f7f5e24968950 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 6 Jan 2021 19:50:13 +1100 Subject: [PATCH] Always ensure the client has a currency set --- app/Http/Controllers/ClientPortal/PaymentController.php | 2 +- app/Http/Requests/Client/UpdateClientRequest.php | 5 +++++ app/Http/Requests/Company/UpdateCompanyRequest.php | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index a0d6d494da13..b5f0b9c9d39a 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -108,7 +108,7 @@ class PaymentController extends Controller $settings = auth()->user()->client->getMergedSettings(); - //nlog($settings); + nlog($settings); /* This loop checks for under / over payments and returns the user if a check fails */ diff --git a/app/Http/Requests/Client/UpdateClientRequest.php b/app/Http/Requests/Client/UpdateClientRequest.php index 6e7919b7e046..770d90914363 100644 --- a/app/Http/Requests/Client/UpdateClientRequest.php +++ b/app/Http/Requests/Client/UpdateClientRequest.php @@ -90,6 +90,11 @@ class UpdateClientRequest extends Request $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); if (array_key_exists('settings', $input)) { diff --git a/app/Http/Requests/Company/UpdateCompanyRequest.php b/app/Http/Requests/Company/UpdateCompanyRequest.php index 505711533c31..cca073724822 100644 --- a/app/Http/Requests/Company/UpdateCompanyRequest.php +++ b/app/Http/Requests/Company/UpdateCompanyRequest.php @@ -57,7 +57,7 @@ class UpdateCompanyRequest extends Request protected function prepareForValidation() { $input = $this->all(); - +// nlog($input); if (array_key_exists('settings', $input)) { $input['settings'] = $this->filterSaveableSettings($input['settings']); }