This script can be used to apply a discount on a selected item.
Administrator Menu > Maintenance > Resources
Create a resource Script.DiscountOnItem and copy paste below code:
pflag = 0;
if (sales.getSelectedIndex() >= 0) {
String discountperc = JOptionPane.showInputDialog(null, "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 && Double.parseDouble(discountperc.substring(0, discountperc.lastIndexOf("%"))) > 0.0) {
discountrate = Double.parseDouble(discountperc.substring(0, discountperc.lastIndexOf("%")));
discountrate = discountrate / 100.00;
pflag = 1;
} else if (Double.parseDouble(discountperc) > 0.0) {
discountrate = Double.parseDouble(discountperc);
}
line = ticket.getLine(sales.getSelectedIndex());
if (pflag == 1) {
line.setSalePrice(line.getPrice() - (line.getPrice() * discountrate * 1));
} else {
line.setSalePrice(line.getPrice() - discountrate);
}
}
} else {
java.awt.Toolkit.getDefaultToolkit().beep();
}
Save
Leave a Reply