mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-12 22:22:32 +01:00
Validation for custom date ranges
This commit is contained in:
parent
70248be9ad
commit
c8a6cee026
@ -40,8 +40,9 @@ class StoreSchedulerRequest extends Request
|
||||
'template' => 'bail|required|string',
|
||||
'parameters' => 'bail|array',
|
||||
'parameters.clients' => ['bail','sometimes', 'array', new ValidClientIds()],
|
||||
'parameters.start_date' => ['bail', 'sometimes', 'date'],
|
||||
'parameters.end_date' => ['bail', 'sometimes', 'date', 'after_or_equal:parameters.start_date'],
|
||||
'parameters.date_date' => 'bail, sometimes, string, in:last7_days,last30_days,last365_days,this_month,last_month,this_quarter,last_quarter,this_year,last_year,custom',
|
||||
'parameters.start_date' => ['bail', 'sometimes', 'date', 'required_if:parameters.date_rate,custom'],
|
||||
'parameters.end_date' => ['bail', 'sometimes', 'date', 'required_if:parameters.date_rate,custom', 'after_or_equal:parameters.start_date'],
|
||||
];
|
||||
|
||||
return $rules;
|
||||
|
@ -129,8 +129,6 @@ class SchedulerTest extends TestCase
|
||||
|
||||
$response->assertStatus(422);
|
||||
|
||||
|
||||
|
||||
$data = [
|
||||
'name' => 'A test statement scheduler',
|
||||
'frequency_id' => RecurringInvoice::FREQUENCY_MONTHLY,
|
||||
@ -154,6 +152,31 @@ class SchedulerTest extends TestCase
|
||||
|
||||
$response->assertStatus(422);
|
||||
|
||||
|
||||
|
||||
$data = [
|
||||
'name' => 'A test statement scheduler',
|
||||
'frequency_id' => RecurringInvoice::FREQUENCY_MONTHLY,
|
||||
'next_run' => now()->format('Y-m-d'),
|
||||
'template' => 'client_statement',
|
||||
'parameters' => [
|
||||
'date_range' => EmailStatement::CUSTOM_RANGE,
|
||||
'show_payments_table' => true,
|
||||
'show_aging_table' => true,
|
||||
'status' => 'paid',
|
||||
'clients' => [],
|
||||
'start_date' => '',
|
||||
'end_date' => ''
|
||||
],
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->postJson('/api/v1/task_schedulers', $data);
|
||||
|
||||
$response->assertStatus(422);
|
||||
|
||||
}
|
||||
|
||||
public function testClientCountResolution()
|
||||
|
Loading…
Reference in New Issue
Block a user