[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sorting invoice numbers by numerical order



This discussion has reminded me of an annoying quirk. Well, having to compensate for it last night also reminded me of it.

<?lsmb YYYY ?><?lsmb MM ?>00001

as the default, might get me:

20100100001
20100100002
20100100003
20100200004
20100200005

Whereas I would expect:

20100100001
20100100002
20100100003
20100200001
20100200002

This has frustrated me since SQL-Ledger. I have to manually reset the defaults at the start of any period for which I use a variable string of this type.

One way to handle it, to cover various use cases, might be with a variable which specifies lowest sequence number, with a certain maximum digit count to be left-padded. Example:

<?lsmb YY ?><?lsmb mm ?><lsmb lowestnumber 5 ?>

Would generate:

100100001
100100002
100200001
100200002

That way, the portion that is in the lowest sequence, will always use the lowest available sequence number in the context of the whole string.

The obvious first problem with this idea, is execution time, as it requires a query to determine the next available sequence number. The second problem is the fact that sequences may include things other than numbers.

The first seems simple enough: if you use this method, expect longer execution times when generating numbers.

The second, however, would seem significantly problematic. A single hyphen, or leading 0 (0902-00001) would break the functionality.

Luke