mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 00:44:35 -04:00
Fixes for types in settings
This commit is contained in:
parent
0d5ee8269d
commit
cfd9ed4875
@ -30,7 +30,7 @@ class CloneQuoteToInvoiceFactory
|
|||||||
unset($quote_array['invitations']);
|
unset($quote_array['invitations']);
|
||||||
|
|
||||||
//preserve terms if they exist on Quotes
|
//preserve terms if they exist on Quotes
|
||||||
if(strlen($quote_array['terms']) < 2)
|
if(array_key_exists('terms', $quote_array) && strlen($quote_array['terms']) < 2)
|
||||||
unset($quote_array['terms']);
|
unset($quote_array['terms']);
|
||||||
|
|
||||||
// unset($quote_array['public_notes']);
|
// unset($quote_array['public_notes']);
|
||||||
|
@ -36,7 +36,7 @@ class StoreClientRequest extends Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{nlog($this->input);
|
||||||
if ($this->input('documents') && is_array($this->input('documents'))) {
|
if ($this->input('documents') && is_array($this->input('documents'))) {
|
||||||
$documents = count($this->input('documents'));
|
$documents = count($this->input('documents'));
|
||||||
|
|
||||||
|
@ -84,8 +84,6 @@ trait ClientGroupSettingsSaver
|
|||||||
$settings = (object) $settings;
|
$settings = (object) $settings;
|
||||||
$casts = CompanySettings::$casts;
|
$casts = CompanySettings::$casts;
|
||||||
|
|
||||||
// $casts = ClientSettings::$property_casts;
|
|
||||||
|
|
||||||
ksort($casts);
|
ksort($casts);
|
||||||
|
|
||||||
if(property_exists($settings, 'translations'))
|
if(property_exists($settings, 'translations'))
|
||||||
@ -115,8 +113,12 @@ trait ClientGroupSettingsSaver
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/*Separate loop if it is a _id field which is an integer cast as a string*/
|
/*Separate loop if it is a _id field which is an integer cast as a string*/
|
||||||
elseif (substr($key, -3) == '_id' || substr($key, -14) == 'number_counter' || $key == 'payment_terms' || $key == 'valid_until') {
|
elseif (substr($key, -3) == '_id' ||
|
||||||
$value = 'integer';
|
substr($key, -14) == 'number_counter' ||
|
||||||
|
($key == 'payment_terms' && property_exists($settings, 'payment_terms') && strlen($settings->{$key}) >= 1) ||
|
||||||
|
($key == 'valid_until' && property_exists($settings, 'valid_until') && strlen($settings->{$key}) >= 1)) {
|
||||||
|
|
||||||
|
$value = 'integer';
|
||||||
|
|
||||||
if (! property_exists($settings, $key)) {
|
if (! property_exists($settings, $key)) {
|
||||||
continue;
|
continue;
|
||||||
@ -164,7 +166,11 @@ trait ClientGroupSettingsSaver
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*Separate loop if it is a _id field which is an integer cast as a string*/
|
/*Separate loop if it is a _id field which is an integer cast as a string*/
|
||||||
if (substr($key, -3) == '_id' || substr($key, -14) == 'number_counter' || $key == 'payment_terms' || $key == 'valid_until') {
|
if (substr($key, -3) == '_id' ||
|
||||||
|
substr($key, -14) == 'number_counter' ||
|
||||||
|
($key == 'payment_terms' && property_exists($settings, 'payment_terms') && strlen($settings->{$key}) >= 1) ||
|
||||||
|
($key == 'valid_until' && property_exists($settings, 'valid_until') && strlen($settings->{$key}) >= 1)) {
|
||||||
|
|
||||||
$value = 'integer';
|
$value = 'integer';
|
||||||
|
|
||||||
if (! property_exists($settings, $key)) {
|
if (! property_exists($settings, $key)) {
|
||||||
@ -213,8 +219,7 @@ trait ClientGroupSettingsSaver
|
|||||||
switch ($key) {
|
switch ($key) {
|
||||||
case 'int':
|
case 'int':
|
||||||
case 'integer':
|
case 'integer':
|
||||||
// return ctype_digit(strval(abs($value)));
|
return is_numeric($value) && ctype_digit(strval(abs($value)));
|
||||||
return ctype_digit(strval($value));
|
|
||||||
case 'real':
|
case 'real':
|
||||||
case 'float':
|
case 'float':
|
||||||
case 'double':
|
case 'double':
|
||||||
|
@ -52,7 +52,7 @@ trait SettingsSaver
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/*Separate loop if it is a _id field which is an integer cast as a string*/
|
/*Separate loop if it is a _id field which is an integer cast as a string*/
|
||||||
elseif (substr($key, -3) == '_id' || substr($key, -14) == 'number_counter' || $key == 'payment_terms' || $key == 'valid_until') {
|
elseif (substr($key, -3) == '_id' || substr($key, -14) == 'number_counter' || ($key == 'payment_terms' && strlen($settings->{$key}) >= 1) || ($key == 'valid_until' && strlen($settings->{$key}) >= 1)) {
|
||||||
$value = 'integer';
|
$value = 'integer';
|
||||||
|
|
||||||
if($key == 'gmail_sending_user_id')
|
if($key == 'gmail_sending_user_id')
|
||||||
@ -94,12 +94,11 @@ trait SettingsSaver
|
|||||||
switch ($key) {
|
switch ($key) {
|
||||||
case 'int':
|
case 'int':
|
||||||
case 'integer':
|
case 'integer':
|
||||||
return ctype_digit(strval(abs($value)));
|
return is_numeric($value) && ctype_digit(strval(abs($value)));
|
||||||
case 'real':
|
case 'real':
|
||||||
case 'float':
|
case 'float':
|
||||||
case 'double':
|
case 'double':
|
||||||
return !is_string($value) && (is_float($value) || is_numeric(strval($value)));
|
return !is_string($value) && (is_float($value) || is_numeric(strval($value)));
|
||||||
// return is_float($value) || is_numeric(strval($value));
|
|
||||||
case 'string':
|
case 'string':
|
||||||
return !is_int($value) || ( is_string( $value ) && method_exists($value, '__toString') ) || is_null($value) || is_string($value);
|
return !is_int($value) || ( is_string( $value ) && method_exists($value, '__toString') ) || is_null($value) || is_string($value);
|
||||||
case 'bool':
|
case 'bool':
|
||||||
|
@ -50,8 +50,6 @@ class CompanySettingsTest extends TestCase
|
|||||||
|
|
||||||
$this->company->saveSettings($settings, $this->company);
|
$this->company->saveSettings($settings, $this->company);
|
||||||
|
|
||||||
//$this->withoutExceptionHandling();
|
|
||||||
|
|
||||||
$response = false;
|
$response = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user