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

Validation for custom date ranges

This commit is contained in:
David Bomba 2023-02-20 15:30:09 +11:00
parent 70248be9ad
commit c8a6cee026
2 changed files with 28 additions and 4 deletions

View File

@ -40,8 +40,9 @@ class StoreSchedulerRequest extends Request
'template' => 'bail|required|string', 'template' => 'bail|required|string',
'parameters' => 'bail|array', 'parameters' => 'bail|array',
'parameters.clients' => ['bail','sometimes', 'array', new ValidClientIds()], 'parameters.clients' => ['bail','sometimes', 'array', new ValidClientIds()],
'parameters.start_date' => ['bail', 'sometimes', '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.end_date' => ['bail', 'sometimes', 'date', 'after_or_equal:parameters.start_date'], '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; return $rules;

View File

@ -129,8 +129,6 @@ class SchedulerTest extends TestCase
$response->assertStatus(422); $response->assertStatus(422);
$data = [ $data = [
'name' => 'A test statement scheduler', 'name' => 'A test statement scheduler',
'frequency_id' => RecurringInvoice::FREQUENCY_MONTHLY, 'frequency_id' => RecurringInvoice::FREQUENCY_MONTHLY,
@ -154,6 +152,31 @@ class SchedulerTest extends TestCase
$response->assertStatus(422); $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() public function testClientCountResolution()