Additional validation rules on bulk requests
This commit is contained in:
parent
dceee1adbc
commit
b151f46211
|
|
@ -45,9 +45,10 @@ class BulkInvoiceRequest extends Request
|
||||||
throw new DuplicatePaymentException('Action still processing, please wait. ', 429);
|
throw new DuplicatePaymentException('Action still processing, please wait. ', 429);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($this->input('ids', false)){
|
||||||
$delay = $this->input('action', 'delete') == 'delete' ? (min(count($this->input('ids', 2)), 3)) : 1;
|
$delay = $this->input('action', 'delete') == 'delete' ? (min(count($this->input('ids', 2)), 3)) : 1;
|
||||||
\Illuminate\Support\Facades\Cache::put(($this->ip()."|".$this->input('action', 0)."|".$user->company()->company_key), true, $delay);
|
\Illuminate\Support\Facades\Cache::put(($this->ip()."|".$this->input('action', 0)."|".$user->company()->company_key), true, $delay);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,22 @@ class InvoiceTest extends TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testBulkInvoiceValidationRequestFailsWithMissingIds()
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'action' => 'archive',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->postJson('/api/v1/invoices/bulk', $data);
|
||||||
|
|
||||||
|
$response->assertStatus(422);
|
||||||
|
$response->assertJsonValidationErrors('ids');
|
||||||
|
|
||||||
|
}
|
||||||
public function testInvoiceItemRoundingWithDiscountIsPercent()
|
public function testInvoiceItemRoundingWithDiscountIsPercent()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue