View Categories

Discount on total bill amount

< 1 min read

This script can be used to input % of discount to apply on the total amount.

Maintenance > Resources
Create a button in Ticket.Buttons and call the below script to apply the discount.

/* % 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;

discountperc = JOptionPane.showInputDialog(null, "Input percentage.....");
double discountrate = Double.parseDouble(discountperc);
discountrate = discountrate/100.00;

total = ticket.getTotal();
if (total > 0.0) {
    sdiscount = Formats.PERCENT.formatValue(discountrate);

    taxes = ticket.getTaxLines();
    for (int i = 0; i < taxes.length; i++) {
        taxline = taxes[i];
        ticket.insertLine(ticket.getLinesCount(),
            new TicketLineInfo(
                "Discount " + sdiscount + " of " + taxline.printSubTotal(),
                taxline.getTaxInfo().getTaxCategoryID(),
                1.0,
                -taxline.getSubTotal() * discountrate,
                taxline.getTaxInfo()));
    }
    sales.setSelectedIndex(ticket.getLinesCount() - 1);
} else {
    java.awt.Toolkit.getDefaultToolkit().beep();
}

Save & restart

0 Comments

Leave a Reply

Arrow-up