Recurring invoices did not send, then only partially sent

This morning at 9am EST our recurring invoices normally send. Have done just fine for a while.

Today they did not. I saw there was a invoice ninja update available, so i installed it and restarted the server. They only partially sent. Meaning not all of them that normally send were sent. Almost exactly half of them still have a next send date of today (4/25/2023). I have tried running the command manually… php artisan schedule:run >> /dev/null 2>&1 from the www folder i have ninja in. But they still won’t send.

here is my crontab entry:
* * * * * cd /var/www/html/ && php artisan schedule:run >> /dev/null 2>&1

the laravel log just has this for today…
[2023-04-25 06:20:02] production.INFO: Performing Autobilling 2023-04-25 06:20:02

nothing has changed with the server. I did change email templates for reminders, but only how many days out those send. that shouldn’t have affected the recurring invoices from sending?

What should I check?


@david do you have any suggestions?

More digging… some, the next send date is still set today, did actually generate and send.

Others it skipped entirely. I don’t see any commonality among those that didn’t send at all. they’re active and

I hope he’s paid well, he sure is tagged in a lot of these posts lol.


Not sure the following is the criteria for firing the Recurring Invoice

  1. company activated
  2. recurring invoice active
  3. client not deleted
  4. next_send_date less than NOW
  5. recurring invoice not archived
  6. remaining_cycles != 0

If you have changed the send time, we do adjust the sending time of the recurring invoice, could this explain the delay?

1-3, are all true. Criteria matches.
4, is it less than or less than or equal?
5. None of these are archived.
6. Is that a DB field?

I didn’t change the send time. Just the reminder templates on when how many days those are sent from the initial invoice date.

So I have three groups.

-Sent normally, show correct next send date. Nothing to do for these.
-Sent but didn’t update next send date. Should these have their next send date manually adjusted?
-Did not send, next send date is still today.

The last group, is there any indicators in the dB I should look for as a reason they may not have gotten picked up?

Looking at the DB, for whatever reason it stopped on recurring invoice id 20 and that recurring invoice didn’t get it’s “Next Send Date” updated.

apache logs show nothing. laravel log shows nothing.

While i am curious what might have caused this, how can I correct id’s 21 - 31 so they will send?

Here’s recurring invoice id 21 seen from phpMyAdmin:

Can you confirm none of the clients have been archived?

If you have access to the command line can you try running the following from the project root

php artisan tinker
RecurringInvoice::where('status_id', RecurringInvoice::STATUS_ACTIVE) \
        ->where('is_deleted', false) \
        ->where('remaining_cycles', '!=', '0') \
        ->whereNotNull('next_send_date') \
        ->whereNull('deleted_at') \
        ->where('next_send_date', '<=', now()->toDateTimeString()) \
        ->whereHas('client', function ($query) { \
            $query->where('is_deleted', 0) \
                   ->where('deleted_at', null); \
        }) \
        ->whereHas('company', function ($query) { \
            $query->where('is_disabled', 0); \
        }) \
        ->with('company') \

If the count comes back as 0 it means a pre condition has failed and the recurring invoice is not in a valid state for generating.

If the count comes back as another number, we’ll need to continue debugging.

@david count is 8

Not sure what timezone you’re in, i’m EST. I’ll be up early in the morning (4am EST usually), if you have a chance to send over other suggestions. These are some of my biggest invoices so I really need to get them out. I do appreciate all of the help.


Can you try running

php artisan ninja:send-recur

And advise if they do generate?

Last night at 10:01pm (EST) the rest of them sent.

Do they only generate and send according to the Email Send time setting? Or will they generate on the day they’re supposed to and then send when the time == the send time in the email settings?

I did double check my timezone on the server, it is set to UTC and the timezone in ninja is set to EST. So not sure why it finally decided to run the ones it missed.

Is there a log I can check for errors ?

I should add, after my last message i changed nothing. So i’m not sure why they finally sent at 10:01pm

They are generated and sent based on the email send time of the clients locale().

If you inspect the next_send_date_client column, it shows the UTC equivalent time that the invoice is sent.

2023-05-25 00:00:00 is what all of them are set to now.

The ones that didn’t send at all have a next client send date of 2023-05-25 00:00:00 but the next_send_date is 2023-05-26 02:00:00, which one is more important? We need them to all send on 5/25 at 9am. Do I need to mass up date the next_send_date to match the invoices that did send? those have a next_Send_date of 2023-05-25 14:00

The system is operating correctly, the next_send_date is what we display in the app, the next_send_date_client is the calculated time to send the recurring invoice based on the UTC time equivalent.

Depending on timezones, the actual UTC time may be the next day hence the discrepency

odd… theyve always sent at the correct time until April 25th. So i should make sure that the next_send_date_client is set to the UTC equivalent of 9am EST for May 25th?

The system will calculate and update that field each time you save the invoice. You should not have to do anything

revisting this. They failed to send this morning at 9AM EST (what is set in ninja email settings)

Example recurring invoice has a next_send_date_client of 2023-05-25 00:00:00, the invoice did not send this morning. none of them sent this morning.

It’s currently 1:57PM UTC as I type this. The system time is set to UTC and it shows: Thu May 25 01:57:01 PM UTC 2023

These are my settings in ninja for localization:

What can I check? I really need these to go out today.

and again, not all of them sent. The ones that didn’t send have a next_send_date of 2023-04-26 2:00:00, which are all the ones that sent late the last time. The ones that sent had a next_send_date of 2023-04-25 2:00:00

Does the system check next_send_date in anyway to help determine when to send these?