private function emailRecurringInvoice(&$invoice)
{
if (!$invoice->shouldSendToday()) {
if ($date = $invoice->getNextSendDate()) {
$date = $invoice->account->formatDate($date);
$date .= ' ' . DEFAULT_SEND_RECURRING_HOUR . ':00 am ' . $invoice->account->getTimezone();
return trans('texts.recurring_too_soon', ['date' => $date]);
} else {
return trans('texts.no_longer_running');
}
}
// switch from the recurring invoice to the generated invoice
$invoice = $this->invoiceRepo->createRecurringInvoice($invoice);
// in case auto-bill is enabled then a receipt has been sent
if ($invoice->isPaid()) {
return true;
} else {
return $this->mailer->sendInvoice($invoice);
}
}