This script shows stock of selected item from sales screen and stops selling out of stock item
Administrator Menu > Maintenance > Resources
Below script creates a button on sales screen to to show stock of selected item.
Add the below line Ticket.Buttons:
<button key="button.print" name="stock" code="Script.Stock" shortcut="F9"/>
Create a new resource, Script.Stock, and add the below line:
javax.swing.JOptionPane.showMessageDialog(null, ticket.getLine(sales.getSelectedIndex()).getStock());
To stop selling out of stock items, add below lines in event.addline and event.setline
if(line.getStock()<=0 || line.getStock()-line.getMultiply()<=0) { javax.swing.JOptionPane.showMessageDialog(null, "Out of Stock!"); return "Cancel"; } Save & restart