Update on invoicing problems

| | Comments (0)
I believe we may have found the 'how' of the bug though not the why.

The invoice creation code depends on the last date an invoice was generated for and the time period between invoices. The last date an invoice is generated for is stored in the database.

We have database backups from before and after the first invoice creation job and have confirmed for at least one customer that the last invoiced date did not change. After the second invoice creation job, for at least this one customer the last invoiced date changed to the desired value. If it had not, multiple duplicate invoices would have been created for the affected customer.

Upon successful creation of an invoice, there is a call to update the last date an invoice was generated for.  These actions do not appear to be atomic. It also appears to be possible for the last invoiced date update to fail, and I cannot find any handling by the caller for failure. I have brought this to Blesta's attention and am waiting for their confirmation.

Unfortunately we don't have a concrete reason for why the update of the last invoiced date would have failed the first time and succeeded the second time. We're hoping that either blesta can give us an explanation or can help us reproduce the bug against the database backup before the first invoice creation job. However, if we can avoid duplicate invoices from being created in the future this is probably good enough.

To our best knowledge, the duplicate invoices are limited to 161 customers.

After the problem with blesta is fixed or worked around, we will manually verify the number of invoices created since the initial import from freeside, either with our own code or by having freeside generate invoices again.

Leave a comment

About this Entry

This page contains a single entry by srn published on March 30, 2015 5:53 PM.

Problems with invoicing was the previous entry in this blog.

Past due notices is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.