mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Fixes for client store request
This commit is contained in:
parent
c28bf391fb
commit
e844abf27d
@ -90,8 +90,6 @@ class StoreClientRequest extends Request
|
|||||||
{
|
{
|
||||||
$input = $this->all();
|
$input = $this->all();
|
||||||
|
|
||||||
//@todo implement feature permissions for > 50 clients
|
|
||||||
|
|
||||||
$settings = ClientSettings::defaults();
|
$settings = ClientSettings::defaults();
|
||||||
|
|
||||||
if (array_key_exists('settings', $input) && ! empty($input['settings'])) {
|
if (array_key_exists('settings', $input) && ! empty($input['settings'])) {
|
||||||
@ -133,6 +131,10 @@ class StoreClientRequest extends Request
|
|||||||
$input['shipping_country_id'] = $this->getCountryCode($input['shipping_country_code']);
|
$input['shipping_country_id'] = $this->getCountryCode($input['shipping_country_code']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If there is no number, just unset it here. */
|
||||||
|
if(array_key_exists('number', $input) && ( is_null($input['number']) || empty($input['number'])))
|
||||||
|
unset($input['number']);
|
||||||
|
|
||||||
$this->replace($input);
|
$this->replace($input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,8 +36,6 @@ trait GeneratesCounter
|
|||||||
//todo in the form validation, we need to ensure that if a prefix and pattern is set we throw a validation error,
|
//todo in the form validation, we need to ensure that if a prefix and pattern is set we throw a validation error,
|
||||||
//only one type is allow else this will cause confusion to the end user
|
//only one type is allow else this will cause confusion to the end user
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private function getNextEntityNumber($entity, Client $client, $is_recurring = false)
|
private function getNextEntityNumber($entity, Client $client, $is_recurring = false)
|
||||||
{
|
{
|
||||||
$prefix = '';
|
$prefix = '';
|
||||||
|
@ -68,6 +68,56 @@ class ClientApiTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testClientNoneValidation()
|
||||||
|
{
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'name' => $this->faker->firstName,
|
||||||
|
'number' => '',
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = false;
|
||||||
|
|
||||||
|
try{
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->post('/api/v1/clients/', $data);
|
||||||
|
} catch (ValidationException $e) {
|
||||||
|
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
|
nlog($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testClientNullValidation()
|
||||||
|
{
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'name' => $this->faker->firstName,
|
||||||
|
'number' => null,
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = false;
|
||||||
|
|
||||||
|
try{
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->post('/api/v1/clients/', $data);
|
||||||
|
} catch (ValidationException $e) {
|
||||||
|
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
|
nlog($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testClientCountryCodeValidationTrueIso3()
|
public function testClientCountryCodeValidationTrueIso3()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user