Subject Re: Generator question
Author Myles Wakeham
Paul wrote:
> I think you need to have the big picture in this.
> If a user can delete an Invoice, than can delete any invoice?
>
> We have same system, but each invoice have a status field.
> If an invoice is deleted, this mean the invoice status modify from
> normal
> to delete. If the invoice is canceled then the status will be
> canceled. But
> NEVER is deleted from database.
>
> Another aproach is to use additional table with type of document field
> (invoice) and current_value(invoice nr).In this case you need again the
> status of invoice (is created, is saved, is canceled) to increment
> or nor
> the invoice nr.

Hi Paul, and also thanks for all the other comments received from
everyone on this post.

The problem isn't that users are creating actual, audited invoices and
then want to cancel them. Its more to do with the data entry process
for this. Its a web hosted application, so data entry is done on a
browser. I don't have a persistent connection with the data entry form
(well I have limited connection through AJAX but I digress).

The user will select the party that they wish to invoice, then click
'Create Invoice'. At this time it will bring up an invoice entry form.
But it will show an invoice number. The invoice record has been
created in order to get a unique invoice number for the user doing the
data entry at this time. However its not until they elect to save their
entry that the invoice is considered 'processed' and therefore actually
exists.

Since a generator is being used to get the next invoice number for the
data entry, and I need to show this to the user at the time of data
entry, the problem is that if they cancel then go back to enter a new
one, it is incrementing the invoice numbers so there are holes in the
sequence. I just want to be able to recycle the invoice numbers that
have not yet been actually created so that when a user returns to do the
invoice again, they don't get a number that shows that the out of
sequence problem.

I'm thinking that using a separate document ID table and just
incrementing that when the document is actually saved might be the best
(and probably only) option for this. At least I can guarantee that two
users won't get the same document ID number allocated, and I can reset
the number back if the user cancels the data entry.

Myles

--
=======================
Myles Wakeham
Director of Engineering
Tech Solutions USA, Inc.
Scottsdale, Arizona USA
http://www.techsolusa.com
Phone +1-480-451-7440