mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Update validation rules
This commit is contained in:
parent
7019cb1779
commit
023de23a45
@ -19,6 +19,7 @@ use App\Factory\CloneInvoiceToQuoteFactory;
|
||||
use App\Factory\InvoiceFactory;
|
||||
use App\Filters\InvoiceFilters;
|
||||
use App\Http\Requests\Invoice\ActionInvoiceRequest;
|
||||
use App\Http\Requests\Invoice\BulkInvoiceRequest;
|
||||
use App\Http\Requests\Invoice\CreateInvoiceRequest;
|
||||
use App\Http\Requests\Invoice\DestroyInvoiceRequest;
|
||||
use App\Http\Requests\Invoice\EditInvoiceRequest;
|
||||
@ -546,11 +547,11 @@ class InvoiceController extends BaseController
|
||||
* ),
|
||||
* )
|
||||
*/
|
||||
public function bulk()
|
||||
public function bulk(BulkInvoiceRequest $request)
|
||||
{
|
||||
$action = request()->input('action');
|
||||
$action = $request->input('action');
|
||||
|
||||
$ids = request()->input('ids');
|
||||
$ids = $request->input('ids');
|
||||
|
||||
if(Ninja::isHosted() && (stripos($action, 'email') !== false) && !auth()->user()->company()->account->account_sms_verified)
|
||||
return response(['message' => 'Please verify your account to send emails.'], 400);
|
||||
|
@ -59,7 +59,13 @@ class StoreCreditRequest extends Request
|
||||
$rules['number'] = ['nullable', Rule::unique('credits')->where('company_id', auth()->user()->company()->id)];
|
||||
$rules['discount'] = 'sometimes|numeric';
|
||||
$rules['is_amount_discount'] = ['boolean'];
|
||||
|
||||
$rules['tax_rate1'] = 'bail|sometimes|numeric';
|
||||
$rules['tax_rate2'] = 'bail|sometimes|numeric';
|
||||
$rules['tax_rate3'] = 'bail|sometimes|numeric';
|
||||
$rules['tax_name1'] = 'bail|sometimes|string|nullable';
|
||||
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
||||
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
||||
|
||||
if ($this->invoice_id) {
|
||||
$rules['invoice_id'] = new ValidInvoiceCreditRule();
|
||||
}
|
||||
|
@ -59,7 +59,13 @@ class UpdateCreditRequest extends Request
|
||||
$rules['line_items'] = 'array';
|
||||
$rules['discount'] = 'sometimes|numeric';
|
||||
$rules['is_amount_discount'] = ['boolean'];
|
||||
|
||||
$rules['tax_rate1'] = 'bail|sometimes|numeric';
|
||||
$rules['tax_rate2'] = 'bail|sometimes|numeric';
|
||||
$rules['tax_rate3'] = 'bail|sometimes|numeric';
|
||||
$rules['tax_name1'] = 'bail|sometimes|string|nullable';
|
||||
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
||||
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
@ -70,4 +70,4 @@ class ActionInvoiceRequest extends Request
|
||||
'action' => $this->error_msg,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
@ -69,7 +69,13 @@ class StoreInvoiceRequest extends Request
|
||||
|
||||
$rules['line_items'] = 'array';
|
||||
$rules['discount'] = 'sometimes|numeric';
|
||||
|
||||
$rules['tax_rate1'] = 'bail|sometimes|numeric';
|
||||
$rules['tax_rate2'] = 'bail|sometimes|numeric';
|
||||
$rules['tax_rate3'] = 'bail|sometimes|numeric';
|
||||
$rules['tax_name1'] = 'bail|sometimes|string|nullable';
|
||||
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
||||
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,12 @@ class UpdateInvoiceRequest extends Request
|
||||
$rules['line_items'] = 'array';
|
||||
$rules['discount'] = 'sometimes|numeric';
|
||||
$rules['project_id'] = ['bail', 'sometimes', new ValidProjectForClient($this->all())];
|
||||
$rules['tax_rate1'] = 'bail|sometimes|numeric';
|
||||
$rules['tax_rate2'] = 'bail|sometimes|numeric';
|
||||
$rules['tax_rate3'] = 'bail|sometimes|numeric';
|
||||
$rules['tax_name1'] = 'bail|sometimes|string|nullable';
|
||||
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
||||
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
@ -58,7 +58,14 @@ class StoreRecurringInvoiceRequest extends Request
|
||||
$rules['project_id'] = ['bail', 'sometimes', new ValidProjectForClient($this->all())];
|
||||
|
||||
$rules['number'] = new UniqueRecurringInvoiceNumberRule($this->all());
|
||||
|
||||
|
||||
$rules['tax_rate1'] = 'bail|sometimes|numeric';
|
||||
$rules['tax_rate2'] = 'bail|sometimes|numeric';
|
||||
$rules['tax_rate3'] = 'bail|sometimes|numeric';
|
||||
$rules['tax_name1'] = 'bail|sometimes|string|nullable';
|
||||
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
||||
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,13 @@ class UpdateRecurringInvoiceRequest extends Request
|
||||
}
|
||||
|
||||
$rules['project_id'] = ['bail', 'sometimes', new ValidProjectForClient($this->all())];
|
||||
|
||||
$rules['tax_rate1'] = 'bail|sometimes|numeric';
|
||||
$rules['tax_rate2'] = 'bail|sometimes|numeric';
|
||||
$rules['tax_rate3'] = 'bail|sometimes|numeric';
|
||||
$rules['tax_name1'] = 'bail|sometimes|string|nullable';
|
||||
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
||||
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
@ -63,16 +63,6 @@ class UpdateInvoicePayment
|
||||
}
|
||||
|
||||
$client->service()->updateBalanceAndPaidToDate($paid_amount*-1, $paid_amount);
|
||||
|
||||
// \DB::connection(config('database.default'))->transaction(function () use($client, $paid_amount){
|
||||
|
||||
// $update_client = Client::withTrashed()->where('id', $client->id)->lockForUpdate()->first();
|
||||
|
||||
// $update_client->paid_to_date += $paid_amount;
|
||||
// $update_client->balance -= $paid_amount;
|
||||
// $update_client->save();
|
||||
|
||||
// }, 1);
|
||||
|
||||
/* Need to determine here is we have an OVER payment - if YES only apply the max invoice amount */
|
||||
if($paid_amount > $invoice->partial && $paid_amount > $invoice->balance)
|
||||
@ -86,8 +76,6 @@ class UpdateInvoicePayment
|
||||
|
||||
$invoice = $invoice->service()
|
||||
->clearPartial()
|
||||
// ->updateBalance($paid_amount * -1)
|
||||
// ->updatePaidToDate($paid_amount)
|
||||
->updateStatus()
|
||||
->touchPdf()
|
||||
->save();
|
||||
|
Loading…
x
Reference in New Issue
Block a user