Asynchronous invoice creation exposes a FreeAgent API bug

Hi,

I made a node app (here, if you’re interested - https://github.com/codeenigma/billder) to create invoices based on customer AWS usage. I have one small problem. Sometimes, because node is asynchronous, it creates two invoices at almost the same time. While the invoice ID safely auto-increments, the invoice title (e.g. “Invoice 002”) does not always. It’s possible to get two or three invoices created with the same title number. Take a look:

For now I’ll fix this by putting a random timer in to dramatically reduce the chances of two invoice creations happening in the same second.

Thanks,

Greg