Selecting contacts automatically on recurring invoices


I am not a developer but I know enough to be dangerous.

Basically we have staff members who modify the email addresses for a client. Our staff occasionally forgets to open every recurring invoice, check all the boxes for all the email addresses and save the changes. This is important because sometimes invoices do not get paid and clients get mad. The customer’s complaint usually starts with, “I gave you guys the new email address(es)… why didn’t yous end so and so a copy so he could pay it?”.

I have a simple cron job:
*/15 * * * * /usr/bin/mysql -e ‘update ninja.contacts set send_invoice=1’

If I open the recurring invoice it still shows the missing email addresses are unchecked and the invoices are not sent.

Before I start breaking stuff… Where can I make the appropriate changes so recurring invoices are always sent to all contacts?

I appreciate any thoughts / help anyone could provide.

The previous message above should read:

“I gave you guys the new email address(es)… why didn’t you send him/her a copy so s/he could pay it?”.

I apologize for the poor proofreading.

I made it a little further in my quest.

I assumed when you load the invoice, it pulls a list of contacts and if ninja.contacts.send_invoice=1 then it would check the box indicating the client would receive a copy of the invoice. I also wrongly assumed the ninja:send-invoices script would generate the appropriate ninja.invitations table entries.

I now understand that checking the box on the invoice and clicking SAVE is what causes the invitations table entry. I still cannot figure out what the send_invoice column is even used for.

I am still back at square one. I really do not want to go through every invoice manually, check the boxes and save the invoice. I also do not want too mess with the invitations table directly because I suspect that could cause problems later.

Anyone have any thoughts on the “correct” way to do this either using bash or a PHP script?

The send_invoice column is used to determine whether or not to send to the contact by default when creating new invoices manually. When a recurring invoice generates a standard invoice it uses its list of invitations (which was determined from the send_invoice field) to determine who to include in the invoice.

Going back to the original problem… are they deleting the old contact and adding a new one or are they updating the old contact’s email address? The former may cause this issue while the latter may not. Also, it may make a difference if they update the info on the edit client page versus the edit invoice page.

Here is what I am trying to accomplish.

  • Helpdesk creates new client.
  • Helpdesk creates new recurring invoice.

<time passes… days… months… etc… >

  • Client provides additional email address for monthly invoice.
  • Helpdesk goes to client page in Invoice Ninja
  • Helpdesk clicks ADD CONTACT and enters the contact’s email address.
  • Helpdesk saves client.

Now we have a new contact. The problem is our customer will not receive their monthly recurring invoice unless someone actively edits the recurring invoice and checks the box next to the new contact.

My preferred solution would be a cron script that looks for any contact where ninja.contacts.auto_bill=0 and automatically updates all associated recurring invoices for the client so the contact receives their monthly invoice.

If this is not possible then my solution at the moment is to simply email Helpdesk a list of all contacts where auto_bill=0 and have them manually go back and fix the recurring invoice. I would just prefer to automate this change instead of depending on a human to do it.

Of course I also know this flexibility (choosing to associate a contact with a recurring invoice) is good. Some customers do not want all contacts to receive all invoices.

Does all of this make sense?

Thanks, that makes sense.

If they can update the client as part of the recurring invoice, rather than on the client page, I believe it should include the new contacts in future invoices.

You are correct.

At the moment our CRM links directly to the client page (based on the account number).

I do not see an easy solution to our problem. I certainly do not believe Invoice Ninja should be automatically updating recurring invoices when new contacts are added.

For now we will just use a cron job to alert Helpdesk if any contacts are not selected on the recurring invoices.