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, "Stock: " + sales.getStock(ticket.getLine(sales.getSelectedIndex()).getProductID()) + " " + "Buy Price: " + ticket.getLine(sales.getSelectedIndex()).printPriceBuy());
To stop selling out of stock items, add below lines in event.addline and event.setline
event.addline
if(sales.getStock(line.getProductID())==0 || sales.getStock(line.getProductID())-line.getMultiply()<=0)
{
javax.swing.JOptionPane.showMessageDialog(null, "There is no stock of this item.");
return "Cancel";
}
event.setline
if(sales.getStock(line.getProductID())==0 || sales.getStock(line.getProductID())-line.getMultiply()<0)
{
javax.swing.JOptionPane.showMessageDialog(null, "There is no stock of this item.");
return "Cancel";
}
Save & restart
Leave a Reply