View Categories

Restrict KOT cancellation

1 min read

This script allow to control users who can cancel KOT. Use below script in event.removeline resource.

line = ticket.getLine(index);
String a = line.getProperty("sendstatus");
String b = "Yes";
String c = "No";
String d = "N/A";
Integer myCount = 0;
//get count of auxiliar after the main product
for (i = index+1; i < ticket.getLinesCount(); i++) {
if (ticket.getLine(i).isProductCom()){
  myCount = myCount + 1;
  }else{
  break;
  }
 }
 //Set SendStatus of sent items to Cancel
 if (a.equals(b) && !line.isProductCom()) {
  for (i = index + myCount; i>= index ; i--) {
   if (ticket.getLine(i).isProductCom() && ticket.getLine(i).getProperty("sendstatus").equals("Yes")){
 if(user.getRoleName().equals("Administrator") || user.getRoleName().equals("Manager"))
 {
     ticket.getLine(i).setProperty("sendstatus", "Cancel");
 }
 else
 {
     javax.swing.JOptionPane.showMessageDialog(null, "You are not allowed to cancel KOT!" );
 }
 }else if (ticket.getLine(i).isProductCom() && ticket.getLine(i).getProperty("sendstatus").equals("No")){
   ticket.removeLine(i);
   }else{
   break;
   }
  }
  if(user.getRoleName().equals("Administrator") || user.getRoleName().equals("Manager"))
 {
     line.setProperty("sendstatus", "Cancel");
 }
 else
 {
     javax.swing.JOptionPane.showMessageDialog(null, "You are not allowed to cancel KOT!" );
 }
 }
 //Removelines of NOT sent items
 if ((a.equals(c) || a.equals(d))&& !line.isProductCom()) {
  for (i = index + myCount; i>= index ; i--) {
   if (ticket.getLine(i).isProductCom()){
   ticket.removeLine(i);
   }else{
   break;
   }
  }
 ticket.removeLine(index);
 }else if (a.equals(c) && line.isProductCom()) {
 ticket.removeLine(index);
 }
 //Cancel event
 removeLine.cancel=true;

0 Comments

Leave a Reply

Arrow-up