Adjustments for auto billing

This commit is contained in:
David Bomba 2024-03-18 09:03:34 +11:00
parent 8e431a4138
commit d2325bed7c
3 changed files with 15 additions and 5 deletions

View File

@ -55,7 +55,17 @@ class SmtpController extends BaseController
(new \Illuminate\Mail\MailServiceProvider(app()))->register();
try {
Mail::mailer('smtp')->to($user->email, $user->present()->name())->send(new TestMailServer('Email Server Works!', strlen($company->settings->custom_sending_email) > 1 ? $company->settings->custom_sending_email : $user->email));
$sending_email = (isset($company->settings->custom_sending_email) && stripos($company->settings->custom_sending_email, "@")) ? $company->settings->custom_sending_email : $user->email;
$sending_user = (isset($company->settings->email_from_name) && strlen($company->settings->email_from_name) > 2) ? $company->settings->email_from_name : $user->name();
$mailable = new TestMailServer('Email Server Works!', $sending_email);
$mailable->from($sending_email,$sending_user);
Mail::mailer('smtp')
->to($user->email, $user->present()->name())
->send($mailable);
} catch (\Exception $e) {
app('mail.manager')->forgetMailers();
return response()->json(['message' => $e->getMessage()], 400);

View File

@ -76,12 +76,12 @@ class SendRecurring implements ShouldQueue
$invoice = $invoice->service()
->markSent()
->applyNumber()
->fillDefaults()
->fillDefaults(true)
->adjustInventory()
->save();
} else {
$invoice = $invoice->service()
->fillDefaults()
->fillDefaults(true)
->save();
}

View File

@ -544,7 +544,7 @@ class InvoiceService
return $this;
}
public function fillDefaults()
public function fillDefaults(bool $is_recurring = false)
{
$this->invoice->load('client.company');
@ -571,7 +571,7 @@ class InvoiceService
$this->invoice->exchange_rate = $this->invoice->client->setExchangeRate();
}
if ($this->invoice->client->getSetting('auto_bill_standard_invoices')) {
if ($is_recurring && $this->invoice->client->getSetting('auto_bill_standard_invoices')) {
$this->invoice->auto_bill_enabled = true;
}