// Discount on Total Amount
// % Discount for the total of the receipt
import com.posics.format.Formats;
import com.posics.pos.ticket.TicketLineInfo;
import com.posics.pos.ticket.TicketProductInfo;
import java.util.Properties;
pflag=0;
String discountperc = sales.readText("Please enter discount amount:\n(Add a % sign at the end for percentage discount.)");
if(discountperc.length()>0){
double discountrate = 0.0;
if(discountperc.lastIndexOf("%")==discountperc.length()-1){
discountperc = discountperc.substring(0, discountperc.lastIndexOf("%"));
discountrate = Double.parseDouble(discountperc);
discountrate = discountrate/100.00;
pflag=1;
}
else if(Double.parseDouble(discountperc)>0.0){
discountrate = Double.parseDouble(discountperc);
}
total = ticket.getTotal();
if(pflag==1)
{ discount = ticket.getTotal() * discountrate * -1; }
else
{ discount = discountrate * -1; }
ticket.insertLine(ticket.getLinesCount(),
new TicketLineInfo(
"AdditionalDiscount",
"000",
1.0,
discount,
null));
l=ticket.getLine(ticket.getLinesCount() - 1);
l.setProperty("sendstatus", "N/A");
sales.setSelectedIndex(ticket.getLinesCount() - 1);
}
Leave a Reply