diff --git a/app/Http/Requests/Payment/StorePaymentRequest.php b/app/Http/Requests/Payment/StorePaymentRequest.php index 056e92515c..9a29fd955b 100644 --- a/app/Http/Requests/Payment/StorePaymentRequest.php +++ b/app/Http/Requests/Payment/StorePaymentRequest.php @@ -43,7 +43,7 @@ class StorePaymentRequest extends Request $invoices_total = 0; $credits_total = 0; - if (isset($input['client_id'])) { + if (isset($input['client_id']) && is_string($input['client_id']) ) { $input['client_id'] = $this->decodePrimaryKey($input['client_id']); } @@ -53,7 +53,9 @@ class StorePaymentRequest extends Request if (isset($input['invoices']) && is_array($input['invoices']) !== false) { foreach ($input['invoices'] as $key => $value) { - $input['invoices'][$key]['invoice_id'] = $this->decodePrimaryKey($value['invoice_id']); + + if(is_string($value['invoice_id'])) + $input['invoices'][$key]['invoice_id'] = $this->decodePrimaryKey($value['invoice_id']); if (array_key_exists('amount', $value)) { $invoices_total += $value['amount']; @@ -97,7 +99,8 @@ class StorePaymentRequest extends Request { $rules = [ 'amount' => ['numeric', 'bail', new PaymentAmountsBalanceRule(), new ValidCreditsPresentRule($this->all())], - 'client_id' => 'bail|required|exists:clients,id', + // 'client_id' => 'bail|required|exists:clients,id', + 'client_id' => 'bail|required|exists:clients,id,company_id,'.auth()->user()->company()->id.',is_deleted,0', 'invoices.*.invoice_id' => 'bail|required|distinct|exists:invoices,id', 'invoices.*.amount' => 'bail|required', 'invoices.*.invoice_id' => new ValidInvoicesRules($this->all()), diff --git a/app/Import/Transformer/BaseTransformer.php b/app/Import/Transformer/BaseTransformer.php index 211a6b52e6..4e755a1408 100644 --- a/app/Import/Transformer/BaseTransformer.php +++ b/app/Import/Transformer/BaseTransformer.php @@ -85,7 +85,9 @@ class BaseTransformer $client_name_search = Client::where('company_id', $this->company->id) ->where('is_deleted', false) - ->where('name', $client_name); + ->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [ + strtolower(str_replace(' ', '', $client_name)), + ]); if ($client_name_search->count() >= 1) { return $client_name_search->first()->id;