Improve delete pdf performance

This commit is contained in:
David Bomba 2021-03-10 13:28:35 +11:00
parent 86d168e3a8
commit 9888d7acb9
3 changed files with 7 additions and 3 deletions

View File

@ -396,6 +396,8 @@ class InvoiceController extends BaseController
} }
$invoice = $this->invoice_repo->save($request->all(), $invoice); $invoice = $this->invoice_repo->save($request->all(), $invoice);
$invoice->service()->deletePdf();
event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars())); event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars()));
@ -697,14 +699,14 @@ class InvoiceController extends BaseController
} }
break; break;
case 'cancel': case 'cancel':
$invoice = $invoice->service()->handleCancellation()->save(); $invoice = $invoice->service()->handleCancellation()->deletePdf()->save();
if (! $bulk) { if (! $bulk) {
$this->itemResponse($invoice); $this->itemResponse($invoice);
} }
break; break;
case 'reverse': case 'reverse':
$invoice = $invoice->service()->handleReversal()->save(); $invoice = $invoice->service()->handleReversal()->deletePdf()->save();
if (! $bulk) { if (! $bulk) {
$this->itemResponse($invoice); $this->itemResponse($invoice);
@ -720,7 +722,7 @@ class InvoiceController extends BaseController
} }
//touch reminder1,2,3_sent + last_sent here if the email is a reminder. //touch reminder1,2,3_sent + last_sent here if the email is a reminder.
$invoice->service()->touchReminder($this->reminder_template)->save(); $invoice->service()->touchReminder($this->reminder_template)->deletePdf()->save();
$invoice->invitations->load('contact.client.country', 'invoice.client.country', 'invoice.company')->each(function ($invitation) use ($invoice) { $invoice->invitations->load('contact.client.country', 'invoice.client.country', 'invoice.company')->each(function ($invitation) use ($invoice) {
EmailEntity::dispatch($invitation, $invoice->company, $this->reminder_template); EmailEntity::dispatch($invitation, $invoice->company, $this->reminder_template);

View File

@ -74,6 +74,7 @@ class MarkPaid extends AbstractService
->updatePaidToDate($payment->amount) ->updatePaidToDate($payment->amount)
->setStatus(Invoice::STATUS_PAID) ->setStatus(Invoice::STATUS_PAID)
->applyNumber() ->applyNumber()
->deletePdf()
->save(); ->save();
if ($this->invoice->client->getSetting('client_manual_payment_notification')) if ($this->invoice->client->getSetting('client_manual_payment_notification'))

View File

@ -47,6 +47,7 @@ class MarkSent extends AbstractService
->applyNumber() ->applyNumber()
->setDueDate() ->setDueDate()
->updateBalance($this->invoice->amount) ->updateBalance($this->invoice->amount)
->deletePdf()
->save(); ->save();
$this->client->service()->updateBalance($this->invoice->balance)->save(); $this->client->service()->updateBalance($this->invoice->balance)->save();