Fixes for approve / convert quotes

This commit is contained in:
David Bomba 2021-01-20 08:30:04 +11:00
parent cfc144b6ec
commit 5ce2a035da
10 changed files with 40 additions and 22 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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) {

View File

@ -40,8 +40,8 @@ class ConvertQuote
$invoice->fresh();
$invoice->service()
->markSent()
->createInvitations()
// ->markSent()
// ->createInvitations()
->save();
$quote->invoice_id = $invoice->id;

View File

@ -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;
}