Piotr Pokora schrieb:
"Andreas Flack" <[EMAIL PROTECTED]> wrote:
How do you know if object's id property is auto incremental ?
How do you know it's primary and unique?
Well, I don't (and I didn't write o.o.invoices), but that's the mechanism the component
uses right now: it looks for the highest ID in the table, then adds one and inserts this
in the invoiceNumber field when you click the "create invoice" link.
I would write the same solution. Though, I wouldn't like to depend on DB auto
incremental ID.
Correct invoice number is much more important than performance.
It's a strange and fragile system (because deleted invoices and other
irregularities can quickly derail the numbering system). Maybe a solution could be
not to use ID as the base for the next invoice number, but instead qb->count();
where qb queries all invoices?
new invoice /* 12 */
new invoice /* 13 */
invoice delete(12)
new invoice /* 13 */ ( disaster )
But that would be bad in real life, too: At least under German
legislation (I don't know about other countries), you're required to use
a consecutive numbering scheme with no gaps in it. If you really needed
to get rid of invoice 12, you'd have to write an invoice 14 revoking it.
Of course you could also construct a scenario where somebody enters a
batch of invoices before sending them, and then wants to delete
"temporary" invoice 12, but in this scenario, all the other unsent
invoices would have to be moved down to prevent the gap (i.e. 13 would
become 12).
But in any case, the best bet would probably to make invoiceNumber an
integer field (I never understood why it is string and has "#000"
prefixed to the number, this could be done in style code just as well)
and then say something like select max(invoiceNumber) to get the next
free number.
It wouldn't be too difficult to implement, but it would require a
conversion script for current installations (if any exist :-P)
Bye,
Andreas
Piotras
_______________________________________________
user mailing list
[email protected]
http://lists.midgard-project.org/mailman/listinfo/user
_______________________________________________
user mailing list
[email protected]
http://lists.midgard-project.org/mailman/listinfo/user