Skip to content

Invoice creation is non-idempotent, resulting in possible duplicate invoices #25

@joshmcclain

Description

@joshmcclain

It seems like two invoice creation attempts ran concurrently, causing duplicate invoices for some projects to be created in Quickbooks. Which projects were duplicated seems to be a function of whether the earlier creation attempt had completed for a particular project by the time the second attempt began running.

This line in InvoiceTracker.rb is intended to bail out of invoice generation if a prior QuickBooks invoice is already assigned to the invoice tracker model. However, since this association is only updated at the end of an invoicing run, it's possible for two runs to detect that no invoice exists, and then race each other for completion.

This line in Stacks::Automator intends to do the same thing (checking whether the invoice pass is marked as complete), but suffers from the same potential race condition.

We should probably have an idempotent guard / soft lock on the invoice pass model indicating whether invoice creation is in progress.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions