Refactors for excessive PDF generation

This commit is contained in:
David Bomba 2023-06-30 15:28:04 +10:00
parent cf4b87e701
commit 8017b589c2
6 changed files with 9 additions and 20 deletions

View File

@ -408,7 +408,7 @@ class InvoiceController extends BaseController
$invoice->service()
->triggeredActions($request)
->touchPdf()
->deletePdf()
->adjustInventory($old_invoice);
event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
@ -740,7 +740,8 @@ class InvoiceController extends BaseController
}
break;
case 'cancel':
$invoice = $invoice->service()->handleCancellation()->touchPdf()->save();
$invoice = $invoice->service()->handleCancellation()->deletePdf()->save();
// $invoice = $invoice->service()->handleCancellation()->touchPdf()->save();
if (! $bulk) {
$this->itemResponse($invoice);

View File

@ -362,7 +362,7 @@ class MatchBankTransactions implements ShouldQueue
$this->invoice
->service()
->applyNumber()
->touchPdf()
->deletePdf()
->save();
$payment->ledger()

View File

@ -208,7 +208,8 @@ class ReminderJob implements ShouldQueue
->markSent()
->save();
$invoice->service()->touchPdf(true);
//30-6-2023 - fix for duplicate touching
// $invoice->service()->touchPdf(true);
$enabled_reminder = 'enable_'.$reminder_template;
if ($reminder_template == 'endless_reminder') {
@ -268,7 +269,6 @@ class ReminderJob implements ShouldQueue
}
return [$late_fee_amount, $late_fee_percent];
// return $this->setLateFee($invoice, $late_fee_amount, $late_fee_percent);
}
/**

View File

@ -525,7 +525,7 @@ class BaseDriver extends AbstractPaymentDriver
$invoices = Invoice::whereIn('id', $this->transformKeys(array_column($this->payment_hash->invoices(), 'invoice_id')))->withTrashed()->get();
$invoices->each(function ($invoice) {
$invoice->service()->touchPdf();
$invoice->service()->deletePdf();
});
$invoices->first()->invitations->each(function ($invitation) use ($nmo) {
@ -570,7 +570,7 @@ class BaseDriver extends AbstractPaymentDriver
$invoices = Invoice::whereIn('id', $this->transformKeys(array_column($this->payment_hash->invoices(), 'invoice_id')))->withTrashed()->get();
$invoices->each(function ($invoice) {
$invoice->service()->touchPdf();
$invoice->service()->deletePdf();
});
$invoices->first()->invitations->each(function ($invitation) use ($nmo) {

View File

@ -44,9 +44,7 @@ class HandleCancellation extends AbstractService
$this->invoice->balance = 0;
$this->invoice = $this->invoice->service()->setStatus(Invoice::STATUS_CANCELLED)->save();
//adjust client balance
$this->invoice->client->service()->updateBalance($adjustment)->save();
// $this->invoice->fresh();
$this->invoice->service()->workFlow()->save();
@ -54,16 +52,6 @@ class HandleCancellation extends AbstractService
event('eloquent.updated: App\Models\Invoice', $this->invoice);
$transaction = [
'invoice' => $this->invoice->transaction_event(),
'payment' => [],
'client' => $this->invoice->client->transaction_event(),
'credit' => [],
'metadata' => [],
];
// TransactionLog::dispatch(TransactionEvent::INVOICE_CANCELLED, $transaction, $this->invoice->company->db);
return $this->invoice;
}

View File

@ -54,7 +54,7 @@ class TriggeredActions extends AbstractService
}
if ($this->request->has('send_email') && $this->request->input('send_email') == 'true') {
$this->invoice->service()->markSent()->touchPdf()->save();
$this->invoice->service()->markSent()->save();
$this->sendEmail();
$this->updated = false;
}