mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Refactor for settings to force types
This commit is contained in:
parent
ff0406d564
commit
86a099587d
@ -20,8 +20,41 @@ class BaseSettings
|
|||||||
public function __construct($obj)
|
public function __construct($obj)
|
||||||
{
|
{
|
||||||
foreach($obj as $key => $value)
|
foreach($obj as $key => $value)
|
||||||
$this->{$key} = $value;
|
$obj->{$key} = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function setCasts($obj, $casts)
|
||||||
|
{
|
||||||
|
foreach ($casts as $key => $value)
|
||||||
|
$obj->{$key} = self::castAttribute($key, $obj->{$key});
|
||||||
|
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function castAttribute($key, $value)
|
||||||
|
{
|
||||||
|
switch ($key)
|
||||||
|
{
|
||||||
|
case 'int':
|
||||||
|
case 'integer':
|
||||||
|
return (int) $value;
|
||||||
|
case 'real':
|
||||||
|
case 'float':
|
||||||
|
case 'double':
|
||||||
|
return (float) $value;
|
||||||
|
case 'string':
|
||||||
|
return is_null($value) ? '' : (string) $value;
|
||||||
|
case 'bool':
|
||||||
|
case 'boolean':
|
||||||
|
return (bool)($value);
|
||||||
|
case 'object':
|
||||||
|
return json_decode($value);
|
||||||
|
case 'array':
|
||||||
|
case 'json':
|
||||||
|
return json_decode($value, true);
|
||||||
|
default:
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -29,58 +29,6 @@ use App\Utils\TranslationHelper;
|
|||||||
*/
|
*/
|
||||||
class ClientSettings extends BaseSettings
|
class ClientSettings extends BaseSettings
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Settings which also have a parent company setting
|
|
||||||
*/
|
|
||||||
public $timezone_id;
|
|
||||||
public $date_format;
|
|
||||||
public $datetime_format;
|
|
||||||
public $military_time;
|
|
||||||
public $start_of_week;
|
|
||||||
public $financial_year_start;
|
|
||||||
public $payment_terms;
|
|
||||||
|
|
||||||
public $language_id;
|
|
||||||
public $precision;
|
|
||||||
public $default_task_rate;
|
|
||||||
public $send_reminders;
|
|
||||||
public $show_tasks_in_portal;
|
|
||||||
public $custom_message_dashboard;
|
|
||||||
public $custom_message_unpaid_invoice;
|
|
||||||
public $custom_message_paid_invoice;
|
|
||||||
public $custom_message_unapproved_quote;
|
|
||||||
public $show_currency_symbol;
|
|
||||||
public $show_currency_code;
|
|
||||||
public $inclusive_taxes;
|
|
||||||
|
|
||||||
public $custom_invoice_taxes1;
|
|
||||||
public $custom_invoice_taxes2;
|
|
||||||
public $lock_sent_invoices;
|
|
||||||
public $auto_bill;
|
|
||||||
public $auto_archive_invoice;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Counter Variables
|
|
||||||
*
|
|
||||||
* Currently we have only engineered counters to be implemented at the client level
|
|
||||||
* prefix/patterns and padding are not there yet.
|
|
||||||
*/
|
|
||||||
public $invoice_number_prefix;
|
|
||||||
public $invoice_number_pattern;
|
|
||||||
public $invoice_number_counter;
|
|
||||||
|
|
||||||
public $quote_number_prefix;
|
|
||||||
public $quote_number_pattern;
|
|
||||||
public $quote_number_counter;
|
|
||||||
|
|
||||||
public $credit_number_prefix;
|
|
||||||
public $credit_number_pattern;
|
|
||||||
public $credit_number_counter;
|
|
||||||
|
|
||||||
public $shared_invoice_quote_counter;
|
|
||||||
public $recurring_invoice_number_prefix;
|
|
||||||
|
|
||||||
public $counter_padding;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings which which are unique to client settings
|
* Settings which which are unique to client settings
|
||||||
@ -88,27 +36,71 @@ class ClientSettings extends BaseSettings
|
|||||||
public $industry_id;
|
public $industry_id;
|
||||||
public $size_id;
|
public $size_id;
|
||||||
|
|
||||||
public $design;
|
public static $casts = [
|
||||||
|
'industry_id' => 'string',
|
||||||
public $company_gateways;
|
'size_id' => 'string',
|
||||||
|
];
|
||||||
|
|
||||||
public $invoice_design_id;
|
|
||||||
public $quote_design_id;
|
|
||||||
public $email_footer;
|
|
||||||
public $email_subject_invoice;
|
|
||||||
public $email_subject_quote;
|
|
||||||
public $email_subject_payment;
|
|
||||||
public $email_template_invoice;
|
|
||||||
public $email_template_quote;
|
|
||||||
public $email_template_payment;
|
|
||||||
public $email_subject_reminder1;
|
|
||||||
public $email_subject_reminder2;
|
|
||||||
public $email_subject_reminder3;
|
|
||||||
public $email_template_reminder1;
|
|
||||||
public $email_template_reminder2;
|
|
||||||
public $email_template_reminder3;
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
public static $casts = [
|
||||||
|
'timezone_id' => 'string',
|
||||||
|
'date_format' => 'string',
|
||||||
|
'datetime_format' => 'string',
|
||||||
|
'military_time' => 'bool',
|
||||||
|
'start_of_week' => 'int',
|
||||||
|
'financial_year_start' => 'int',
|
||||||
|
'payment_terms' => 'int',
|
||||||
|
'language_id' => 'string',
|
||||||
|
'precision' => 'int',
|
||||||
|
'default_task_rate' => 'float',
|
||||||
|
'send_reminders' => 'bool',
|
||||||
|
'show_tasks_in_portal' => 'bool',
|
||||||
|
'custom_message_dashboard' => 'string',
|
||||||
|
'custom_message_unpaid_invoice' => 'string',
|
||||||
|
'custom_message_paid_invoice' => 'string',
|
||||||
|
'custom_message_unapproved_quote' => 'string',
|
||||||
|
'show_currency_symbol' => 'bool',
|
||||||
|
'show_currency_code' => 'bool',
|
||||||
|
'inclusive_taxes' => 'bool',
|
||||||
|
'custom_invoice_taxes1' => 'bool',
|
||||||
|
'custom_invoice_taxes2' => 'bool',
|
||||||
|
'lock_sent_invoices' => 'bool',
|
||||||
|
'auto_bill' => 'bool',
|
||||||
|
'auto_archive_invoice' => 'bool',
|
||||||
|
'invoice_number_prefix' => 'string',
|
||||||
|
'invoice_number_pattern' => 'string',
|
||||||
|
'invoice_number_counter' => 'int',
|
||||||
|
'quote_number_prefix' => 'string',
|
||||||
|
'quote_number_pattern' => 'string',
|
||||||
|
'quote_number_counter' => 'int',
|
||||||
|
'credit_number_prefix' => 'string',
|
||||||
|
'credit_number_pattern' => 'string',
|
||||||
|
'credit_number_counter' => 'int',
|
||||||
|
'shared_invoice_quote_counter' => 'int',
|
||||||
|
'recurring_invoice_number_prefix' => 'string',
|
||||||
|
'counter_padding' => 'int',
|
||||||
|
'industry_id' => 'string',
|
||||||
|
'size_id' => 'string',
|
||||||
|
'design' => 'string',
|
||||||
|
'company_gateways' => 'string',
|
||||||
|
'invoice_design_id' => 'string',
|
||||||
|
'quote_design_id' => 'string',
|
||||||
|
'email_footer' => 'string',
|
||||||
|
'email_subject_invoice' => 'string',
|
||||||
|
'email_subject_quote' => 'string',
|
||||||
|
'email_subject_payment' => 'string',
|
||||||
|
'email_template_invoice' => 'string',
|
||||||
|
'email_template_quote' => 'string',
|
||||||
|
'email_template_payment' => 'string',
|
||||||
|
'email_subject_reminder1' => 'string',
|
||||||
|
'email_subject_reminder2' => 'string',
|
||||||
|
'email_subject_reminder3' => 'string',
|
||||||
|
'email_template_reminder1' => 'string',
|
||||||
|
'email_template_reminder2' => 'string',
|
||||||
|
'email_template_reminder3' => 'string',
|
||||||
|
];
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* Cast object values and return entire class
|
* Cast object values and return entire class
|
||||||
* prevents missing properties from not being returned
|
* prevents missing properties from not being returned
|
||||||
@ -131,12 +123,14 @@ class ClientSettings extends BaseSettings
|
|||||||
public static function defaults() : \stdClass
|
public static function defaults() : \stdClass
|
||||||
{
|
{
|
||||||
|
|
||||||
return (object)[
|
$data = (object)[
|
||||||
'entity' => Client::class,
|
'entity' => (string)Client::class,
|
||||||
'industry_id' => NULL,
|
'industry_id' => '',
|
||||||
'size_id' => NULL,
|
'size_id' => '',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
return self::setCasts($data, self::$casts);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -151,10 +145,14 @@ class ClientSettings extends BaseSettings
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
foreach($client_settings as $key => $value)
|
foreach($company_settings as $key => $value)
|
||||||
{
|
{
|
||||||
|
/* pseudo code
|
||||||
if(!isset($client_settings->{$key}) && property_exists($company_settings, $key)) {
|
if the property exists and is a string BUT has no length, treat it as TRUE
|
||||||
|
*/
|
||||||
|
if( ( (property_exists($client_settings, $key) && is_string($client_settings->{$key}) && (iconv_strlen($client_settings->{$key}) <1)))
|
||||||
|
|| !isset($client_settings->{$key})
|
||||||
|
&& property_exists($company_settings, $key)) {
|
||||||
$client_settings->{$key} = $company_settings->{$key};
|
$client_settings->{$key} = $company_settings->{$key};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\DataMapper;
|
namespace App\DataMapper;
|
||||||
|
|
||||||
|
use App\DataMapper\CompanySettings;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -19,140 +20,217 @@ use App\Models\Company;
|
|||||||
class CompanySettings extends BaseSettings
|
class CompanySettings extends BaseSettings
|
||||||
{
|
{
|
||||||
|
|
||||||
public $timezone_id;
|
public $timezone_id = '';
|
||||||
public $date_format;
|
public $date_format = '';
|
||||||
public $datetime_format;
|
public $datetime_format = '';
|
||||||
public $military_time;
|
public $military_time = false;
|
||||||
public $start_of_week;
|
public $start_of_week = '';
|
||||||
public $financial_year_start;
|
public $financial_year_start = '';
|
||||||
|
|
||||||
public $language_id;
|
public $language_id = '';
|
||||||
|
|
||||||
public $precision;
|
public $precision = 2;
|
||||||
public $show_currency_symbol;
|
public $show_currency_symbol = true;
|
||||||
public $show_currency_code;
|
public $show_currency_code = false;
|
||||||
|
|
||||||
public $payment_terms; //days
|
public $payment_terms;
|
||||||
|
|
||||||
public $custom_label1;
|
public $custom_label1 = '';
|
||||||
public $custom_value1;
|
public $custom_value1 = '';
|
||||||
public $custom_label2;
|
public $custom_label2 = '';
|
||||||
public $custom_value2;
|
public $custom_value2 = '';
|
||||||
public $custom_label3;
|
public $custom_label3 = '';
|
||||||
public $custom_value3;
|
public $custom_value3 = '';
|
||||||
public $custom_label4;
|
public $custom_label4 = '';
|
||||||
public $custom_value5;
|
public $custom_value5 = '';
|
||||||
public $custom_client_label1;
|
public $custom_client_label1 = '';
|
||||||
public $custom_client_label2;
|
public $custom_client_label2 = '';
|
||||||
public $custom_client_label3;
|
public $custom_client_label3 = '';
|
||||||
public $custom_client_label4;
|
public $custom_client_label4 = '';
|
||||||
public $custom_client_contact_label1;
|
public $custom_client_contact_label1 = '';
|
||||||
public $custom_client_contact_label2;
|
public $custom_client_contact_label2 = '';
|
||||||
public $custom_client_contact_label3;
|
public $custom_client_contact_label3 = '';
|
||||||
public $custom_client_contact_label4;
|
public $custom_client_contact_label4 = '';
|
||||||
public $custom_invoice_label1;
|
public $custom_invoice_label1 = '';
|
||||||
public $custom_invoice_label2;
|
public $custom_invoice_label2 = '';
|
||||||
public $custom_invoice_label3;
|
public $custom_invoice_label3 = '';
|
||||||
public $custom_invoice_label4;
|
public $custom_invoice_label4 = '';
|
||||||
public $custom_product_label1;
|
public $custom_product_label1 = '';
|
||||||
public $custom_product_label2;
|
public $custom_product_label2 = '';
|
||||||
public $custom_product_label3;
|
public $custom_product_label3 = '';
|
||||||
public $custom_product_label4;
|
public $custom_product_label4 = '';
|
||||||
public $custom_task_label1;
|
public $custom_task_label1 = '';
|
||||||
public $custom_task_label2;
|
public $custom_task_label2 = '';
|
||||||
public $custom_task_label3;
|
public $custom_task_label3 = '';
|
||||||
public $custom_task_label4;
|
public $custom_task_label4 = '';
|
||||||
public $custom_expense_label1;
|
public $custom_expense_label1 = '';
|
||||||
public $custom_expense_label2;
|
public $custom_expense_label2 = '';
|
||||||
public $custom_expense_label3;
|
public $custom_expense_label3 = '';
|
||||||
public $custom_expense_label4;
|
public $custom_expense_label4 = '';
|
||||||
|
|
||||||
public $custom_invoice_taxes1;
|
public $custom_invoice_taxes1 = false;
|
||||||
public $custom_invoice_taxes2;
|
public $custom_invoice_taxes2 = false;
|
||||||
|
|
||||||
public $default_task_rate;
|
public $default_task_rate = 0;
|
||||||
public $send_reminders;
|
public $send_reminders = false;
|
||||||
public $show_tasks_in_portal;
|
public $show_tasks_in_portal = false;
|
||||||
|
|
||||||
public $custom_message_dashboard;
|
public $custom_message_dashboard = '';
|
||||||
public $custom_message_unpaid_invoice;
|
public $custom_message_unpaid_invoice = '';
|
||||||
public $custom_message_paid_invoice;
|
public $custom_message_paid_invoice = '';
|
||||||
public $custom_message_unapproved_quote;
|
public $custom_message_unapproved_quote = '';
|
||||||
public $lock_sent_invoices;
|
public $lock_sent_invoices = false;
|
||||||
public $auto_archive_invoice;
|
public $auto_archive_invoice = false;
|
||||||
|
|
||||||
public $inclusive_taxes;
|
public $inclusive_taxes = false;
|
||||||
|
|
||||||
public $translations;
|
public $translations;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counter Variables
|
* Counter Variables
|
||||||
*/
|
*/
|
||||||
public $invoice_number_prefix;
|
public $invoice_number_prefix = '';
|
||||||
public $invoice_number_pattern;
|
public $invoice_number_pattern = '';
|
||||||
public $invoice_number_counter;
|
public $invoice_number_counter = 1;
|
||||||
|
|
||||||
public $quote_number_prefix;
|
public $quote_number_prefix = '';
|
||||||
public $quote_number_pattern;
|
public $quote_number_pattern = '';
|
||||||
public $quote_number_counter;
|
public $quote_number_counter = 1;
|
||||||
|
|
||||||
public $client_number_prefix;
|
public $client_number_prefix = '';
|
||||||
public $client_number_pattern;
|
public $client_number_pattern = '';
|
||||||
public $client_number_counter;
|
public $client_number_counter = 1;
|
||||||
|
|
||||||
public $credit_number_prefix;
|
public $credit_number_prefix = '';
|
||||||
public $credit_number_pattern;
|
public $credit_number_pattern = '';
|
||||||
public $credit_number_counter;
|
public $credit_number_counter = 1;
|
||||||
|
|
||||||
public $shared_invoice_quote_counter;
|
public $shared_invoice_quote_counter = false;
|
||||||
|
|
||||||
public $recurring_invoice_number_prefix;
|
public $recurring_invoice_number_prefix = 'R';
|
||||||
public $reset_counter_frequency_id;
|
public $reset_counter_frequency_id = '';
|
||||||
public $reset_counter_date;
|
public $reset_counter_date = '';
|
||||||
public $counter_padding;
|
public $counter_padding = 0;
|
||||||
|
|
||||||
public $design;
|
public $design = 'views/pdf/design1.blade.php';
|
||||||
|
|
||||||
public $company_gateways;
|
public $company_gateways = '';
|
||||||
|
|
||||||
|
|
||||||
public $invoice_terms;
|
public $invoice_terms = '';
|
||||||
public $quote_terms;
|
public $quote_terms = '';
|
||||||
public $invoice_taxes;
|
public $invoice_taxes = false;
|
||||||
public $invoice_item_taxes;
|
public $invoice_item_taxes = false;
|
||||||
public $invoice_design_id;
|
public $invoice_design_id = '';
|
||||||
public $quote_design_id;
|
public $quote_design_id = '';
|
||||||
public $invoice_footer;
|
public $invoice_footer = '';
|
||||||
public $invoice_labels;
|
public $invoice_labels = '';
|
||||||
public $show_item_taxes;
|
public $show_item_taxes = false;
|
||||||
public $fill_products;
|
public $fill_products = false;
|
||||||
public $tax_name1;
|
public $tax_name1 = '';
|
||||||
public $tax_rate1;
|
public $tax_rate1 = '';
|
||||||
public $tax_name2;
|
public $tax_name2 = '';
|
||||||
public $tax_rate2;
|
public $tax_rate2 = '';
|
||||||
public $enable_second_tax_rate;
|
public $enable_second_tax_rate = false;
|
||||||
public $enable_modules;
|
public $enable_modules = false;
|
||||||
public $payment_type_id;
|
public $payment_type_id = '';
|
||||||
public $convert_products;
|
public $convert_products = false;
|
||||||
public $custom_fields;
|
public $custom_fields = '';
|
||||||
public $invoice_fields;
|
public $invoice_fields = '';
|
||||||
public $email_footer;
|
public $email_footer = '';
|
||||||
public $email_subject_invoice;
|
public $email_subject_invoice = '';
|
||||||
public $email_subject_quote;
|
public $email_subject_quote = '';
|
||||||
public $email_subject_payment;
|
public $email_subject_payment = '';
|
||||||
public $email_template_invoice;
|
public $email_template_invoice = '';
|
||||||
public $email_template_quote;
|
public $email_template_quote = '';
|
||||||
public $email_template_payment;
|
public $email_template_payment = '';
|
||||||
public $email_subject_reminder1;
|
public $email_subject_reminder1 = '';
|
||||||
public $email_subject_reminder2;
|
public $email_subject_reminder2 = '';
|
||||||
public $email_subject_reminder3;
|
public $email_subject_reminder3 = '';
|
||||||
public $email_template_reminder1;
|
public $email_template_reminder1 = '';
|
||||||
public $email_template_reminder2;
|
public $email_template_reminder2 = '';
|
||||||
public $email_template_reminder3;
|
public $email_template_reminder3 = '';
|
||||||
public $has_custom_design1;
|
public $has_custom_design1 = '';
|
||||||
public $has_custom_design2;
|
public $has_custom_design2 = '';
|
||||||
public $has_custom_design3;
|
public $has_custom_design3 = '';
|
||||||
public $enable_portal_password;
|
public $enable_portal_password = false;
|
||||||
|
|
||||||
|
public static $casts = [
|
||||||
|
'timezone_id' => 'string',
|
||||||
|
'date_format' => 'string',
|
||||||
|
'datetime_format' => 'string',
|
||||||
|
'military_time' => 'bool',
|
||||||
|
'start_of_week' => 'string',
|
||||||
|
'financial_year_start' => 'string',
|
||||||
|
'language_id' => 'string',
|
||||||
|
'precision' => 'int',
|
||||||
|
'show_currency_symbol' => 'bool',
|
||||||
|
'show_currency_code' => 'bool',
|
||||||
|
'payment_terms' => 'int',
|
||||||
|
'custom_label1' => 'string',
|
||||||
|
'custom_value1' => 'string',
|
||||||
|
'custom_label2' => 'string',
|
||||||
|
'custom_value2' => 'string',
|
||||||
|
'custom_label3' => 'string',
|
||||||
|
'custom_value3' => 'string',
|
||||||
|
'custom_label4' => 'string',
|
||||||
|
'custom_value5' => 'string',
|
||||||
|
'custom_client_label1' => 'string',
|
||||||
|
'custom_client_label2' => 'string',
|
||||||
|
'custom_client_label3' => 'string',
|
||||||
|
'custom_client_label4' => 'string',
|
||||||
|
'custom_client_contact_label1' => 'string',
|
||||||
|
'custom_client_contact_label2' => 'string',
|
||||||
|
'custom_client_contact_label3' => 'string',
|
||||||
|
'custom_client_contact_label4' => 'string',
|
||||||
|
'custom_invoice_label1' => 'string',
|
||||||
|
'custom_invoice_label2' => 'string',
|
||||||
|
'custom_invoice_label3' => 'string',
|
||||||
|
'custom_invoice_label4' => 'string',
|
||||||
|
'custom_product_label1' => 'string',
|
||||||
|
'custom_product_label2' => 'string',
|
||||||
|
'custom_product_label3' => 'string',
|
||||||
|
'custom_product_label4' => 'string',
|
||||||
|
'custom_task_label1' => 'string',
|
||||||
|
'custom_task_label2' => 'string',
|
||||||
|
'custom_task_label3' => 'string',
|
||||||
|
'custom_task_label4' => 'string',
|
||||||
|
'custom_expense_label1' => 'string',
|
||||||
|
'custom_expense_label2' => 'string',
|
||||||
|
'custom_expense_label3' => 'string',
|
||||||
|
'custom_expense_label4' => 'string',
|
||||||
|
'custom_invoice_taxes1' => 'bool',
|
||||||
|
'custom_invoice_taxes2' => 'bool',
|
||||||
|
'default_task_rate' => 'float',
|
||||||
|
'send_reminders' => 'bool',
|
||||||
|
'show_tasks_in_portal' => 'bool',
|
||||||
|
'custom_message_dashboard' => 'string',
|
||||||
|
'custom_message_unpaid_invoice' => 'string',
|
||||||
|
'custom_message_paid_invoice' => 'string',
|
||||||
|
'custom_message_unapproved_quote' => 'string',
|
||||||
|
'lock_sent_invoices' => 'bool',
|
||||||
|
'auto_archive_invoice' => 'bool',
|
||||||
|
'inclusive_taxes' => 'bool',
|
||||||
|
'invoice_number_prefix' => 'string',
|
||||||
|
'invoice_number_pattern' => 'string',
|
||||||
|
'invoice_number_counter' => 'int',
|
||||||
|
'quote_number_prefix' => 'string',
|
||||||
|
'quote_number_pattern' => 'string',
|
||||||
|
'quote_number_counter' => 'int',
|
||||||
|
'client_number_prefix' => 'string',
|
||||||
|
'client_number_pattern' => 'string',
|
||||||
|
'client_number_counter' => 'int',
|
||||||
|
'credit_number_prefix' => 'string',
|
||||||
|
'credit_number_pattern' => 'string',
|
||||||
|
'credit_number_counter' => 'int',
|
||||||
|
'shared_invoice_quote_counter' => 'bool',
|
||||||
|
'recurring_invoice_number_prefix' => 'string',
|
||||||
|
'reset_counter_frequency_id' => 'int',
|
||||||
|
'reset_counter_date' => 'string',
|
||||||
|
'counter_padding' => 'int',
|
||||||
|
'design' => 'string',
|
||||||
|
'company_gateways' => 'string',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cast object values and return entire class
|
* Cast object values and return entire class
|
||||||
@ -163,7 +241,7 @@ class CompanySettings extends BaseSettings
|
|||||||
*/
|
*/
|
||||||
public function __construct($obj)
|
public function __construct($obj)
|
||||||
{
|
{
|
||||||
parent::__construct($obj);
|
// parent::__construct($obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -173,43 +251,21 @@ class CompanySettings extends BaseSettings
|
|||||||
public static function defaults() : \stdClass
|
public static function defaults() : \stdClass
|
||||||
{
|
{
|
||||||
$config = json_decode(config('ninja.settings'));
|
$config = json_decode(config('ninja.settings'));
|
||||||
|
|
||||||
|
$data = (object)get_class_vars(CompanySettings::class);
|
||||||
|
unset($data->casts);
|
||||||
|
|
||||||
return (object) [
|
$data->timezone_id = (string)config('ninja.i18n.timezone_id');
|
||||||
'entity' => Company::class,
|
$data->language_id = (string)config('ninja.i18n.language_id');
|
||||||
'timezone_id' => config('ninja.i18n.timezone_id'),
|
$data->payment_terms = (string)config('ninja.i18n.payment_terms');
|
||||||
'language_id' => config('ninja.i18n.language_id'),
|
$data->datetime_format = (string)config('ninja.i18n.datetime_format');
|
||||||
'precision' => 2,
|
$data->military_time = (bool )config('ninja.i18n.military_time');
|
||||||
'payment_terms' => config('ninja.i18n.payment_terms'),
|
$data->date_format = (string)config('ninja.i18n.date_format');
|
||||||
'datetime_format' => config('ninja.i18n.datetime_format'),
|
$data->start_of_week = (int) config('ninja.i18n.start_of_week');
|
||||||
'military_time' => config('ninja.i18n.military_time'),
|
$data->financial_year_start = (int)config('ninja.i18n.financial_year_start');
|
||||||
'date_format' => config('ninja.i18n.date_format'),
|
$data->translations = (object) [];
|
||||||
'start_of_week' => config('ninja.i18n.start_of_week'),
|
|
||||||
'financial_year_start' => config('ninja.i18n.financial_year_start'),
|
return self::setCasts($data, self::$casts);
|
||||||
'default_task_rate' => 0,
|
|
||||||
'send_reminders' => 'TRUE',
|
|
||||||
'show_tasks_in_portal' => 'TRUE',
|
|
||||||
'show_currency_symbol' => 'TRUE',
|
|
||||||
'show_currency_code' => 'FALSE',
|
|
||||||
'inclusive_taxes' => 'TRUE',
|
|
||||||
'custom_invoice_taxes1' => 'FALSE',
|
|
||||||
'custom_invoice_taxes2' => 'FALSE',
|
|
||||||
'lock_sent_invoices' => 'TRUE',
|
|
||||||
'shared_invoice_quote_counter' => 'FALSE',
|
|
||||||
'invoice_number_counter' => 1,
|
|
||||||
'quote_number_counter' => 1,
|
|
||||||
'credit_number_counter' => 1,
|
|
||||||
'client_number_counter' => 1,
|
|
||||||
'counter_padding' => 0,
|
|
||||||
'recurring_invoice_number_prefix' => 'R',
|
|
||||||
'invoice_number_prefix' => '',
|
|
||||||
'quote_number_prefix' => '',
|
|
||||||
'credit_number_prefix' => '',
|
|
||||||
'client_number_prefix' => '',
|
|
||||||
'auto_archive_invoice' => 'FALSE',
|
|
||||||
'design' => 'views/pdf/design1.blade.php',
|
|
||||||
|
|
||||||
'translations' => (object) [],
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ class ClientFactory
|
|||||||
$client->is_deleted = 0;
|
$client->is_deleted = 0;
|
||||||
$client->client_hash = str_random(40);
|
$client->client_hash = str_random(40);
|
||||||
$client->currency_id = config('ninja.i18n.currency_id');
|
$client->currency_id = config('ninja.i18n.currency_id');
|
||||||
$client->settings = new ClientSettings(ClientSettings::defaults());
|
$client->settings = ClientSettings::defaults();
|
||||||
|
|
||||||
$client_contact = ClientContactFactory::create($company_id, $user_id);
|
$client_contact = ClientContactFactory::create($company_id, $user_id);
|
||||||
$client->contacts->add($client_contact);
|
$client->contacts->add($client_contact);
|
||||||
|
@ -26,7 +26,7 @@ class CompanyFactory
|
|||||||
$company->name = '';
|
$company->name = '';
|
||||||
$company->account_id = $account_id;
|
$company->account_id = $account_id;
|
||||||
$company->company_key = $this->createHash();
|
$company->company_key = $this->createHash();
|
||||||
$company->settings = new CompanySettings(CompanySettings::defaults());
|
$company->settings = CompanySettings::defaults();
|
||||||
$company->db = config('database.default');
|
$company->db = config('database.default');
|
||||||
$company->domain = '';
|
$company->domain = '';
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class InvoiceFactory
|
|||||||
$invoice->partial_due_date = null;
|
$invoice->partial_due_date = null;
|
||||||
$invoice->is_deleted = false;
|
$invoice->is_deleted = false;
|
||||||
$invoice->line_items = json_encode([]);
|
$invoice->line_items = json_encode([]);
|
||||||
$invoice->settings = ClientSettings::buildClientSettings(new CompanySettings(CompanySettings::defaults()), new ClientSettings(ClientSettings::defaults())); //todo need to embed the settings here
|
$invoice->settings = ClientSettings::buildClientSettings(CompanySettings::defaults(), ClientSettings::defaults()); //todo need to embed the settings here
|
||||||
$invoice->backup = json_encode([]);
|
$invoice->backup = json_encode([]);
|
||||||
$invoice->tax_name1 = '';
|
$invoice->tax_name1 = '';
|
||||||
$invoice->tax_rate1 = 0;
|
$invoice->tax_rate1 = 0;
|
||||||
|
@ -35,7 +35,7 @@ class QuoteFactory
|
|||||||
$quote->partial_due_date = null;
|
$quote->partial_due_date = null;
|
||||||
$quote->is_deleted = false;
|
$quote->is_deleted = false;
|
||||||
$quote->line_items = json_encode([]);
|
$quote->line_items = json_encode([]);
|
||||||
$quote->settings = ClientSettings::buildClientSettings(new CompanySettings(CompanySettings::defaults()), new ClientSettings(ClientSettings::defaults())); //todo need to embed the settings here
|
$quote->settings = ClientSettings::buildClientSettings(CompanySettings::defaults(), ClientSettings::defaults()); //todo need to embed the settings here
|
||||||
$quote->backup = json_encode([]);
|
$quote->backup = json_encode([]);
|
||||||
$quote->tax_name1 = '';
|
$quote->tax_name1 = '';
|
||||||
$quote->tax_rate1 = 0;
|
$quote->tax_rate1 = 0;
|
||||||
|
@ -34,7 +34,7 @@ class RecurringInvoiceFactory
|
|||||||
$invoice->partial_due_date = null;
|
$invoice->partial_due_date = null;
|
||||||
$invoice->is_deleted = false;
|
$invoice->is_deleted = false;
|
||||||
$invoice->line_items = json_encode([]);
|
$invoice->line_items = json_encode([]);
|
||||||
$invoice->settings = ClientSettings::buildClientSettings(new CompanySettings(CompanySettings::defaults()), new ClientSettings(ClientSettings::defaults())); //todo need to embed the settings here
|
$invoice->settings = ClientSettings::buildClientSettings(CompanySettings::defaults(), ClientSettings::defaults()); //todo need to embed the settings here
|
||||||
$invoice->backup = json_encode([]);
|
$invoice->backup = json_encode([]);
|
||||||
$invoice->tax_name1 = '';
|
$invoice->tax_name1 = '';
|
||||||
$invoice->tax_rate1 = 0;
|
$invoice->tax_rate1 = 0;
|
||||||
|
@ -33,7 +33,7 @@ class RecurringQuoteFactory
|
|||||||
$quote->partial_due_date = null;
|
$quote->partial_due_date = null;
|
||||||
$quote->is_deleted = false;
|
$quote->is_deleted = false;
|
||||||
$quote->line_items = json_encode([]);
|
$quote->line_items = json_encode([]);
|
||||||
$quote->settings = ClientSettings::buildClientSettings(new CompanySettings(CompanySettings::defaults()), new ClientSettings(ClientSettings::defaults())); //todo need to embed the settings here
|
$quote->settings = ClientSettings::buildClientSettings(CompanySettings::defaults(), ClientSettings::defaults()); //todo need to embed the settings here
|
||||||
$quote->backup = json_encode([]);
|
$quote->backup = json_encode([]);
|
||||||
$quote->tax_name1 = '';
|
$quote->tax_name1 = '';
|
||||||
$quote->tax_rate1 = 0;
|
$quote->tax_rate1 = 0;
|
||||||
|
@ -70,7 +70,7 @@ class InvoiceCalc
|
|||||||
*/
|
*/
|
||||||
public function build()
|
public function build()
|
||||||
{
|
{
|
||||||
//Log::error(print_r($this->invoice,1));
|
//\Log::error(var_dump($this->settings));
|
||||||
|
|
||||||
$this->calcLineItems()
|
$this->calcLineItems()
|
||||||
->calcDiscount()
|
->calcDiscount()
|
||||||
|
@ -55,7 +55,7 @@ class CreateCompany
|
|||||||
$company->account_id = $this->account->id;
|
$company->account_id = $this->account->id;
|
||||||
$company->company_key = $this->createHash();
|
$company->company_key = $this->createHash();
|
||||||
$company->ip = request()->ip();
|
$company->ip = request()->ip();
|
||||||
$company->settings = new CompanySettings(CompanySettings::defaults());
|
$company->settings = CompanySettings::defaults();
|
||||||
$company->db = config('database.default');
|
$company->db = config('database.default');
|
||||||
$company->save();
|
$company->save();
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ class BaseModel extends Model
|
|||||||
return $this->getSettings()->{$key};
|
return $this->getSettings()->{$key};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//Log::error(print_r(new CompanySettings($this->company->settings),1));
|
Log::error(print_r(new CompanySettings($this->company->settings),1));
|
||||||
return (new CompanySettings($this->company->settings))->{$key};
|
return (new CompanySettings($this->company->settings))->{$key};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,13 +179,13 @@ class Client extends BaseModel
|
|||||||
if($this->group_settings !== null)
|
if($this->group_settings !== null)
|
||||||
{
|
{
|
||||||
|
|
||||||
$group_settings = ClientSettings::buildClientSettings(new ClientSettings($this->group_settings->settings), new ClientSettings($this->settings));
|
$group_settings = ClientSettings::buildClientSettings($this->group_settings->settings, $this->settings);
|
||||||
|
|
||||||
return ClientSettings::buildClientSettings(new CompanySettings($this->company->settings), $group_settings);
|
return ClientSettings::buildClientSettings($this->company->settings, $group_settings);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ClientSettings::buildClientSettings(new CompanySettings($this->company->settings), new ClientSettings($this->settings));
|
return ClientSettings::buildClientSettings($this->company->settings, $this->settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -199,19 +199,30 @@ class Client extends BaseModel
|
|||||||
*/
|
*/
|
||||||
public function getSetting($setting)
|
public function getSetting($setting)
|
||||||
{
|
{
|
||||||
|
|
||||||
//check client level first
|
//check client level first
|
||||||
if($this->settings && isset($this->settings->{$setting}) && property_exists($this->settings, $setting))
|
if($this->settings && (property_exists($this->settings, $setting) !== false) && (isset($this->settings->{$setting}) !== false) ){
|
||||||
return $this->settings->{$setting};
|
|
||||||
|
/*need to catch empt string here*/
|
||||||
|
if(is_string($this->settings->{$setting}) && (iconv_strlen($this->settings->{$setting}) >=1)){
|
||||||
|
return $this->settings->{$setting};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//check group level (if a group is assigned)
|
//check group level (if a group is assigned)
|
||||||
if($this->group_settings && isset($this->group_settings->settings->{$setting}) && property_exists($this->group_settings->settings, $setting))
|
if($this->group_settings && (property_exists($this->group_settings->settings, $setting) !== false) && (isset($this->group_settings->settings->{$setting}) !== false)){
|
||||||
return $this->group_settings->settings->{$setting};
|
\Log::error('returning group '.$this->group_settings->{$setting});
|
||||||
|
|
||||||
|
return $this->group_settings->settings->{$setting};
|
||||||
|
}
|
||||||
|
|
||||||
//check company level
|
//check company level
|
||||||
if(isset($this->company->settings->{$setting}) && property_exists($this->company->settings, $setting))
|
if((property_exists($this->company->settings, $setting) != false ) && (isset($this->company->settings->{$setting}) !== false) ){
|
||||||
|
\Log::error('returning company '.$this->company->{$setting});
|
||||||
|
|
||||||
return $this->company->settings->{$setting};
|
return $this->company->settings->{$setting};
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \Exception("Settings corrupted", 1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ use App\Models\Credit;
|
|||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Quote;
|
use App\Models\Quote;
|
||||||
use App\Models\RecurringInvoice;
|
use App\Models\RecurringInvoice;
|
||||||
|
use App\Models\Timezone;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
@ -151,9 +152,9 @@ trait GeneratesCounter
|
|||||||
//Reset counters if enabled
|
//Reset counters if enabled
|
||||||
$this->resetCounters($client);
|
$this->resetCounters($client);
|
||||||
|
|
||||||
$counter = $client->company->getSettingsByKey( 'client_number_counter' );
|
$counter = $client->getSetting('client_number_counter' );
|
||||||
|
|
||||||
$client_number = $this->checkEntityNumber(Client::class, $client, $counter, $client->company->settings->counter_padding, $client->company->settings->client_number_prefix, $client->company->settings->client_number_pattern);
|
$client_number = $this->checkEntityNumber(Client::class, $client, $counter, $client->getSetting('counter_padding'), $client->getSetting('client_number_prefix'), $client->getSetting('client_number_pattern'));
|
||||||
|
|
||||||
$this->incrementCounter($client->company, 'client_number_counter');
|
$this->incrementCounter($client->company, 'client_number_counter');
|
||||||
|
|
||||||
@ -266,11 +267,11 @@ trait GeneratesCounter
|
|||||||
private function resetCounters(Client $client)
|
private function resetCounters(Client $client)
|
||||||
{
|
{
|
||||||
|
|
||||||
$timezone = $client->company->timezone()->name;
|
$timezone = Timezone::find($client->getSetting('timezone_id'));
|
||||||
|
|
||||||
$reset_date = Carbon::parse($client->company->settings->reset_counter_date, $timezone);
|
$reset_date = Carbon::parse($client->getSetting('reset_counter_date'), $timezone->name);
|
||||||
|
|
||||||
if (! $reset_date->isToday() || ! $client->company->settings->reset_counter_date)
|
if (! $reset_date->isToday() || ! $client->getSetting('reset_counter_date'))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch ($client->company->reset_counter_frequency_id) {
|
switch ($client->company->reset_counter_frequency_id) {
|
||||||
|
@ -9,7 +9,7 @@ $factory->define(App\Models\Company::class, function (Faker $faker) {
|
|||||||
'company_key' => strtolower(str_random(config('ninja.key_length'))),
|
'company_key' => strtolower(str_random(config('ninja.key_length'))),
|
||||||
'ip' => $faker->ipv4,
|
'ip' => $faker->ipv4,
|
||||||
'db' => config('database.default'),
|
'db' => config('database.default'),
|
||||||
'settings' => new CompanySettings(CompanySettings::defaults()),
|
'settings' => CompanySettings::defaults(),
|
||||||
'address1' => $faker->secondaryAddress,
|
'address1' => $faker->secondaryAddress,
|
||||||
'address2' => $faker->address,
|
'address2' => $faker->address,
|
||||||
'city' => $faker->city,
|
'city' => $faker->city,
|
||||||
|
@ -125,7 +125,7 @@ class RandomDataSeeder extends Seeder
|
|||||||
GroupSetting::create([
|
GroupSetting::create([
|
||||||
'company_id' => $company->id,
|
'company_id' => $company->id,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'settings' => ClientSettings::buildClientSettings(new CompanySettings(CompanySettings::defaults()), new ClientSettings(ClientSettings::defaults())),
|
'settings' => ClientSettings::buildClientSettings(CompanySettings::defaults(), ClientSettings::defaults()),
|
||||||
'name' => 'Default Client Settings',
|
'name' => 'Default Client Settings',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ class ClientTest extends TestCase
|
|||||||
|
|
||||||
$token = $company_token->token;
|
$token = $company_token->token;
|
||||||
$company = $company_token->company;
|
$company = $company_token->company;
|
||||||
|
|
||||||
$user = $company_token->user;
|
$user = $company_token->user;
|
||||||
|
|
||||||
//$company_user = $company->company_users()->first();
|
//$company_user = $company->company_users()->first();
|
||||||
|
@ -73,7 +73,7 @@ trait MockAccountData
|
|||||||
$gs = new GroupSetting;
|
$gs = new GroupSetting;
|
||||||
$gs->name = 'Test';
|
$gs->name = 'Test';
|
||||||
$gs->company_id = $this->client->company_id;
|
$gs->company_id = $this->client->company_id;
|
||||||
$gs->settings = new ClientSettings(ClientSettings::defaults());
|
$gs->settings = ClientSettings::buildClientSettings($this->company->settings, $this->client->settings);
|
||||||
$gs->save();
|
$gs->save();
|
||||||
|
|
||||||
$this->client->group_settings_id = $gs->id;
|
$this->client->group_settings_id = $gs->id;
|
||||||
@ -86,7 +86,7 @@ trait MockAccountData
|
|||||||
|
|
||||||
$this->invoice->line_items = $this->buildLineItems();
|
$this->invoice->line_items = $this->buildLineItems();
|
||||||
|
|
||||||
$this->settings = $this->client->settings;
|
$this->settings = $this->client->getMergedSettings();
|
||||||
|
|
||||||
$this->settings->custom_taxes1 = false;
|
$this->settings->custom_taxes1 = false;
|
||||||
$this->settings->custom_taxes2 = false;
|
$this->settings->custom_taxes2 = false;
|
||||||
@ -168,7 +168,7 @@ trait MockAccountData
|
|||||||
$gs = new GroupSetting;
|
$gs = new GroupSetting;
|
||||||
$gs->company_id = $this->company->id;
|
$gs->company_id = $this->company->id;
|
||||||
$gs->user_id = $this->user->id;
|
$gs->user_id = $this->user->id;
|
||||||
$gs->settings = ClientSettings::buildClientSettings(new CompanySettings(CompanySettings::defaults()), new ClientSettings(ClientSettings::defaults()));
|
$gs->settings = ClientSettings::buildClientSettings(CompanySettings::defaults(), ClientSettings::defaults());
|
||||||
$gs->name = 'Default Client Settings';
|
$gs->name = 'Default Client Settings';
|
||||||
$gs->save();
|
$gs->save();
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ class BaseSettingsTest extends TestCase
|
|||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->settings = new ClientSettings(ClientSettings::defaults());
|
$this->settings = ClientSettings::defaults();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ class BaseSettingsTest extends TestCase
|
|||||||
|
|
||||||
$updated_object = $this->migrate($blank_object);
|
$updated_object = $this->migrate($blank_object);
|
||||||
|
|
||||||
$this->assertTrue(property_exists($updated_object, 'language_id'));
|
$this->assertTrue(property_exists($updated_object, 'size_id'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPropertyNamesNotExist()
|
public function testPropertyNamesNotExist()
|
||||||
|
@ -35,10 +35,10 @@ class CompanySettingsTest extends TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPropertyIsNotset()
|
public function testPropertyIssetOk()
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->assertFalse(isset($this->company_settings->custom_label1));
|
$this->assertTrue(isset($this->company_settings->custom_label1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,9 +19,9 @@ class CompareObjectTest extends TestCase
|
|||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->client_settings = new ClientSettings(ClientSettings::defaults());
|
$this->client_settings = ClientSettings::defaults();
|
||||||
|
|
||||||
$this->company_settings = new CompanySettings(CompanySettings::defaults());
|
$this->company_settings = CompanySettings::defaults();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ class CompareObjectTest extends TestCase
|
|||||||
public function buildClientSettings()
|
public function buildClientSettings()
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach($this->client_settings as $key => $value)
|
foreach($this->company_settings as $key => $value)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!isset($this->client_settings->{$key}) && property_exists($this->company_settings, $key))
|
if(!isset($this->client_settings->{$key}) && property_exists($this->company_settings, $key))
|
||||||
@ -52,12 +52,12 @@ class CompareObjectTest extends TestCase
|
|||||||
|
|
||||||
public function testDirectClientSettingsBuild()
|
public function testDirectClientSettingsBuild()
|
||||||
{
|
{
|
||||||
$settings = ClientSettings::buildClientSettings(new CompanySettings(CompanySettings::defaults()), new ClientSettings(ClientSettings::defaults()));
|
$settings = ClientSettings::buildClientSettings(CompanySettings::defaults(), ClientSettings::defaults());
|
||||||
|
|
||||||
$this->assertEquals($settings->timezone_id, 15);
|
$this->assertEquals($settings->timezone_id, 15);
|
||||||
$this->assertEquals($settings->language_id, 1);
|
$this->assertEquals($settings->language_id, 1);
|
||||||
$this->assertEquals($settings->payment_terms, 1);
|
$this->assertEquals($settings->payment_terms, 1);
|
||||||
$this->assertEquals($settings->custom_invoice_taxes1, 'FALSE');
|
$this->assertFalse($settings->custom_invoice_taxes1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -224,10 +224,12 @@ class GeneratesCounterTest extends TestCase
|
|||||||
public function testClientNumberPattern()
|
public function testClientNumberPattern()
|
||||||
{
|
{
|
||||||
$settings = $this->client->company->settings;
|
$settings = $this->client->company->settings;
|
||||||
$settings->client_number_prefix = null;
|
$settings->client_number_prefix = '';
|
||||||
$settings->client_number_pattern = '{$year}-{$user_id}-{$counter}';
|
$settings->client_number_pattern = '{$year}-{$user_id}-{$counter}';
|
||||||
$this->client->company->settings = $settings;
|
$this->client->company->settings = $settings;
|
||||||
$this->client->company->save();
|
$this->client->company->save();
|
||||||
|
$this->client->save();
|
||||||
|
$this->client->fresh();
|
||||||
|
|
||||||
$client_number = $this->getNextClientNumber($this->client);
|
$client_number = $this->getNextClientNumber($this->client);
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class GroupSettingsTest extends TestCase
|
|||||||
$this->makeTestData();
|
$this->makeTestData();
|
||||||
|
|
||||||
$this->company_settings = CompanySettings::defaults();
|
$this->company_settings = CompanySettings::defaults();
|
||||||
$this->client->settings = new ClientSettings(ClientSettings::defaults());
|
$this->client_settings = ClientSettings::buildClientSettings($this->company_settings, ClientSettings::defaults());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -36,39 +36,44 @@ class GroupSettingsTest extends TestCase
|
|||||||
{
|
{
|
||||||
|
|
||||||
$this->company_settings->timezone_id = 'fluffy';
|
$this->company_settings->timezone_id = 'fluffy';
|
||||||
$this->client->company->settings = $this->company_settings;
|
$this->company->settings = $this->company_settings;
|
||||||
|
$this->company->save();
|
||||||
|
|
||||||
$this->assertEquals($this->client->company->settings->timezone_id, 'fluffy');
|
$this->client_settings->timezone_id = '1';
|
||||||
$this->assertEquals($this->client->getSetting('timezone_id'), 'fluffy');
|
$this->client->settings = $this->client_settings;
|
||||||
$this->assertEquals($this->client->getMergedSettings()->timezone_id, 'fluffy');
|
$this->client->save();
|
||||||
|
|
||||||
|
$this->assertEquals($this->client->settings->timezone_id, '1');
|
||||||
|
$this->assertEquals($this->client->getSetting('timezone_id'), '1');
|
||||||
|
$this->assertEquals($this->client->getMergedSettings()->timezone_id, '1');
|
||||||
|
|
||||||
|
$this->assertEquals($this->company->settings->timezone_id, 'fluffy');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testGroupDefaults()
|
public function testGroupDefaults()
|
||||||
{
|
{
|
||||||
|
|
||||||
$cs = $this->client->company->settings;
|
$cs = $this->company->settings;
|
||||||
$cs->timezone_id = NULL;
|
$cs->timezone_id = '';
|
||||||
|
|
||||||
$this->client->company->settings = $cs;
|
$this->company->settings = $cs;
|
||||||
|
|
||||||
$gs = $this->client->group_settings->settings;
|
$gs = $this->client->group_settings->settings;
|
||||||
$gs->timezone_id = 'SPOCK';
|
$gs->timezone_id = 'SPOCK';
|
||||||
|
|
||||||
$this->client->group_settings->settings = $gs;
|
$this->client->group_settings->settings = $gs;
|
||||||
|
$this->client->save();
|
||||||
|
|
||||||
$cls = $this->client->settings;
|
$cls = $this->client->settings;
|
||||||
$cls->timezone_id = NULL;
|
$cls->timezone_id = '';
|
||||||
$cls->date_format = 'sharleen';
|
$cls->date_format = 'sharleen';
|
||||||
|
|
||||||
$this->client->settings = $cls;
|
$this->client->settings = $cls;
|
||||||
|
|
||||||
$this->client->group_settings->save();
|
|
||||||
$this->client->company->save();
|
|
||||||
$this->client->save();
|
$this->client->save();
|
||||||
|
|
||||||
$this->client->fresh();
|
$this->client->company->save();
|
||||||
|
$this->client->save();
|
||||||
|
|
||||||
$this->assertEquals($this->client->group_settings->settings->timezone_id, 'SPOCK');
|
$this->assertEquals($this->client->group_settings->settings->timezone_id, 'SPOCK');
|
||||||
$this->assertEquals($this->client->getSetting('timezone_id'), 'SPOCK');
|
$this->assertEquals($this->client->getSetting('timezone_id'), 'SPOCK');
|
||||||
|
@ -18,7 +18,7 @@ class GroupTest extends TestCase
|
|||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->settings = ClientSettings::buildClientSettings(new CompanySettings(CompanySettings::defaults()), new ClientSettings(ClientSettings::defaults()));
|
$this->settings = ClientSettings::buildClientSettings(CompanySettings::defaults(), ClientSettings::defaults());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,6 @@ class InvoiceTest extends TestCase
|
|||||||
$this->invoice->tax_name1 = 'GST';
|
$this->invoice->tax_name1 = 'GST';
|
||||||
$this->invoice->tax_rate1 = 10;
|
$this->invoice->tax_rate1 = 10;
|
||||||
|
|
||||||
|
|
||||||
$this->invoice_calc->build();
|
$this->invoice_calc->build();
|
||||||
|
|
||||||
$this->assertEquals($this->invoice_calc->getSubTotal(), 20);
|
$this->assertEquals($this->invoice_calc->getSubTotal(), 20);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user