Retail:Developers Guide/Receipt and Customer display documents
Contents |
Receipt and customer displays documents
![]() | Fiscal printers support it is at this moment in testing stages. Do not use it in production environments until is announced. |
Introduction
Openbravo web POS defines a language based on XML which is independent on the receipt printer or display model used.
The receipt printer language
A ticket template is composed by lines. Each line can contain images, barcodes and text. Depending on the tag, some attributes are available providing utilities to format and align elements of the ticket.
The tags described in this section conforms a ticket template
XML Tag: ticket Prints a receipt. When this element is closed the receipt printer cuts the paper.
- Ticket attribute, printer: Defines the target printer of a ticket, by default 1.
- XML Tag: line
- Is defined inside a ticket element. Defines a ticket line in the receipt.
- XML Tag: text
- Is defined inside a line element. Is used to print a string into a ticket.
- text attribute, size: Defines the font size used, by Default is 0, the avalable values are:
- 0: Normal size
- 1: Double height
- 2: Double width
- 3: Double height, double width
- text attribute, align: Defines the aligment of the text string. The avalable values are:
- left: Align text to the left
- right: Align text to the right
- center: Center the text.
- text attribute, length: Defines the length in characters. Is used to fit the text strings.
- text attribute, bold: Defines if the text is bold or not. By default is false.
- text attribute, underline: Defines if the text is underlined or not. By default is false.
<line> <text align="center" length="42"> <%=OB.UTIL.encodeXMLComponent(OB.I18N.getLabel('OBPOS_tckheader_line1'));%> </text> </line>
- XML Tag: image
- Is defined inside a line element. Is used to print an image into a ticket. The image is converted to B/W before sending it to the printer.
- image attribute, type: Defines where the image type.
- default: The image is a file located in the img/ folder of the hardware manager installation
- data: The image is encoded in Base64. This is the prefered way to include an image in a print document because it does not depend on the images installed in the hardware manager. To convert an image file into Base64 you can use the base64 command line tool or any online tool.
- url: The image is an URL.
- file: The image is a file located in the file system.
- classpath: The image is located in the java classpath.
<%-- PNG image encoded as Base64 --%> <image type="data"> iVBORw0KGgoAAAANSUhEUgAAAAUA AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO 9TXL0Y4OHwAAAABJRU5ErkJggg== </image> <%-- PNG file located in the img/ folder of the hardware manager --%> <image>ticket-image.png</image>
- XML Tag: barcode
- Is defined inside a line element. Is used to print a barcode into a ticket.
- barcode attribute, type: Defines the type of barcode that is going to be printed.
- EAN13: Prints EAN13 barcode
- CODE128: Prints CODE128 barcode
- CODE39: Prints CODE39 barcode. This barcode type is only available in JavaPOS printers.
- barcode attribute, position: Defines the position of barcode label
- top: Locates the barcode label on to the top of the barcode.
- bottom: Locates the barcode label on the bottom of the barcode.
- none: Does not print the barcode label.
<barcode type="CODE128" position="bottom"><%= OB.UTIL.encodeXMLComponent(order.get('documentNo')) %></barcode>
The customer display language
The tags described in this section conforms a display template
XML Tag: display Changes the customer display content.
- attribute, animation: Defines animation usedto print the text the available values are:
- none: Text is not animated. This is the default value.
- flyer: Text appears from the right.
- scroll: Text is scrolling in the display from right to left continuously.
- blink: Text blinks continuously.
- curtain: Text appears behind a virtual curtain.
- XML Tag: line
- Is defined inside a display element. Defines a line in the display.
- text attribute, align: Defines the aligment of the text string. The avalable values are:
- left: Align text to the left (Default)
- right: Align text to the right
- center: Center the text.
- text attribute, length: Defines the length in characters. Is used to fit the text strings.
<display> <line> <text align="left" length="10"><%= OB.UTIL.encodeXMLComponent(OB.I18N.getLabel('OBPOS_display_total'))%></text> <text align="right" length="10"><%= order.printGross() %></text> </line> <line> <text align="center" length="20"><%= OB.UTIL.encodeXMLComponent(OB.I18N.getLabel('OBPOS_thankyou'))%></text> </line> </display>In case you want to show only one line, just add the following after your line:
<line></line>
The open drawer tag
Openbravo web POS also supports communication with drawers. To open it, one tag is available.
XML Tag: opendrawer Opens the cash drawer attached to the receipt printer
<opendrawer/>
The fiscal receipt printer language
A fiscal receipt is composed by commands that the fiscal printer uses to compose and print the receipt, This receipt is composed by lines, messages, discounts, service charges and payments.
The tags described in this section conforms a fiscal receipt
XML Tag: fiscalreceipt Composes and prints a fiscal receipt or document. When this element is closed the receipt or document is printed and the printer cuts the paper.
- attribute, printer: Defines the target printer, by default 1.
- attribute, type: Defines the fiscal document type. Each kind of documents is identified in the result. The available values are:
- nonfiscal: Defines a non fiscal document not registered in the fiscal memory of the device. This is the default value.
- fiscal: Defines a fiscal document. This is the value that must be used for regular receipts given to customers when selling goods.
- invoice: Defines a fiscal invoice. this is the value that must be used when it is needed to provide an invoice to the customer when selling goods.
- attribute, cashier: Defines the cashier that created the receipt.
- attribute, invnumber. Only for fiscal documents of type invoice. Defines the invoice number.
- attribute, taxnumber. Only for fiscal documents of type invoice. Defines the tax identifier of the customer.
- attribute, vatnumber. Only for fiscal documents of type invoice. Defines the VAT identifier of the customer.
- attribute, name. Only for fiscal documents of type invoice. Defines the name of the customer.
- attribute, address. Only for fiscal documents of type invoice. Defines the address of the customer.
- XML Tag: line
- Is defined inside a ticket element. Defines a receipt line and contains a product name.
- attribute, price. Defines the unit price of the goods defined in this line.
- attribute, units. Defines the units sold. By default 1.
- attribute, tax. Defines the tax identifier for this line. Its value depends on the fiscal printer.
- attribute, discount. Defines the percentage discount applied to this line. If negative is a discount, if positive an extra charge. By default is 0.
- XML Tag: message
- Prints a text line in the receipt. It contains the message to print.
- attribute, style. Defines the style of the text message. The available values are:
- normal. Prints the message with no styles. It is the default value.
- bold. Prints the message in bold.
- italic. Prints the message in italic.
- underline. Prints the message underlined.
- doublewidth. Prints the message with double width typeface.
- doubleheight. Prints the message with double height typeface.
- XML Tag: totaldiscount
- Adds a percentage discount to the total of the receipt.
- attribute, discount. The percentage to apply to the total of the receipt. If negative is a discount, if positive an extra charge.
- XML Tag: servicecharge
- Adds an service charge to the total of the receipt.
- attribute, amount. The service charge to apply to the total of the receipt. If negative is a discount, if positive an extra charge.
- XML Tag: total
- Adds a payment to the receipt. The sum of all payments added must be equal to the total of the receipt. If there is a difference, an adjustment is applied to match the payments with the total of the receipt.
- attribute, payment. Defines the payment identifier. Its value depends on the fiscal printer.
- attribute, name. Defines the name of the payment identifier.
- attribute, amount. Defines amount paid.
The cash management tag
This tag defines and prints a cash management movement for fiscal printers.
XML Tag: cashmanagement
- attribute, printer: Defines the target printer, by default 1.
- attribute, payment: Defines the payment identifier. Its value depends on the fiscal printer.
- attribute, name. Defines the name of the payment identifier.
- attribute, amount. Defines amount paid.
The X Report tag
This tag defines and prints a fiscal X report. An X report is a summary of all fiscal operations executed in the fiscal printer. It does not reset any total.
XML Tag: fiscalxreport
- attribute, printer: Defines the target printer, by default 1.
The Z Report tag
This tag defines and prints a fiscal Z report. An Z report is a summary of all fiscal operations executed in the fiscal printer. It reset all totals, and it is usually a daily process executed at the end of the day to review the daily sales.
XML Tag: fiscalzreport
- attribute, printer: Defines the target printer, by default 1.
File to place templates
Display templates and receipt templates are included in xml files. The root element of this file will be "<output></output>". Depending on the action that you need, you can add to this element templates for several devices. In this example when the template is processed by hardware manager these actions will happened:
- The printer will print a receipt
- The display will show a message
- The drawer will be opened
<output> <ticket> </ticket> <display> </display> <opendrawer/> </output>
Back to Concepts