View source | Discuss this page | Page history | Printable version   

POS - Add reference product to a ticket line

Contents

Code snippet

Name: POS - Add reference product to a ticket line
Version: POS 2.30
Author: Andy Orencio (lodopidolo)



This article is an attempt on how to store the reference of an article as an attribute of the ticket line, to print on the receipt.

Implementation

The method is:

 
<event key="ticket.addline" code="event.addline"/>
 
// Add product reference to a ticket line, y in the line is a product (discounts and others have no reference).
 
import com.openbravo.pos.forms.DataLogicSales; 
import com.openbravo.pos.ticket.ProductInfoExt; 
import com.openbravo.data.loader.Session;
import com.openbravo.pos.ticket.TicketLineInfo;
 
Session session = new Session(database_url,  database_user, database_password); 
DataLogicSales logic = new DataLogicSales();
logic.init(session);
 
try {
	ProductInfoExt product = logic.getProductInfo(line.getProductID());
	line.setProperty("product.reference", product.getReference());
} catch (Exception e) {
	line.setProperty("product.reference", " ");
}
In this scriptlet you must replace database_url, database_user and database_password by their corresponding values.
 
${ticketline.getProperty("product.reference", "")}

Example

 
        <line>
             <text>----------------------------------------</text>
        </line>   
        #foreach ($ticketline in $ticket.getLines())
        <line>
            #if ($ticketline.isProductCom()) 
                <text align ="left" length="10">*${ticketline.printName()}</text>
            #else
                <text align ="left" length="10">${ticketline.printName()}</text>
            #end
            <text align ="right" length="5">x${ticketline.printMultiply()}</text>
            <text align ="right" length="25">${ticketline.getProperty("product.reference", "")}</text>
        </line>   
        #if ($ticketline.productAttSetInstId)
        <line>
	        <text align ="left" length="40">    ${ticketline.productAttSetInstDesc}</text>
        </line>
        #end
        #end
        <line>
             <text>----------------------------------------</text>
        </line>

References

Retrieved from "http://wiki.openbravo.com/wiki/POS_-_Add_reference_product_to_a_ticket_line"

This page has been accessed 18,280 times. This page was last modified on 3 January 2010, at 11:37. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.