Set valid until when a quote is marked as sent

This commit is contained in:
David Bomba 2021-04-01 19:07:32 +11:00
parent 3b9ffb431f
commit 3a770361aa
2 changed files with 11 additions and 0 deletions

View File

@ -139,6 +139,8 @@ class CompanySettings extends BaseSettings
public $payment_type_id = '0'; //@TODO where do we use this? public $payment_type_id = '0'; //@TODO where do we use this?
// public $invoice_fields = ''; //@TODO is this redundant, we store this in the custom_fields on the company? // public $invoice_fields = ''; //@TODO is this redundant, we store this in the custom_fields on the company?
public $valid_until = ''; //@implemented
public $show_accept_invoice_terms = false; //@TODO ben to confirm public $show_accept_invoice_terms = false; //@TODO ben to confirm
public $show_accept_quote_terms = false; //@TODO ben to confirm public $show_accept_quote_terms = false; //@TODO ben to confirm
public $require_invoice_signature = false; //@TODO ben to confirm public $require_invoice_signature = false; //@TODO ben to confirm
@ -430,6 +432,7 @@ class CompanySettings extends BaseSettings
'show_accept_quote_terms' => 'bool', 'show_accept_quote_terms' => 'bool',
'show_accept_invoice_terms' => 'bool', 'show_accept_invoice_terms' => 'bool',
'timezone_id' => 'string', 'timezone_id' => 'string',
'valid_until' => 'string',
'date_format_id' => 'string', 'date_format_id' => 'string',
'military_time' => 'bool', 'military_time' => 'bool',
'language_id' => 'string', 'language_id' => 'string',

View File

@ -14,6 +14,7 @@ namespace App\Services\Quote;
use App\Events\Quote\QuoteWasMarkedSent; use App\Events\Quote\QuoteWasMarkedSent;
use App\Models\Quote; use App\Models\Quote;
use App\Utils\Ninja; use App\Utils\Ninja;
use Carbon\Carbon;
class MarkSent class MarkSent
{ {
@ -37,6 +38,13 @@ class MarkSent
$this->quote->markInvitationsSent(); $this->quote->markInvitationsSent();
if ($this->quote->due_date != '' || $this->quote->client->getSetting('valid_until') == '') {
}
else{
$this->quote->due_date = Carbon::parse($this->quote->date)->addDays($this->quote->client->getSetting('valid_until'));
}
event(new QuoteWasMarkedSent($this->quote, $this->quote->company, Ninja::eventVars())); event(new QuoteWasMarkedSent($this->quote, $this->quote->company, Ninja::eventVars()));
$this->quote $this->quote