UnicentaPOS Help Wiki
Advertisement

THIS MY EDITED VERSION OF ANOTHER SCRIPT

It is available under the Creative Commons Share and Share Alike Licence

This code snippet is intented to implement a simple Happy hour functionality. This script allows a discount between 2 times

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. This example gives a discount between 12 am and 13 pm of 20% (0.2)

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:Edit[]

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

Advertisement