Merge pull request #5156 from turbo124/v5-develop

Tuning company settings for missing properties
This commit is contained in:
David Bomba 2021-03-17 21:07:17 +11:00 committed by GitHub
commit 3a0624e649
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 2 deletions

View File

@ -108,6 +108,7 @@ class CompanySettings extends BaseSettings
public $project_number_counter = 1; //@implemented
public $shared_invoice_quote_counter = false; //@implemented
public $shared_invoice_credit_counter = false; //@implemented
public $recurring_number_prefix = 'R'; //@implemented
public $reset_counter_frequency_id = '0'; //@implemented
public $reset_counter_date = ''; //@implemented
@ -262,6 +263,7 @@ class CompanySettings extends BaseSettings
public $hide_empty_columns_on_pdf = false;
public static $casts = [
'shared_invoice_credit_counter' => 'bool',
'reply_to_name' => 'string',
'hide_empty_columns_on_pdf' => 'bool',
'enable_reminder_endless' => 'bool',

View File

@ -304,6 +304,10 @@ class Client extends BaseModel implements HasLocalePreference
return $this->company->settings->{$setting};
}
elseif( property_exists(CompanySettings::defaults(), $setting) ) {
return CompanySettings::defaults()->{$setting};
}
return '';
// throw new \Exception("Settings corrupted", 1);

View File

@ -13,6 +13,7 @@ namespace App\Services\BillingSubscription;
use App\DataMapper\InvoiceItem;
use App\Factory\InvoiceFactory;
use App\Models\BillingSubscription;
use App\Models\ClientSubscription;
use App\Models\Product;
use App\Repositories\InvoiceRepository;
@ -41,7 +42,7 @@ class BillingSubscriptionService
// 'line_items' => [],
// ];
$invoice = $invoice_repo->save($data, InvoiceFactory::create($billing_subscription->company_id, $billing_subscription->user_id));
$invoice = $invoice_repo->save($data, InvoiceFactory::create($this->billing_subscription->company_id, $this->billing_subscription->user_id));
/*
If trial_enabled -> return early

View File

@ -134,6 +134,9 @@ trait GeneratesCounter
return 'payment_number_counter';
break;
case Credit::class:
if ($this->hasSharedCounter($client))
return 'invoice_number_counter';
return 'credit_number_counter';
break;
case Project::class:
@ -313,7 +316,7 @@ trait GeneratesCounter
*/
public function hasSharedCounter(Client $client) : bool
{
return (bool) $client->getSetting('shared_invoice_quote_counter');
return (bool) $client->getSetting('shared_invoice_quote_counter') || (bool) $client->getSetting('shared_invoice_credit_counter');
}
/**