diff --git a/app/Http/Controllers/ClientPortal/InvitationController.php b/app/Http/Controllers/ClientPortal/InvitationController.php index 460020db838b..5e89320062f6 100644 --- a/app/Http/Controllers/ClientPortal/InvitationController.php +++ b/app/Http/Controllers/ClientPortal/InvitationController.php @@ -55,10 +55,13 @@ class InvitationController extends Controller /* Return early if we have the correct client_hash embedded */ if (request()->has('client_hash') && request()->input('client_hash') == $invitation->contact->client->client_hash) { + nlog("scenario 1"); auth()->guard('contact')->login($invitation->contact, true); } elseif ((bool) $invitation->contact->client->getSetting('enable_client_portal_password') !== false) { + nlog("scenario 2"); $this->middleware('auth:contact'); } else { + nlog("scenario 3"); auth()->guard('contact')->login($invitation->contact, true); } diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php index 6fce805e8390..b6fa2b9e66cb 100644 --- a/app/Repositories/BaseRepository.php +++ b/app/Repositories/BaseRepository.php @@ -202,10 +202,6 @@ class BaseRepository /* Model now persisted, now lets do some child tasks */ - /* If client currency differs from the company default currency, then insert the client exchange rate on the model.*/ - if($client->currency()->id != (int) $model->company->settings->currency_id) - $model->exchange_rate = $client->currency()->exchange_rate; - /* Save any documents */ if (array_key_exists('documents', $data)) $this->saveDocuments($data['documents'], $model); diff --git a/app/Services/Credit/CreditService.php b/app/Services/Credit/CreditService.php index b7cc91d13888..e2a4b2229525 100644 --- a/app/Services/Credit/CreditService.php +++ b/app/Services/Credit/CreditService.php @@ -102,18 +102,18 @@ class CreditService { $settings = $this->credit->client->getMergedSettings(); - if (! $this->credit->design_id) { + if (! $this->credit->design_id) $this->credit->design_id = $this->decodePrimaryKey($settings->credit_design_id); - } - - if (!isset($this->credit->footer)) { + + if (!isset($this->credit->footer)) $this->credit->footer = $settings->credit_footer; - } - if (!isset($this->credit->terms)) { + if (!isset($this->credit->terms)) $this->credit->terms = $settings->credit_terms; - } + /* If client currency differs from the company default currency, then insert the client exchange rate on the model.*/ + if(!isset($this->credit->exchange_rate) && $this->credit->client->currency()->id != (int) $this->credit->company->settings->currency_id) + $this->credit->exchange_rate = $this->credit->client->currency()->exchange_rate; return $this; } diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 7b9fc1a13b3c..295d15e84f70 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -364,18 +364,19 @@ class InvoiceService { $settings = $this->invoice->client->getMergedSettings(); - if (! $this->invoice->design_id) { + if (! $this->invoice->design_id) $this->invoice->design_id = $this->decodePrimaryKey($settings->invoice_design_id); - } - - if (!isset($this->invoice->footer)) { - $this->invoice->footer = $settings->invoice_footer; - } - - if (!isset($this->invoice->terms)) { - $this->invoice->terms = $settings->invoice_terms; - } + if (!isset($this->invoice->footer)) + $this->invoice->footer = $settings->invoice_footer; + + if (!isset($this->invoice->terms)) + $this->invoice->terms = $settings->invoice_terms; + + /* If client currency differs from the company default currency, then insert the client exchange rate on the model.*/ + if(!isset($this->invoice->exchange_rate) && $this->invoice->client->currency()->id != (int) $this->invoice->company->settings->currency_id) + $this->invoice->exchange_rate = $this->invoice->client->currency()->exchange_rate; + return $this; } diff --git a/app/Services/Quote/QuoteService.php b/app/Services/Quote/QuoteService.php index 92ac2731175a..b8c2195f91fc 100644 --- a/app/Services/Quote/QuoteService.php +++ b/app/Services/Quote/QuoteService.php @@ -159,18 +159,18 @@ class QuoteService { $settings = $this->quote->client->getMergedSettings(); - if (! $this->quote->design_id) { + if (! $this->quote->design_id) $this->quote->design_id = $this->decodePrimaryKey($settings->quote_design_id); - } - if (!isset($this->quote->footer)) { + if (!isset($this->quote->footer)) $this->quote->footer = $settings->quote_footer; - } - - if (!isset($this->quote->terms)) { + + if (!isset($this->quote->terms)) $this->quote->terms = $settings->quote_terms; - } - + + /* If client currency differs from the company default currency, then insert the client exchange rate on the model.*/ + if(!isset($this->quote->exchange_rate) && $this->quote->client->currency()->id != (int) $this->quote->company->settings->currency_id) + $this->quote->exchange_rate = $this->quote->client->currency()->exchange_rate; return $this; }