Fixes for recurring invoices where auto_email_invoice not set

This commit is contained in:
David Bomba 2021-11-30 16:05:15 +11:00
parent a4da2b0428
commit 5af0ad72e9
4 changed files with 13 additions and 5 deletions

View File

@ -112,6 +112,9 @@ class EmailEntity implements ShouldQueue
App::setLocale($this->invitation->contact->preferredLocale()); App::setLocale($this->invitation->contact->preferredLocale());
$t->replace(Ninja::transformTranslations($this->settings)); $t->replace(Ninja::transformTranslations($this->settings));
/* Mark entity sent */
$this->entity->service()->markSent()->save();
$nmo = new NinjaMailerObject; $nmo = new NinjaMailerObject;
$nmo->mailable = new TemplateEmail($this->email_entity_builder, $this->invitation->contact, $this->invitation); $nmo->mailable = new TemplateEmail($this->email_entity_builder, $this->invitation->contact, $this->invitation);
$nmo->company = $this->company; $nmo->company = $this->company;
@ -124,8 +127,7 @@ class EmailEntity implements ShouldQueue
NinjaMailerJob::dispatchNow($nmo); NinjaMailerJob::dispatchNow($nmo);
/* Mark entity sent */
$this->entity->service()->markSent()->save();
} }
private function resolveEntityString() :string private function resolveEntityString() :string

View File

@ -64,7 +64,7 @@ class QuoteEmailEngine extends BaseEmailEngine
[ [
'quote' => $this->quote->number, 'quote' => $this->quote->number,
'company' => $this->quote->company->present()->name(), 'company' => $this->quote->company->present()->name(),
'amount' => Number::formatMoney($this->quote->balance, $this->client), 'amount' => Number::formatMoney($this->quote->amount, $this->client),
], ],
null, null,
$this->client->locale() $this->client->locale()
@ -99,7 +99,6 @@ class QuoteEmailEngine extends BaseEmailEngine
->setViewText(ctrans('texts.view_quote')) ->setViewText(ctrans('texts.view_quote'))
->setInvitation($this->invitation); ->setInvitation($this->invitation);
if ($this->client->getSetting('pdf_email_attachment') !== false && $this->quote->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) { if ($this->client->getSetting('pdf_email_attachment') !== false && $this->quote->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
if(Ninja::isHosted()) if(Ninja::isHosted())

View File

@ -483,6 +483,10 @@ class InvoiceService
if(!isset($this->invoice->exchange_rate) && $this->invoice->client->currency()->id != (int) $this->invoice->company->settings->currency_id) if(!isset($this->invoice->exchange_rate) && $this->invoice->client->currency()->id != (int) $this->invoice->company->settings->currency_id)
$this->invoice->exchange_rate = $this->invoice->client->currency()->exchange_rate; $this->invoice->exchange_rate = $this->invoice->client->currency()->exchange_rate;
if($settings->counter_number_applied == 'when_saved'){
$this->invoice->service()->applyNumber()->save();
}
return $this; return $this;
} }

View File

@ -57,7 +57,10 @@ class TriggeredActions extends AbstractService
{ {
$reminder_template = $this->quote->calculateTemplate('quote'); $reminder_template = $this->quote->calculateTemplate('quote');
//$reminder_template = 'payment'; // $reminder_template = 'email_template_quote';
// nlog($reminder_template);
$this->quote->invitations->load('contact.client.country', 'quote.client.country', 'quote.company')->each(function ($invitation) use ($reminder_template) { $this->quote->invitations->load('contact.client.country', 'quote.client.country', 'quote.company')->each(function ($invitation) use ($reminder_template) {
EmailEntity::dispatch($invitation, $this->quote->company, $reminder_template); EmailEntity::dispatch($invitation, $this->quote->company, $reminder_template);