The Command Line

What are the command-line options?

OptionDescriptionCommand Example
--create (-c)Creates a new invoice (and stores it in the repository) based on an UBL order.Example
--render (-r)Renders an existing invoice in the repository to the specified output format. TeX, PDF and HTML formats are supported.Example
--update (-u)Updates an existing invoice in the repository.Example
--delete (-d)Deletes an existing invoice from the repositoryExample
--generate (-g)Creates a new invoice based on an existing invoice in the repository.Example
--query (-q)Queries tne invoice repositoryExample
--format (-f)Specifies the invoice output formatExample
--output (-o)Specifies the invoice output file pathExample
--template(-t)Specifies the template path used to produce the invoice output file.Example

How do I create a new invoice based on an order?

Given the UBL order, use the -c option to creates a new invoice in the repository. Open Invoice creates a new invoice in the repository and renders the invoice output using the following default values:

  • Output invoice Format: TeX format. Use -f option to specify your desired output format.
  • Output invoice directory: output.dir property value (that is defined in cfg/openinvoice.properties). Use -o option to specify your desired output file path.
  • Output invoice file base name: invoice-key
  • Invoice template: invoice.tex that's packed in the Open Invoice jar file. Use -t option to specify the path to your custom template.

 java -jar lib/openinvoice-0.1.jar -c order.xml

How do I create a new invoice based on an existing invoice in the repository?

Given an existing invoice in the repository, you can use -g option to have Open Invoice create a new invoice based on the information available in the existing invoice. Open Invoice, retrieves the existing invoice and uses its content to create the new invoice. But, you can still provide set of keys & values to be used by Open Invoice when creating the new invoice; those keys are:

  • EXISTING.INV_ID: specifies the key of the existing invoice; if it's not specified, Open Invoice retrieves the last (the invoice with most recent invoice issue date) invoice.
  • INV_ISSUE_DATE: specifies a new issue date for the new invoice, if not specified, Open Invoice, takes the issue data of the last invoice and increments the month of the issue date by 1. That is if the last invoice issue date is 01/01/2012, the issue date of the new invoice is set to 01/02/2012.
  • INV_ID: specifies a new invoice identifier (or invoice number) for the new invoice, if not specified, Open Invoice, takes the invoice identifier of the last invoice; if the invoice identifier is a number, it's increments by one otherwise the invoice identifier of the existing invoice is used for the new invoice.
  • INV_ITEM_QUANTITY: specifies the quantity of the first line of the invoice lines. It's only useful for invoices with one line.

java -jar lib/openinvoice-0.1.jar -g new-values.properties

invoice.properties

             
 # Sample content of invoice.properties. Note that all of the following properties are optional;
 # if they are  not specified, Open Invoice will set them to default values.
 EXISTING.INV_ID=2011-10-31_153
 INV_ISSUE_DATE=2015-01-01
 INV_ID=300
 INV_ITEM_QUANTITY=10.0
            
           

How do I render an existing invoice in the repository to my desired output format?

TeX is the Open Invoice default output format and most customizable format for printing. To generate your own custom invoice:

  1. Customize the Open Invoice TeX template
  2. Use -r option to render the invoice and -t option to pass your custom template.
  3. Run LaTeX on the rendered invoice to produce the PDF output.

java -jar lib/openinvoice-0.1.jar -r invoice-key -t custom-template.tex -o invoice.tex

How do I update an invoice in the repository?

Use the -u option to update an existing invoice; you needs to provide the invoice-key of the existing invoice as well as an order file that contains the update information.

 java -jar lib/openinvoice-0.1.jar -u invoice-key order.xml

How do I delete an invoice from the repository?

The following command deletes the invoice corresponding to the specified invoice-key. By default, the invoice-key is composed of the invoice issue date and the invoice number

 java -jar lib/openinvoice-0.1.jar -d invoice-key

How do I query the Open Invoice repository?

Use the -q option to perform queries on Open Invoice repository. The Open Invoice query accepts a set of filters to search the repository and format its result set to CSV or plain text format. In the following example, the query processes the pre-defined filters; sorts its result set on the invoice supplier name in ascending order; formats its result in CSV format and finaly writes the output to the result.csv file. formats see the sample file below.

 java -jar lib/openinvoice-0.1.jar -q query.properties -f CSV -o result.csv

query.properties

                 
# Sample content of query.properties. Note that all of the following filters are
# optional; if they are  not specified, Open Invoice will set them to default values.
# Some filters are range filters including a pair of values separated by a ';'.
# Putting a value inside a pair of '[]', flags the value as being inclusive.
# -----------------------------------------------------------------------------
# Filters
# -----------------------------------------------------------------------------

filter.INV_ISSUE_DATE=[2009-01-02];[2015-12-31]
filter.INV_CURRENCY_CODE=USD
filter.INV_SUBTOTAL=1;[1000000]
filter.INV_TOTAL=100.00;[1000000000]
filter.INV_TAX_TOTAL=1;10000000
filter.INV_ID=%200%
filter.SUPPLIER_NAME=Plain%
filter.CUSTOMER_NAME=%Sun%

# -----------------------------------------------------------------------------
# Sort properties
# -----------------------------------------------------------------------------
sort.column=SUPPLIER_NAME
sort.order=DESCENDING

# -----------------------------------------------------------------------------
# Result set properties
# -----------------------------------------------------------------------------
result.maxSize=1000
result.countOnly=false
                
               

Configuration and Customization

Where is the Open Invoice configuration information?

Open Invoice reads configuration information from several sources. The default configuration, built into the application, is augmented by user-specified configuration files, system properties, and command line options, generally in that order. Configuration files are located in the cfg directory.


How do I change the invoice locale?

The invoice locale is determined based on the Language.LocaleCode and Country.IdentificationCode of the SellerSupplierParty.party in the given UBL order. For example, fr and BE selects French as the invoice language and the invoice fields formatting are done according to the Belgian locale.


How do I change the invoice currency?

The invoice currency is determined based on the Price.CurrencyCode of the first InvoiceLine of the given UBL order.


How do I change the invoice invoice terms?

There are two ways for changing your invoice terms:

  • If you want to apply the same invoice terms for all of your invoices, create a plain text file in which you include your payment terms; name the file as payment-terms.txt and put it in your home directory. The invoice terms file name can be changed by re-setting the value of the invoice.invoiceTermsFileName key defined in the ubl4j.properties configuration file.
  • Put your invoice terms in Order.Note element of the UBL order. Make sure that the first line of the invoice terms text starts with Invoice Terms.

How do I change the invoice look and feel?

To change the invoice look and feel:

  1. Copy one of the default templates (invoice.tex or invoice.html) located in template directory
  2. Customise the template to fit your requirements
  3. use -t option to specify the path to your custom template

How do I change the invoice repository directory where Open Invoice stores invoices?

In openinvoice.properties, set repository.uri to point to your desired directory path.


How do I change the output directory where Open Invoice generates the result of its output rendering?

In openinvoice.properties, set output.dir to point to your desired directory path.


What is the invoice key?

It's the unique key identifying a given invoice in the Open Invoice repository. By default, Open Invoice uses a composite key that is composed of the invoice issue date and the invoice identifier. For example, 2012-01-01_101.