Found a bug !
If you apply this solution to GL Journal (or any document that support Re-activation), you can create holes. Because the number is set in the completeIt.
So if you complete, then reactivate, and then complete again, your document has new number !
Steps to reproduce (i've just done it on demo.globallqss.com):
Window Document type :
Document sequence = Temporary Sequence
Check Overwirte n° on complete and select GL Journal for Definite Sequence
Create new Journal Batch (using GL Journal as Doc type)
Complete it. Write down numbers (fot both batch and journal)
Complete it again.
Numbers have been updated.
IMHO, updating journals numbers seems not too risky, but if you allow users to reactivate invoices, that could become complicated
Maybe the call to setDefiniteDocumentNo should be based on the previous status of the document ? (if drafted, you call it, otherwise, you don't) ?