UBL4J provides a Java implementation for Universal Business Language (UBL) Order to Invoice process. Given an UBL order document, it produces an UBL invoice document and renders its output to TeX, PDF or HTML formats. UBl4J uses the order document country and language information to tailor locale-sensitive invoices.
To install UBL4J, download UBL4J distribution file and extract it into your desired directory. By default, UBL4J reads its configuration from the .ubl4j.properties in the user home directory. Copy the cfg/ubl4j.properties file that is in your UBL4J install directory to your home directory, and adapt it to fit your needs. Refer to UBL4JConfigurationBean for configuration parameters that control the behaviour of UBL4J.
The invoice output file can be customized via the following files:
The UBL4J behaviour can also be customized via its API.
UBL4J is meant to serve as a framework or library, refer to OpenInvoice documentation to see how you can use UBL4J as a building block of your own application. But UBL4J can also be invoked via the command-line.
Assuming that you are in the UBL4J install directory, the following command creates an invoice based on the UBL order, MyOrder.xml, and renders its output to PDF format by default. Also, by default the output invoice file is saved in the output directory (specified by the 'output.dir' property in the '.ubl4j.properties' file). By default, the invoice issue date and the invoice identifier are used to compose the invoice file name.
$ java -jar lib/ubl4j-0.6.jar -c MyOrder.xml
Assuming that you are in the UBL4J install directory, the following command creates an invoice based on the UBL order, MyOrder.xml, and renders its output to TeX format. '-f' option is used to specify the TeX format and '-t' option is used to specify the TeX template, MyTeXTemplate.tex. If the template is not specified, UBL4J uses its own default TeX template. '-o' option is used to specify the invoice output file.
$ java -jar lib/ubl4j-0.6.jar -c MyOrder.xml -f TEX -t MyTexTemplate.tex -o MyInvoice.tex
Assuming that you are in the UBL4J install directory, the following command creates an invoice based on the UBL order, MyOrder.xml, and renders its output to HTML format. The default HTML template is used to render the invoice output. The output invoice file is saved in the output directory (specified by the 'output.dir' property in the '.ubl4j.properties' file). The invoice issue date and the invoice identifier are used to compose the invoice file name.
$ java -jar lib/ubl4j-0.6.jar -c MyOrder.xml -f HTML
The following code snippet shows how to create a UBL invoice based on an UBL order.
InvoiceCreationInput input = new CreateInvoiceBasedOnOrderInput(); File orderFile = new File(options.convertOrderToInvoice); ((CreateInvoiceBasedOnOrderInput)input).setOrderURI(URI.create(orderFile.toURI().getPath())); CreateInvoiceBasedOnOrderTask task = new CreateInvoiceBasedOnOrderTask(); InvoiceCreationOutput output = task.execute(input); System.out.println(output.toString());