// script.Totaldiscount // // uniCenta oPOS - Touch Friendly Point Of Sale // Copyright (c) 2009-2018 uniCenta // http://sourceforge.net/projects/unicentaopos // // This file is part of uniCenta oPOS. // // uniCenta oPOS is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // uniCenta oPOS is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with uniCenta oPOS. If not, see . // ************************************************************************** // This script applies UsersInput %Discount for the Total Ticket // each Line value is recalculated and annotated // To use in the sales screen: Highlight the line you want to discount // Then Tap in the %Discount amount and touch the % button import com.unicenta.format.Formats; import com.unicenta.pos.ticket.TicketLineInfo; import com.unicenta.pos.ticket.TicketProductInfo; discountrate = sales.getInputValue() / 100.0; index = sales.getSelectedIndex(); if (index >= 0) { if (ticket.getTotal() > 0.0 && discountrate > 0.0) { sdiscount = Formats.PERCENT.formatValue((discountrate)); for (int number= 0; number < ticket.getLinesCount(); number++) { line = ticket.getLine(number); TicketLineInfo ticketLineInfo = new TicketLineInfo( line.getProductID(), line.getProductName() + " - Item Discount @ " + sdiscount, line.getProductTaxCategoryID(), line.getProductPrinter(), line.getMultiply(), line.getNewPrice() - (double)Math.abs(line.getNewPrice() * discountrate * 100) /100, line.getTaxInfo()); ticketLineInfo.setTicketUpdated("ticket.updated", "true"); ticket.setLine(number,ticketLineInfo); } } else { java.awt.Toolkit.getDefaultToolkit().beep(); } } else { java.awt.Toolkit.getDefaultToolkit().beep(); }