View source | Discuss this page | Page history | Printable version   

POS - Calculate Units from Total Line Price

1) Add Permissions to Roles

Choose the Maintenance option, then choose Roles. Add this to the Roles needed to access this option and click/press the save icon:

<class name="button.calcunits"/>

2) Create Button

Choose the Maintenance option, then Resources. Add this to Tickets.Buttons resource and click/press the save icon:

<button key="button.calcunits" name="button.calcunits" code="Script.CalcUnits"/>

3) Create the Script.CalcUnits Resource

Choose the Maintenance Option, then choose Resources. Click/Press the option for new resource. Make sure the resource is set for "Text" and add the following as the resource Script.CalcUnits and click/press the save icon:

import javax.swing.JOptionPane;
 value = javax.swing.JOptionPane.showInputDialog("Price", "");
index = sales.getSelectedIndex(); 
line = ticket.getLine(index);
 try {
  Double newUnits = new Double(value);
  Double pricetax = line.getPriceTax();
 } catch (NumberFormatException e) {
  JOptionPane.showMessageDialog(null, "Not valid number: " + value, "Error", JOptionPane.PLAIN_MESSAGE);

4) Set Button Name

Add the following to the bottom of the file in locales folder:

button.calcunits=Calc Units

Retrieved from ""

This page has been accessed 6,809 times. This page was last modified on 22 June 2010, at 19:00. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.