Invoice reminders are not sent

Hello team,

I’m using IN 5.6.6 and I assume one of the updates from last months broke the reminders.

Here are my reminder settings for the first reminder:

  • Days: 4
  • Schedule: After the due date
  • Send Email: yes

The “Due Date” and “Next Send Date” are shown correctly on every invoice, but although no reminder has been sent to the customer. In the “Activity”-Tab there is also no sign of the reminder.

I can send the reminder manually, but the “Next Send Date” stays the same.

Customer settings for reminders are empty (default).

I’ve set two cronjobs for IN:

  • Laravel Scheduler (artisan schedule:run) every minute
  • Database Queue (artisan queue:work) every 5 minutes

But I didn’t touch the cronjobs for a long time, so that shouldn’t be the problem.

Laravel.log also looks good for me:

[2023-06-21 23:30:03] production.INFO: updating currencies
[2023-06-22 06:20:04] production.INFO: Performing Autobilling 2023-06-22 06:20:04
[2023-06-22 23:30:03] production.INFO: updating currencies
[2023-06-23 06:20:02] production.INFO: Performing Autobilling 2023-06-23 06:20:02
[2023-06-23 23:30:04] production.INFO: updating currencies
[2023-06-24 06:20:02] production.INFO: Performing Autobilling 2023-06-24 06:20:02
[2023-06-24 23:30:04] production.INFO: updating currencies
[2023-06-25 06:20:02] production.INFO: Performing Autobilling 2023-06-25 06:20:02
[2023-06-25 23:30:03] production.INFO: updating currencies
[2023-06-26 06:20:02] production.INFO: Performing Autobilling 2023-06-26 06:20:02
[2023-06-26 23:30:03] production.INFO: updating currencies
[2023-06-27 06:20:02] production.INFO: Performing Autobilling 2023-06-27 06:20:02
[2023-06-27 09:15:02] production.INFO: available credit balance = 0
[2023-06-27 09:15:02] production.INFO: Auto Bill - balance remains to be paid!! - XXXXX
[2023-06-27 23:35:02] production.INFO: updating currencies
[2023-06-29 04:00:16] production.INFO: available credit balance = 0
[2023-06-29 04:00:16] production.INFO: Auto Bill - balance remains to be paid!! - XXXXX
[2023-06-29 06:20:02] production.INFO: Performing Autobilling 2023-06-29 06:20:02
[2023-06-29 23:30:04] production.INFO: updating currencies
[2023-06-30 06:20:02] production.INFO: Performing Autobilling 2023-06-30 06:20:02
[2023-06-30 23:30:03] production.INFO: updating currencies
[2023-07-01 06:20:02] production.INFO: Performing Autobilling 2023-07-01 06:20:02
[2023-07-01 09:01:11] production.INFO: available credit balance = 0
[2023-07-01 09:01:11] production.INFO: Auto Bill - balance remains to be paid!! - XXXXX

Any suggestions what to do, to get the reminders back to work? Thanks in advance for your help!

Hi,

@david do you have any suggestions?

So with advanced logging on you should be seeing something like this in your logs:

Sending invoice reminders on xxxxxxx 

For some reason none of your hourly crons are running? is your cron configuration definitely configured to


?

Thanks for your help!
I enabled advanced logging in .env-file with the instruction:

EXPANDED_LOGGING=true

And I performed (don’t know if that is necessary?)

php artisan optimize

But I can’t see something like

 Sending invoice reminders on xxxxxx

in laravel.log.

For some reason none of your hourly crons are running? is your cron configuration definitely configured to

I’ve got no hourly cronjobs.

  • I have one cronjob every minute: php artisan schedule:run
  • And I have one cronjob every 5 minutes: artisan queue:work --stop-when-empty

To be sure that both cronjobs are running, I changed them to send an email after work and got the following results:

2023-07-02 16:30:02 Running [queue-size-job] ..................... 26ms DONE
 2023-07-02 16:30:02 Running [stale-invoice-job] .................. 10ms DONE
 2023-07-02 16:30:02 Running [Callback] ........................... 31ms DONE
 2023-07-02 16:30:02 Running ['artisan' queue:work database --stop-when-empty --memory=256]  4,366ms DONE
 ⇂ '/opt/keyhelp/php/8.1/bin/php' 'artisan' queue:work database --stop-when-empty --memory=256 > '/dev/null' 2>&1  
 2023-07-02 16:30:06 Running ['artisan' queue:restart] ........... 504ms DONE
 ⇂ '/opt/keyhelp/php/8.1/bin/php' 'artisan' queue:restart > '/dev/null' 2>&1  

Seems fine to me, or is there anything I have to change?

Ok, I looked for the advanced logging in the wrong file. In invoiceninja.log I found this:

[2023-07-03 08:00:04] production.INFO: Sending invoice reminders on 2023-07-03 08:00:04
[2023-07-03 08:00:05] production.INFO: caught a duplicate reminder for invoice R-0136-0002
[2023-07-03 08:30:03] production.INFO: Cleaning Stale Invoices:
[2023-07-03 08:40:02] production.INFO: Updating calculated fields

How can I get rid of this duplicate reminder?

@meisterkeks

Ok, so the issue could be that you may have already send the reminder manually?

If you manually send the reminder email, the system will not “resend” another automatic one.

I looked it up. The reminder for invoice R-0136-0002 was not sent automatically at 2023-06-26, so I sent it manually at 2023-06-29 (that’s correctly in the activity-tab).

Unfortunately the “Next Send Date” still shows 2023-06-26.

But that’s not the big issue for me. More important is to sent the reminder automatically in the first place.

@david
For testing purposes, I created a new invoice “R-00000-0025” a few days ago. The reminder should have been sent today at 11 am.

No reminder was sent (automatically or manually). “Next Send Date” for the invoice still shows
09.07.2023. In invoiceninja.log, I found following error, although I have not manually sent a reminder:

[2023-07-09 11:00:06] production.INFO: caught a duplicate reminder for invoice R-00000-0025

if ($invoice->reminder_last_sent && Carbon::parse($invoice->reminder_last_sent)->startOfDay()->eq(now()->startOfDay())) {
 nlog("caught a duplicate reminder for invoice {$invoice->number}"); 
 return;
}

We watch for any invoices that were already sent on that day. If the query condition matches, we do not send an email twice to the user. This would mean that the last send date of this particular invoice was “today” What is the schedule you have configured for your reminders?

First reminder is set to 4 days after due date. Invoice R-00000-0025 was created at 2023-07-05. No reminder at all was sent yesterday (2023-07-09) automatically or manually.

I looked up some values in the table invoices for invoice R-00000-0025:

  • date: 2023-07-05
  • last _sent_date: 2023-07-10
  • due_date: 2023-07-05 00:00:00
  • next_send_date: 2023-07-09 09:00:00
  • created_at: 2023-07-04 23:30:58.025936
  • updated_at: 2023-07-10 00:00:18.641442
  • reminder1_sent: 2023-07-10
  • reminder_last_sent: 2023-07-10

Interestingly my other overdue invoice has also todays date (2023-07-10) for last_sent_date, reminder1_sent and reminder_last_sent. Further more it was also updated_at 2023-07-10 00:00:18.435063.

Hopefully any of this information helps.

Was the reminder sent on the 10th?

The other items which may “catch” and prevent this from sending is the send_reminders being disabled

The logic used here is as follows.

  1. Is the invoice still payable / overdue?
  2. Has a reminder already been sent today for this invoice? If yes, return early and no nothing else.
  3. Set today’s date as the reminder last sent date (prevents an endless loop from occurring is any of the following return true…)
  4. Is a late fee applicable? If yes - add the late fee to the invoice.
  5. Is this a reminder template? AND is this reminder enabled? AND is send emails enabled ?
  6. Send the reminder
  7. Set the next reminder if one is configured

Was the reminder sent on the 10th?

:x: Unfortunately not. invoiceninja.log shows the following error:

caught a duplicate reminder for invoice R-00000-0025
  1. Is the invoice still payable / overdue?

:heavy_check_mark: Check

  1. Has a reminder already been sent today for this invoice? If yes, return early and no nothing else.

:x: No reminder has been sent for this particular invoice or any other overdue invoice. Reminders at all aren’t sent anymore.

  1. Set today’s date as the reminder last sent date (prevents an endless loop from occurring is any of the following return true…)

:heavy_check_mark: I checked the database and last_sent_date is set to today for every overdue invoice.

  1. Is a late fee applicable? If yes - add the late fee to the invoice.

:x: No late fee.

  1. Is this a reminder template?

I don’t know what you mean by this. Attached you find my settings for the first reminder.

AND is this reminder enabled?

:heavy_check_mark: As shown in the screenshot above: It is enabled.

AND is send emails enabled?

:heavy_check_mark: The client setting Send Reminders was empty (default), but to avoid potential errors I set this option to Enabled.

  1. Send the reminder

:x: Does not happen.

  1. Set the next reminder if one is configured

:x: Does not happen.

Hello,

I have the exact same issue for several months now…
It was working as expected before.

Recurring invoices are still sent automatically without any issue, but not reminders.

With EXPANDED_LOGGING=true, I can confirm that invoiceninja.log also shows the error “caught a duplicate reminder for invoice XXXXX”, but no reminder e-Mail was sent. In the “invoices” table, I can also confirm the same behaviour at columns level.

It looks like the reminder is marked as sent without being sent, with the exception that the next_send_date is not updated. It stays stuck. No matter the number of reminders configured to being sent…

I would be very happy to get a solution for that issue too.

Thank you in advance for your help.

Hi,

Log with no reminder sent, either automatically or manually for both invoices XXXX64 and XXXX65:

[2023-07-26 08:00:03] production.INFO: Sending invoice reminders on 2023-07-26 08:00:03  
[2023-07-26 08:00:03] production.INFO: caught a duplicate reminder for invoice XXXX64  
[2023-07-26 08:00:03] production.INFO: caught a duplicate reminder for invoice XXXX65  
[2023-07-26 08:30:03] production.INFO: Cleaning Stale Invoices:  
[2023-07-26 08:40:02] production.INFO: Updating calculated fields

I’ve just tried to set reminder1_sent and reminder_last_sent to NULL for invoice XXXX64. I’ve also tried to change the hour in next_send_date to something in the near future (next hour). Here comes the log after that change:

[2023-07-26 09:00:02] production.INFO: Sending recurring invoices 2023-07-26 09:00:02  
[2023-07-26 09:00:02] production.INFO: 2023-07-26 Sending Recurring Invoices. Count = 0  
[2023-07-26 09:00:02] production.INFO: Recurring invoice send duration 2023-07-26 09:00:02 - 2023-07-26 09:00:02  
[2023-07-26 09:00:02] production.INFO: Sending invoice reminders on 2023-07-26 09:00:02  
[2023-07-26 09:00:02] production.INFO: caught a duplicate reminder for invoice XXXX65  

Nothing about XXXX64 in the log. After that, I’m back to the previous state at database level. reminder1_sent is set to today as well as reminder_last_sent for invoice XXXX64. However, no reminder e-Mail has been sent. No trace of it in activities or elsewhere. Is there something like “Invoice reminder send duration…” line missing in the log?

Update 5.6.24 fixed the problem. Thanks for your work!

1 Like