Script: Reset invoice number

Resets the invoice number counter

Product line

Standard

|

Expert

Operating mode

CLOUD ABO

|

ON-PREMISES

Modules

Services & CRM

Budget & Phases

Purchases

Resource Planning

Business Intelligence

Created: 12.02.2004
Updated: 15.10.2024 | Replaced VB Scripts with Python Scripts.

The invoice number is reset. This script is used, for example, when an invoice needs to be deleted and re-created, so that the invoice number is not “wasted”.

There are 2 scripts:

  • Script 1: Resets the invoice number by one counter.
  • Script 2: If you want to reset the invoice number by more than one counter, use this script. You can specify the desired counter in a query.

For both scripts, they reset the last used invoice number with the current prefix.

If you want to increase the invoice number instead, you do not need this script, but can specify the next invoice number in the system settings > invoice / invoice.

    Execute

    Somewhere in Vertec

    Script 1

    Resets the invoice number by one counter.

    ResetInvoice Number.py

    Script text

    # coding: windows-1252 
    #
    #---Description: Reset invoice number
    # Class: BusinessclassesRoot
    # Condexpression:
    # Objectscript: N
    # Containerscript: N
    # Eventtype: None
    # Eventclass:
    # Eventmembers:
    # Extendedrights: N
    #---Resets invoice number by one counter.
    #---12.02.2004, Vertec AG: created
    #---02.06.2008, sr: Updatedatabase added.
    #---19.06.2017, sr: Script created in Python.


    def main():

    prop = vtcapp.evalocl(“property->select(propertyname='PraefixInvoice Number’)->first”)
    if prop:
    prefix = vtcapp.evalocl(“usedprefix->select(prefix='” + prop.propertyvalue + “')->first”)
    if

    prefix: mer has


    been reset’)

    main()

    Script 2

    Sets the invoice number to the value requested by the user.

    ResetInvoice numberInput.py

    Script text

    # coding: windows-1252 
    #
    #---Description: Reset invoice number with input
    # Class: BusinessclassesRoot
    # CondExpression:
    # Objectscript: N
    # Containerscript: N
    # Eventtype: None
    # Eventclass:
    # Eventmembers:
    # Extendedrights: N
    #---Resets invoice number. The next
    # invoice number to be used can be specified in a query.
    #---15.02.2007, sc: created. created #---31.12.2012, sr: Prefix added to msgbox.

    #---19.06.2017, sr: Script created in Python.

    def main():

    prop = vtcapp.evalocl(“property->select(propertyname='PraefixInvoice Number’)->first”)
    if prop:
    prefix =
    vtcapp.evalocl(“usedprefix->select(prefix='” + prop.propertyvalue + “')->first”)
    if prefix: lastusednumber =
    prefix.lastusednumber
    userinput = vtcapp.inputbox(“Vertec,””The last invoice number is: %s \r\r The associated prefix is: %s \r\r Enter a new invoice number (without prefix):” % (lastusednumber, prop.propertyvalue), ““)           
    if userinput:
    try:                       

    return

    prefix.lastusednumber = int(newnumber) -1 vtcapp.updatedatabase() vtcapp.updatedatabase()
    except ValueError:

    vtcapp.msgbox('The value you entered is not a number. Please enter a number.', 0, 'Vertec’)

    main()


    Bitte wählen Sie Ihren Standort