View source | View content page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Show collection (0 pages)
Collections help

Search

Talk:POS - Consolidate the receipt

The code to Consolidate the receipt will ignore any attributes and as a result any attributes selected for the first of any item, will be used for any such item.

To avoid this I would recommend using the following code, which will only consolidate Items with the same attributes.



import com.openbravo.format.Formats;

import com.openbravo.pos.ticket.TicketLineInfo;

import com.openbravo.pos.ticket.TicketInfo;

import com.openbravo.pos.ticket.TicketProductInfo;

import java.util.Properties;


int numlines = ticket.getLinesCount();


for (int i = 0 ; i < numlines ; i++) {

current_ticketline = ticket.getLine(i);

current_unit = current_ticketline.getMultiply();

if ( current_unit != 0){

String current_productAtt = current_ticketline.getProductAttSetInstDesc();

String current_productid = current_ticketline.getProductID();

for (int j = i + 1 ; j < numlines ; j++) {

loop_ticketline = ticket.getLine(j);

loop_unit = loop_ticketline.getMultiply();

String loop_productid = loop_ticketline.getProductID();

String loop_productAtt = loop_ticketline.getProductAttSetInstDesc();


if ( loop_productid.equals(current_productid) && (loop_ticketline.getPrice() == current_ticketline.getPrice()) && (loop_unit != 0)

&& loop_productAtt.equals(current_productAtt) ){

current_unit = current_unit + loop_unit;

loop_ticketline.setMultiply(0);

}

}

current_ticketline.setMultiply(current_unit);

}

}


// now remove the ticket lines where the unit = 0

// start deleteing in reverse order


for (int i = numlines - 1 ; i > 0 ; i--) {

loop_ticketline = ticket.getLine(i);

loop_unit = loop_ticketline.getMultiply();

if (loop_unit == 0){

ticket.removeLine(i);


}

}

sales.printTicket("Printer.TicketPreview");



Thanks to Seballa for the original code. Sorry about formatting, not sure how to preserve whitespace!

--Jordan 23:25, 23 January 2011 (UTC)

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

This page has been accessed 1,457 times. This page was last modified on 23 January 2011, at 23:25. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.