POS - Script Happy hour functionality
Code snippetName: POS - Happy Hour functionality
|
This code snippet is intented to implement a simple Happy hour functionality.
This code has been copied from this forum thread.
The script allow user to specify the time range (start - end hour) and the quantity of the discount to be applied during the Happy hour.
- Login as Administrator and go to Maintenance-->Resources and select Ticket.Buttons resource.
- Add a new line:
<event key="ticket.addline" code="event.happyhour"/>
- Create new resource event.happyhour with this content:
import java.util.Calendar; Calendar cal = Calendar.getInstance(); int hour = cal.get(Calendar.HOUR_OF_DAY); //Discount discountrate = 0.2; //Happy hour range start = 12; end = 13; if (hour>=start && hour<end) { p = line.getPrice(); line.setPrice(p - (p*discountrate)); }
You can modify the discount rate and also the period (start and end).
4. Save changes and restart the application.
The discount will be applied to new added lines if the current time is between selected range.