// Consolidate the receipt
// Remove duplicate item entries
// Add their units to the first entry of the item
import com.posics.format.Formats;
import com.posics.pos.ticket.TicketLineInfo;
import com.posics.pos.ticket.TicketInfo;
import com.posics.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){
for (int j = i + 1 ; j < numlines ; j++) {
loop_ticketline = ticket.getLine(j);
loop_unit = loop_ticketline.getMultiply();
String current_productid = current_ticketline.getProductID();
String loop_productid = loop_ticketline.getProductID();
if (loop_productid != null){
if ( loop_productid.equals(current_productid) && (loop_ticketline.getSalePrice() == current_ticketline.getSalePrice()) && (loop_unit != 0) ){
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);
}
}
//
//Force for something if missing
//
/*
if (ticket.getProperty("PeopleCount") == null){
value = javax.swing.JOptionPane.showInputDialog("Please enter number of people served:", "");
try {
Double peopleCount = new Double(value);
ticket.setProperty("PeopleCount", value);
}
catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null, "Not a valid number: " + value, "Error", JOptionPane.PLAIN_MESSAGE);
}
}else{
return null;
}
*/
//
//Stop payment when all items not sent
//
/*
for(int i= 0; i < ticket.getLinesCount(); i++){
line = ticket.getLine(i);
// Set Discount(kotnum=NULL) to N/A so it does not error on next section.
if (line.getProperty("kotnum") == null){
line.setProperty("kotnum", "N/A");
}
if (line.getProperty("sendstatus") == null){
line.setProperty("sendstatus", "No");
}
if((line.getProperty("sendstatus").equals("No") || line.getProperty("sendstatus").equals("Cancel")) && !line.getProductName().equals("Discount")){
mySent = "No";
}
}
if (mySent == "No"){
javax.swing.JOptionPane.showMessageDialog(null, "You must Send all items to the Kitchen before payment", "Send Warning", JOptionPane.WARNING_MESSAGE);
return "Cancel";
}else{
return null;
}*/
Leave a Reply