mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01: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']);
|
||||
|
||||
//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['public_notes']);
|
||||
|
@ -36,7 +36,7 @@ class StoreClientRequest extends Request
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
{nlog($this->input);
|
||||
if ($this->input('documents') && is_array($this->input('documents'))) {
|
||||
$documents = count($this->input('documents'));
|
||||
|
||||
|
@ -84,8 +84,6 @@ trait ClientGroupSettingsSaver
|
||||
$settings = (object) $settings;
|
||||
$casts = CompanySettings::$casts;
|
||||
|
||||
// $casts = ClientSettings::$property_casts;
|
||||
|
||||
ksort($casts);
|
||||
|
||||
if(property_exists($settings, 'translations'))
|
||||
@ -115,8 +113,12 @@ trait ClientGroupSettingsSaver
|
||||
continue;
|
||||
}
|
||||
/*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') {
|
||||
$value = 'integer';
|
||||
elseif (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';
|
||||
|
||||
if (! property_exists($settings, $key)) {
|
||||
continue;
|
||||
@ -164,7 +166,11 @@ trait ClientGroupSettingsSaver
|
||||
}
|
||||
|
||||
/*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';
|
||||
|
||||
if (! property_exists($settings, $key)) {
|
||||
@ -213,8 +219,7 @@ trait ClientGroupSettingsSaver
|
||||
switch ($key) {
|
||||
case 'int':
|
||||
case 'integer':
|
||||
// return ctype_digit(strval(abs($value)));
|
||||
return ctype_digit(strval($value));
|
||||
return is_numeric($value) && ctype_digit(strval(abs($value)));
|
||||
case 'real':
|
||||
case 'float':
|
||||
case 'double':
|
||||
|
@ -52,7 +52,7 @@ trait SettingsSaver
|
||||
continue;
|
||||
}
|
||||
/*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';
|
||||
|
||||
if($key == 'gmail_sending_user_id')
|
||||
@ -94,12 +94,11 @@ trait SettingsSaver
|
||||
switch ($key) {
|
||||
case 'int':
|
||||
case 'integer':
|
||||
return ctype_digit(strval(abs($value)));
|
||||
return is_numeric($value) && ctype_digit(strval(abs($value)));
|
||||
case 'real':
|
||||
case 'float':
|
||||
case 'double':
|
||||
return !is_string($value) && (is_float($value) || is_numeric(strval($value)));
|
||||
// return is_float($value) || is_numeric(strval($value));
|
||||
case 'string':
|
||||
return !is_int($value) || ( is_string( $value ) && method_exists($value, '__toString') ) || is_null($value) || is_string($value);
|
||||
case 'bool':
|
||||
|
@ -50,8 +50,6 @@ class CompanySettingsTest extends TestCase
|
||||
|
||||
$this->company->saveSettings($settings, $this->company);
|
||||
|
||||
//$this->withoutExceptionHandling();
|
||||
|
||||
$response = false;
|
||||
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user