1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Working on recurring invoices + reminders

This commit is contained in:
David Bomba 2020-09-08 21:01:55 +10:00
parent 84ec6b35cd
commit f8f8da830e
2 changed files with 7 additions and 4 deletions

View File

@ -37,7 +37,7 @@ class RecurringInvoicesCron
public function handle() : void
{
/* Get all invoices where the send date is less than NOW + 30 minutes() */
info("Sending recurring invoices {now()}");
info("Sending recurring invoices {Carbon::now()->format('Y-m-d h:i:s')}");
if (! config('ninja.db.multi_db_enabled')) {
@ -56,7 +56,7 @@ class RecurringInvoicesCron
$recurring_invoices = RecurringInvoice::where('next_send_date', '<=', Carbon::now()->addMinutes(30))->cursor();
Log::info(Carbon::now()->addMinutes(30).' Sending Recurring Invoices. Count = '.$recurring_invoices->count().'On Database # '.$db);
Log::info(Carbon::now()->addMinutes(30).' Sending Recurring Invoices. Count = '.$recurring_invoices->count().' On Database # '.$db);
$recurring_invoices->each(function ($recurring_invoice, $key) {
SendRecurring::dispatch($recurring_invoice, $recurring_invoice->company->db);

View File

@ -56,16 +56,19 @@ class ReminderJob implements ShouldQueue
$this->processReminders($db);
}
}
}
private function processReminders($db = null)
{
Invoice::where('next_send_date', Carbon::today()->format('Y-m-d'))->with('invitations')->cursor()->each(function ($invoice) {
if ($invoice->isPayable()) {
$reminder_template = $invoice->calculateTemplate();
$invoice->service()->touchReminder($this->reminder_template)->save();
$invoice->invitations->each(function ($invitation) use ($invoice) {
$email_builder = (new InvoiceEmail())->build($invitation);