Bug in API recurring invoice

I think i found a bug in API. When I execute the following command the invoice sent to costumer has “invoice_number” like the microtime() PHP function, but all recurring invoices were supposed to have numbers as “R0001”.
The invoice with number microtime() does not apear on the admin panel and has no button to pay on the client portal.

curl -X POST ninja.comain.tld/api/v1/invoices -H "Content-Type:application/json" -d '{"email":"clientmail@domain.tld", "frequency_id":1, "is_recurring":true,"start_date":"2016-05-01", "end_date":"", "invoice_items":[{"product_key": "ITEM", "notes":"Test", "cost":10, "qty":1}], "email_invoice":true}' -H "X-Ninja-Token:ThatBigString" -H "X-Requested-With: XMLHttpRequest"

Invoice Ninja Self-Hosted.
When manually click on “Send Invoice”, at the recurring invoice page, everything works fine.

Looks like the API doesn’t know what to do when the “invoice_number” is empty and put there the microtime().

Mail sent to client: http://prnt.sc/d2ttx2
No link for the costumer pay: http://prnt.sc/d2tu5r

The bug happens when execute the following command too:

curl -X POST ninja.domain.tld/api/v1/email_invoice -H "Content-Type:application/json" -d '{"id":INVOICE_ID}' -H "X-Ninja-Token: thatBigString" -H "X-Requested-With: XMLHttpRequest"

I think the problem here is recurring invoices aren’t meant to be emailed, they generate standard invoices which are then emailed.

You should be able to workaround this by calling php artisan ninja:send-invoices after creating the recurring invoice.

We’ll correct the API in our next release.

It works. It’s not the best solution but is good enough. Everything is working as expected.

Thanks for letting us know, we’ll look into improving the API to handle this case.