Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 77025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:45:55+00:00 2026-05-10T20:45:55+00:00

Some background: In Germany (at least) invoice numbers have to follow certain rules: The

  • 0

Some background: In Germany (at least) invoice numbers have to follow certain rules:

  1. The have to be ordered
  2. They have to be continuous (may not have gaps)

Since a few months they are allowed to contain characters. Some customers want to use that possibility and customers don’t know that or are afraid and they insist on digit-only invoice numbers.

Additionally the customers don’t want to start them at zero.

Is I can think of many ways to generate such a number I wonder: What’s the best way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:45:56+00:00Added an answer on May 10, 2026 at 8:45 pm

    In order to avoid starting at 0 – just start at 10000. Forget about the zero-padding.

    You have to consider when the number is going to be allocated.

    If you allocate the number when the invoice is first opened for edit, for instance the number 10014 is allocated, and the user cancels the invoice then you have a gap, since you have to keep in mind that someone else could already have begun to create an invoice with the id 10015, so you can’t just rollback the number.

    If you allocate the number when the invoice has been completely written and is being saved then you’ll avoid the scenario, and you’ll avoid having gaps, but you will not know which invoice number the invoice is going to have before it is saved.

    Also, you need to make sure that it is threadsafe, so that two users can’t create the same invoice number.

    static object _invoiceNumberLock = new object(); public static string GetInvoiceNumber() {     lock(_invoiceNumberLock)     {         //Connect to database and get MAX(invoicenumber)+1         //Increase the invoicenumber in SQL database by one         //Perhaps also add characters     } } 

    Also consider backing up the uniqueness by having a UNIQUE INDEX on the invoicenumber column in the SQL database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some Background: I have a VS 2008 Deployment project I am not using the
Some background: an 'image' is part of one 'photoshoot', and may be a part
Some background first. I have a .net client agent installed on each of the
Some Background I have noticed that setting the EditTemplate of a DataForm (from the
Some Background I have been using Git for a while now. The projects that
Some background: We have some entity classes need to be serialized, so we implement
Some background: I am writing a application with several forms, etc. Users have to
Some background. I'm helping a group of students at my son's school and they
First some background information: We have three environments for our EJB3 application: test, development
Some Background The app that i have made, is an interval app. This allows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.