diff --git a/app/DataMapper/BaseSettings.php b/app/DataMapper/BaseSettings.php index 0be23161cc05..479f0cc349ec 100644 --- a/app/DataMapper/BaseSettings.php +++ b/app/DataMapper/BaseSettings.php @@ -57,4 +57,9 @@ class BaseSettings } } + public static function castSingleAttribute($key, $data) + { + + } + } \ No newline at end of file diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index 431a736af51c..43e8a04dde3a 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -154,8 +154,12 @@ class CompanySettings extends BaseSettings public $has_custom_design2 = ''; public $has_custom_design3 = ''; public $enable_portal_password = false; + public $show_accept_invoice_terms = false; + public $show_accept_quote_terms = false; public static $casts = [ + 'show_accept_quote_terms' => 'false', + 'show_accept_invoice_terms' => 'false', 'timezone_id' => 'string', 'date_format' => 'string', 'datetime_format' => 'string', @@ -250,6 +254,7 @@ class CompanySettings extends BaseSettings */ public static function defaults() : \stdClass { + $config = json_decode(config('ninja.settings')); $data = (object)get_class_vars(CompanySettings::class); @@ -266,6 +271,29 @@ class CompanySettings extends BaseSettings $data->translations = (object) []; return self::setCasts($data, self::$casts); + + } + + /** + * In case we update the settings object in the future we + * need to provide a fallback catch on old settings objects which will + * set new properties to the object prior to being returned. + * + * @param object $data The settings object to be checked + */ + public static function setProperties($settings) :\stdClass + { + + $company_settings = (object)get_class_vars(CompanySettings::class); + + foreach($company_settings as $key => $value) + { + + if(!property_exists($data, $key)) + $settings->{$key} = self::castAttribute($key, $company_settings->{$key}); + + } + return $settings; } } diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php index be0ef7fee459..1bb91f728d2f 100644 --- a/app/Http/Controllers/ClientPortal/InvoiceController.php +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -122,7 +122,7 @@ class InvoiceController extends Controller $total = $invoices->sum('balance'); - + $invoices->filter(function ($invoice){ return $invoice->isPayable(); })->map(function ($invoice){ @@ -138,6 +138,7 @@ class InvoiceController extends Controller $payment_methods = auth()->user()->client->getPaymentMethods($total); $data = [ + 'settings' => auth()->user()->client->getMergedSettings(), 'invoices' => $invoices, 'formatted_total' => $formatted_total, 'payment_methods' => $payment_methods, diff --git a/app/Models/Client.php b/app/Models/Client.php index 5694dd41aaaa..14de710080bb 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -173,7 +173,7 @@ class Client extends BaseModel * * @return object stdClass object of settings */ - public function getMergedSettings() + public function getMergedSettings() :object { if($this->group_settings !== null) @@ -185,7 +185,7 @@ class Client extends BaseModel } - return ClientSettings::buildClientSettings($this->company->settings, $this->settings); + return CompanySettings::setProperties(ClientSettings::buildClientSettings($this->company->settings, $this->settings)); } /** diff --git a/resources/views/portal/default/gateways/stripe/add_credit_card.blade.php b/resources/views/portal/default/gateways/stripe/add_credit_card.blade.php index c9af76966c75..9db743ab6485 100644 --- a/resources/views/portal/default/gateways/stripe/add_credit_card.blade.php +++ b/resources/views/portal/default/gateways/stripe/add_credit_card.blade.php @@ -70,8 +70,8 @@ ).then(function(result) { if (result.error) { // Display error.message in your UI. - console.log(result.error); - console.log(result.error.message); + // console.log(result.error); + // console.log(result.error.message); $("#card-errors").empty(); $("#card-errors").append("" + result.error.message + ""); diff --git a/resources/views/portal/default/invoices/payment.blade.php b/resources/views/portal/default/invoices/payment.blade.php index 7397f928ec1b..2e8c08b54afa 100644 --- a/resources/views/portal/default/invoices/payment.blade.php +++ b/resources/views/portal/default/invoices/payment.blade.php @@ -97,7 +97,7 @@