Unique number use more than once
Posted: Mon May 09, 2011 4:23 pm
How would you solve the following.
The company uses Quotes and invoices. The quotes get a running number and can not skip a number. A customer requests a job done and so he gets a quote with a number (lets say 241-Q). Now he is not happy with the quote and negotiates and a new quote is made (lets say 242-Q) He now is happy and accepts the quote. So he gets and invoice the invoice is based on the quote 242 and subsequently has the invoice number 242-I. The receipt wiwll then be 242-R and the Delivery note 242-D
Now the challenge is how to create the number in the first place. If I use a mysql auto number field (the id field in the table) it will not work as the number only gets assigned at the point when the record is saved. Plus the number can only be used once.
If I use a normal field it does not autoincrement (as there can be only one column to autoincrement).
If I use select max(number) at number from Tbl_number then I get the last number. This could be incremented and presented to the user. The problem with this approach in a multiuser environment is that if a second user is faster he/she will get the same number and save it before the first user clicks submit.
Any insights how to do this with nuBuilder?
Your comments are appreciated.
Fundi
The company uses Quotes and invoices. The quotes get a running number and can not skip a number. A customer requests a job done and so he gets a quote with a number (lets say 241-Q). Now he is not happy with the quote and negotiates and a new quote is made (lets say 242-Q) He now is happy and accepts the quote. So he gets and invoice the invoice is based on the quote 242 and subsequently has the invoice number 242-I. The receipt wiwll then be 242-R and the Delivery note 242-D
Now the challenge is how to create the number in the first place. If I use a mysql auto number field (the id field in the table) it will not work as the number only gets assigned at the point when the record is saved. Plus the number can only be used once.
If I use a normal field it does not autoincrement (as there can be only one column to autoincrement).
If I use select max(number) at number from Tbl_number then I get the last number. This could be incremented and presented to the user. The problem with this approach in a multiuser environment is that if a second user is faster he/she will get the same number and save it before the first user clicks submit.
Any insights how to do this with nuBuilder?
Your comments are appreciated.
Fundi