Good day everyone..To share
I have created DocumentNo BO:
- Type (Sales Invoice, Sales Debit Note etc)
- Prefix (SI-)
- Number (1000)
- Suffix (-2011)
- Next Document No (SI-1001-2011)
If DocumentNo.ID IS DEFINED Then
DocumentNo.NextDocumentNo=DocumentNo.Prefix+DocumentNo.Number+1+DocumentNo.Suffix
On the SalesInvoiceHeader:
If EXISTS SalesInvoiceHeader WHERE (SalesInvoiceHeader.DocumentNo=ThisSalesInvoiceHeader.DocumentNo AND SalesInvoiceHeader.ID<>ThisSalesInvoiceHeader.ID) Then
FIND DocumentNo WHERE DocumentNo.Type='Sales Invoice'
DocumentNo.Number=DocumentNo.Number+1
GetDocumentNo_SalesInvoice
Process for GetDocumentNo_SalesInvoice
If SalesInvoiceHeader.ID IS DEFINED Then
FIND DocumentNo WHERE DocumentNo.Type='Sales Invoice'
SalesInvoiceHeader.DocumentNo=DocumentNo.NextDocumentNo
In this way, the DocumentNo will find a New Number without duplicate.
Assume the user enter manual: SI-1010-2011.. and now the document No is SI-1009-2011..
With the above process.. The system will check whether SI-1010-2011 is used. If yes, the next invoice is SI-1011-2011 and update the documentno too.
Cool....
Free to add any comment....