UnicentaPOS Help Wiki
Advertisement

This Script applies a Meal Deal.

If you add a Product that is Classed as Item 1 (the main part of the deal such as a Burger), then add a product classed as Product 2 (the secondary part of the deal such as a drink), it applies a line that discounts the Products to the deal price. (see picture).

MealDeal

Meal Deal Discount Line




Add this to the Product Properties page[]

Change it to 1 or 2 depending on which part of the deal the Product is.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>  
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">

<properties>
	<entry key="MDeal">1</entry>
</properties>

Add this to the event.change script[]

Change where it says 6 in the 2nd line to the price of your deal.


import com.openbravo.format.Formats;
import com.openbravo.pos.ticket.TicketLineInfo;
import com.openbravo.pos.ticket.TicketProductInfo;

//Meal deal script
index = sales.getSelectedIndex();
line = ticket.getLine(index);
Double meal = new Double("6");
price1 = line.getPriceTax(); 
if (line.getProperty("MDeal") != null){
	if (index >= 0) {
		line = ticket.getLine(index);
		if (line.getProperty("MDeal").equals("1")){
			for(int i= 0; i < ticket.getLinesCount(); i++){  
				line = ticket.getLine(i);
				if (line.getProperty("MDeal") != null){
					if (line.getProperty("MDeal").equals("2")){
						price2 = line.getPriceTax();
						price3 = (-price1 - price2 + meal);
						line = ticket.getLine(index); 
						ticket.insertLine(ticket.getLinesCount(),
						new TicketLineInfo(
						line.getProductID(),
						"Meal Deal",
						line.getProductTaxCategoryID(),
						line.getMultiply(),
						0,
						line.getTaxInfo()));

						sales.setSelectedIndex(ticket.getLinesCount()-1);
						index = sales.getSelectedIndex();
						line = ticket.getLine(index); 
						line.setPriceTax(price3);
						line.setProperty("sendstatus", "Bar");
						sales.setSelectedIndex(ticket.getLinesCount()-2);

						line = ticket.getLine(i);
						line.setProperty("MDeal", "0");
						line = ticket.getLine(index);
						line.setProperty("MDeal", "0");
						return;
					}
				}
			}
		}
	index = sales.getSelectedIndex();
	line = ticket.getLine(index);
		if (line.getProperty("MDeal").equals("2")){
			for(int i= 0; i < ticket.getLinesCount(); i++){  
				line = ticket.getLine(i);
				if (line.getProperty("MDeal") != null){
					if (line.getProperty("MDeal").equals("1")){
						price2 = line.getPriceTax();
						price3 = (-price1 - price2 + meal);
						line = ticket.getLine(index); 
						ticket.insertLine(ticket.getLinesCount(),
						new TicketLineInfo(
						line.getProductID(),
						"Meal Deal",
						line.getProductTaxCategoryID(),
						line.getMultiply(),
						0,
						line.getTaxInfo()));

						sales.setSelectedIndex(ticket.getLinesCount()-1);
						index = sales.getSelectedIndex();
						line = ticket.getLine(index); 
						line.setPriceTax(price3);
						line.setProperty("sendstatus", "Bar");
						sales.setSelectedIndex(ticket.getLinesCount()-2);

						line = ticket.getLine(i);
						line.setProperty("MDeal", "0");
						line = ticket.getLine(index);
						line.setProperty("MDeal", "0");
						return;
				}
			}
		}
	}
}
}
Advertisement