diff --git a/app/Factory/CloneCreditFactory.php b/app/Factory/CloneCreditFactory.php index 070f8239ee8b..19966346314a 100644 --- a/app/Factory/CloneCreditFactory.php +++ b/app/Factory/CloneCreditFactory.php @@ -25,7 +25,7 @@ class CloneCreditFactory $clone_credit->due_date = null; $clone_credit->partial_due_date = null; $clone_credit->user_id = $user_id; - $clone_credit->balance = $credit->amount; + //$clone_credit->balance = $credit->amount; $clone_credit->line_items = $credit->line_items; return $clone_credit; diff --git a/app/Factory/CloneCreditToQuoteFactory.php b/app/Factory/CloneCreditToQuoteFactory.php index 0013ca28303e..17adc7706d94 100644 --- a/app/Factory/CloneCreditToQuoteFactory.php +++ b/app/Factory/CloneCreditToQuoteFactory.php @@ -39,7 +39,7 @@ class CloneCreditToQuoteFactory $quote->custom_value3 = $credit->custom_value3; $quote->custom_value4 = $credit->custom_value4; $quote->amount = $credit->amount; - $quote->balance = $credit->balance; + //$quote->balance = $credit->balance; $quote->partial = $credit->partial; $quote->partial_due_date = $credit->partial_due_date; $quote->last_viewed = $credit->last_viewed; @@ -49,7 +49,7 @@ class CloneCreditToQuoteFactory $quote->date = null; $quote->due_date = null; $quote->partial_due_date = null; - $quote->balance = $credit->amount; + // $quote->balance = $credit->amount; $quote->line_items = $credit->line_items; return $quote; diff --git a/app/Factory/CloneInvoiceFactory.php b/app/Factory/CloneInvoiceFactory.php index a070564ccf4a..a7423415c70b 100644 --- a/app/Factory/CloneInvoiceFactory.php +++ b/app/Factory/CloneInvoiceFactory.php @@ -24,7 +24,7 @@ class CloneInvoiceFactory $clone_invoice->due_date = null; $clone_invoice->partial_due_date = null; $clone_invoice->user_id = $user_id; - $clone_invoice->balance = $invoice->amount; + //$clone_invoice->balance = $invoice->amount; $clone_invoice->amount = $invoice->amount; $clone_invoice->line_items = $invoice->line_items; diff --git a/app/Factory/CloneInvoiceToQuoteFactory.php b/app/Factory/CloneInvoiceToQuoteFactory.php index 358427b02f8d..6055311db95c 100644 --- a/app/Factory/CloneInvoiceToQuoteFactory.php +++ b/app/Factory/CloneInvoiceToQuoteFactory.php @@ -38,7 +38,7 @@ class CloneInvoiceToQuoteFactory $quote->custom_value3 = $invoice->custom_value3; $quote->custom_value4 = $invoice->custom_value4; $quote->amount = $invoice->amount; - $quote->balance = $invoice->amount; + //$quote->balance = $invoice->amount; $quote->partial = $invoice->partial; $quote->partial_due_date = $invoice->partial_due_date; $quote->last_viewed = $invoice->last_viewed; diff --git a/app/Factory/CloneQuoteFactory.php b/app/Factory/CloneQuoteFactory.php index 142e66ac9506..74617c557cce 100644 --- a/app/Factory/CloneQuoteFactory.php +++ b/app/Factory/CloneQuoteFactory.php @@ -24,7 +24,7 @@ class CloneQuoteFactory $clone_quote->due_date = null; $clone_quote->partial_due_date = null; $clone_quote->user_id = $user_id; - $clone_quote->balance = $quote->amount; + //$clone_quote->balance = $quote->amount; $clone_quote->amount = $quote->amount; $clone_quote->line_items = $quote->line_items; diff --git a/app/Factory/CloneQuoteToInvoiceFactory.php b/app/Factory/CloneQuoteToInvoiceFactory.php index e147cb7a3444..a2626d47dda6 100644 --- a/app/Factory/CloneQuoteToInvoiceFactory.php +++ b/app/Factory/CloneQuoteToInvoiceFactory.php @@ -38,6 +38,7 @@ class CloneQuoteToInvoiceFactory $invoice->partial_due_date = null; $invoice->number = null; $invoice->date = now()->format('Y-m-d'); + $invoice->balance = 0; return $invoice; } } diff --git a/app/Factory/InvoiceToRecurringInvoiceFactory.php b/app/Factory/InvoiceToRecurringInvoiceFactory.php index 04ea7a37b3cd..d63565980586 100644 --- a/app/Factory/InvoiceToRecurringInvoiceFactory.php +++ b/app/Factory/InvoiceToRecurringInvoiceFactory.php @@ -42,7 +42,7 @@ class InvoiceToRecurringInvoiceFactory $recurring_invoice->custom_value3 = $invoice->custom_value3; $recurring_invoice->custom_value4 = $invoice->custom_value4; $recurring_invoice->amount = $invoice->amount; - $recurring_invoice->balance = $invoice->balance; + // $recurring_invoice->balance = $invoice->balance; $recurring_invoice->user_id = $invoice->user_id; $recurring_invoice->client_id = $invoice->client_id; $recurring_invoice->company_id = $invoice->company_id; diff --git a/app/Repositories/ActivityRepository.php b/app/Repositories/ActivityRepository.php index 1e81e79acc26..d32c9de6a2b4 100644 --- a/app/Repositories/ActivityRepository.php +++ b/app/Repositories/ActivityRepository.php @@ -120,6 +120,12 @@ class ActivityRepository extends BaseRepository $entity_design_id = $entity->design_id ? $entity->design_id : $this->decodePrimaryKey($entity->client->getSetting($entity_design_id)); $design = Design::find($entity_design_id); + + if(!$entity->invitations()->exists()){ + nlog("No invitations for entity {$entity->id} - {$entity->number}"); + return; + } + $html = new HtmlEngine($entity->invitations->first()); if ($design->is_custom) { diff --git a/app/Services/Quote/ConvertQuote.php b/app/Services/Quote/ConvertQuote.php index 0a6b226e3f2f..b3b947ee40de 100644 --- a/app/Services/Quote/ConvertQuote.php +++ b/app/Services/Quote/ConvertQuote.php @@ -40,8 +40,8 @@ class ConvertQuote $invoice->fresh(); $invoice->service() - ->markSent() - ->createInvitations() + // ->markSent() + // ->createInvitations() ->save(); $quote->invoice_id = $invoice->id; diff --git a/app/Services/Quote/QuoteService.php b/app/Services/Quote/QuoteService.php index 4feefda7b944..fbf53e623a37 100644 --- a/app/Services/Quote/QuoteService.php +++ b/app/Services/Quote/QuoteService.php @@ -38,17 +38,20 @@ class QuoteService return $this; } - public function markApproved() - { - $mark_approved = new MarkApproved($this->quote->client); - $this->quote = $mark_approved->run($this->quote); + // public function markApproved() + // { + // $mark_approved = new MarkApproved($this->quote->client); + // $this->quote = $mark_approved->run($this->quote); - if ($this->quote->client->getSetting('auto_convert_quote') === true) { - $this->convert(); - } + // if ($this->quote->client->getSetting('auto_convert_quote') == true) { + // $this->convert(); + // } - return $this; - } + // $this->markSent() + // ->createInvitations(); + + // return $this; + // } public function convert() :self { @@ -116,12 +119,18 @@ class QuoteService event(new QuoteWasApproved($contact, $this->quote, $this->quote->company, Ninja::eventVars())); - $invoice = null; - if ($this->quote->client->getSetting('auto_convert_quote')) { $this->convert(); + + $this->invoice + ->service() + ->markSent() + ->createInvitations() + ->save(); + } + if ($this->quote->client->getSetting('auto_archive_quote')) { $quote_repo = new QuoteRepository(); $quote_repo->archive($this->quote); @@ -134,11 +143,13 @@ class QuoteService { //to prevent circular references we need to explicit call this here. - $mark_approved = new MarkApproved($this->quote->client); - $this->quote = $mark_approved->run($this->quote); + // $mark_approved = new MarkApproved($this->quote->client); + // $this->quote = $mark_approved->run($this->quote); $this->convert(); + $this->invoice->service()->createInvitations(); + return $this->invoice; }