1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Fixes for store payment request

This commit is contained in:
David Bomba 2022-09-06 13:38:54 +10:00
parent 8dbc70d277
commit 4b0b32ed5b
2 changed files with 9 additions and 4 deletions

View File

@ -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()),

View File

@ -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;