Custom Invoice numbers - centralized approach
  • ss_theoness_theone January 2010

    Hi there,

    What's the best way to do custom invoice numbers that can then be shown globally throughout the different views? We typically append dates to our invoice #s and add some leading numbers to invoice index.

    Is there a centralized approach to changing this without hacks all over?

    Thanks.
    Sean,

  • justinjustin January 2010

    hey sean

    currently invoice numbers are based the mysql primary key for the invoice table
    - the only central option is to adjust the mysql auto-increment to something you like ie. 201000 etc..

    i plan on changing this to a more flexible approach soon

    let us know how you go

    cheers

    justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • lebretonlebreton January 2010

    Quote
    the only central option is to adjust the mysql auto-increment to something you like ie. 201000 etc..
    Unquote

    Thanks for that one, but how/where is setting "mysql auto-increment" accomplished ?

    A more "flexible approach" would be great, also with the new year, is it possible to reset the numbers ?

    Thanks in advance and best wishes for 2010

  • absukabsuk January 2010

    Hay, sorry for my intrusion, just reading up on Simpleinvoces, your comment about the re-setting of Invoice numbers is a bad idea, as you always want a unique ID, regardless of date, I guess you can have a pre-fix with the date then the number afterwards, even then, there is no reason to reset the numbers as I can not see the benefits of such a feature.

    Simpleinvoices is great ;)

  • lebretonlebreton January 2010

    @absuk
    Hi and tks, yr right of course about wanting a unique id, but that doesnt tell me how to pre-fix "2010xyz" to auto incremented invoice numbers.
    Just that I used to number invoices in date-dept-number format, which always seemed to make sense.....regardless whether resetting at the start of a new year or not.
    Still new to mysql/phpmyadmin so greatly appreciate any help.
    Otherwise SimpleInvoices does the trick as far as I am concerned :)

    btw googled "mysql auto increment pre-fix" but can not make much sense out of the results :(

  • 21sts21sts January 2010

    If this might help, I added a date to the invoice that shows "year/month-00002" for each invoice (ex. 01/10-0022 for this month) I am not a code person, so someone else may have a better solution. Here is what I did:

    Add the following to include/sql_queries.php around line 927 (2009 version). It should follow the function getInvoice($id) in the section with variables for total, gross, owing, etc.
    $invoice['year'] = date('y/m', strtotime( $invoice['date'] ) ); (note: format the date as you want - I just wanted year/month)

    In your template, you can add something like:
    {$invoice.year}-{invoice_number invoiceId=$invoice.id length=4} Note: I use the function.invoice_number plugin to get the leading zeros. If you don't use that plugin, just use {{invoice.id}-{$invoice.year} or so.

    Hope this helps.

  • justinjustin January 2010

    @21st
    - thanks for your reply - great work-arounds to this problem!

    @lebreton

    - refer: http://simpleinvoices.org/forum/discussion/203/#Item_6 for info on how to reset the ID number in phpmyadmin

    @absuk

    - thanks

    cheers

    justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

Categories