Automatic Discount Deletion Once the Discount Use Period Expires

Task: A discount should automatically disappear from a saved order after a certain time.

For example, there is a manually added Happy Hour discount that is active from 11 am to 1 pm. If a saved order remains unpaid until after 1:30 pm, the discount must automatically disappear and must not apply to the dishes added to the order before 1 pm.

Solution:

procedure DiscountUsage1001863(UsageParameters: TDiscountUsageParameters);
var
  t1, t2: TDatetime;
begin
  t1 := StrToTime('11:00:00');  // hour:minutes:seconds
  t2 := StrToTime('13:30:00');  // hour:minutes:seconds
  if (Time >= t1)and(Time < t2) then
    UsageParameters.UsageMode := umAllow //umAuto
  else
    UsageParameters.UsageMode := umDeny;
end;

Deleting an Automatic Extra Charge Once a Certain Dish is Added

Task: A karaoke has an automatic extra charge (entry fee). To create a script deleting an extra charge once a certain dish is added to an order (song order) or to display a reminder that the extra charge should be deleted.

Solution:

procedure DiscountUsage1000872(UsageParameters: TDiscountUsageParameters);
var i: integer;
    it: TCheckItem;
begin
  for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do begin
    it := RKCheck.CurrentOrder.Sessions.Lines[i];
    if SYS.ObjectInheritsFrom(TObject(it), 'TDish') then
    if (it.CODE = 23) then  // change 23 to the code of the dish that cancels a discount
    Begin
     UsageParameters.UsageMode := umDeny;
     Exit;
    End;
  end;
  UsageParameters.UsageMode := umAuto;
end;

Adding a Discount to Every Second Dish in the Order

Task: To create a script that will allow applying a discount to every second dish. Codes of specific dishes must be indicated in the script and can be changed.

Solution:

procedure DiscountUsage1001506(UsageParameters: TDiscountUsageParameters);

var i,sd,CategCode: integer;
    it: TCheckItem;
    Categ: TClassificatorGroup;
begin
  if not RKCheck.Valid then Exit;
  CategCode := 8;   // indicate category code
  Categ := TClassificatorGroup(getitemBycodeNum('ClassificatorGroups', CategCode));
  sd := 0;
  for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do begin
    it := RKCheck.CurrentOrder.Sessions.Lines[i];
    if SYS.ObjectInheritsFrom(TObject(it), 'TDish') then
//      if Categ.IsChild(TDish(it).RefItem) then    // running a check by dish category
     if
      //Dishes
      ((it.CODE = 3006)
      or (it.CODE = 3007)
      or (it.CODE = 3022)
      or (it.CODE = 3025)
      or (it.CODE = 8056)
      or (it.CODE = 8060)
      or (it.CODE = 3035)
      or (it.CODE = 3036)
      or (it.CODE = 8096)
      or (it.CODE = 8097)
      or (it.CODE = 3029)
      or (it.CODE = 3031)
      or (it.CODE = 3032)
      or (it.CODE = 3003)
      or (it.CODE = 3018)
      or (it.CODE = 3019)
      //Combo
      or (it.CODE = 8066)
      or (it.CODE = 8067)
      or (it.CODE = 8068)
      or (it.CODE = 5011)
      or (it.CODE = 5015)
      or (it.CODE = 5023)
      or (it.CODE = 5026)
      or (it.CODE = 5029)
      or (it.CODE = 5102)
      or (it.CODE = 5152)
      or (it.CODE = 5202)
      or (it.CODE = 5254)
      or (it.CODE = 5302)
      or (it.CODE = 5354)
      or (it.CODE = 5402)
      or (it.CODE = 5452)
      or (it.CODE = 5502)
      or (it.CODE = 5552)
      or (it.CODE = 5604)
      or (it.CODE = 5654)
      or (it.CODE = 5754)
      or (it.CODE = 5904)
      or (it.CODE = 5039)
      or (it.CODE = 5040)
      or (it.CODE = 5041)
      or (it.CODE = 5042)
      or (it.CODE = 5043)
      or (it.CODE = 5044)
      or (it.CODE = 5045)
      or (it.CODE = 5046)
      or (it.CODE = 6013)
      or (it.CODE = 6014)
      or (it.CODE = 6015)
      or (it.CODE = 5047)
      or (it.CODE = 5048)
      or (it.CODE = 5049)
      or (it.CODE = 5050)
      or (it.CODE = 5051)
      or (it.CODE = 5052)
      or (it.CODE = 5053)
      or (it.CODE = 5201)
      or (it.CODE = 5204)
      or (it.CODE = 5205)
      or (it.CODE = 5206)
      or (it.CODE = 5207)
      or (it.CODE = 5208)
      or (it.CODE = 5209)
      or (it.CODE = 5210)
      or (it.CODE = 5211)
      or (it.CODE = 5212)
      or (it.CODE = 5213)
      or (it.CODE = 5214)
      or (it.CODE = 5215)
      or (it.CODE = 5216)
      or (it.CODE = 5217)
      or (it.CODE = 5218)
      or (it.CODE = 5219)
      or (it.CODE = 5220)
      or (it.CODE = 5221)
      or (it.CODE = 5222)
      or (it.CODE = 5223)
      or (it.CODE = 5224)
      or (it.CODE = 5054)
      or (it.CODE = 5055)
      or (it.CODE = 5056)
      or (it.CODE = 5225))
     then   // running a check by dish code
       sd := sd + 1;
  end;
  if sd>0 then
    UsageParameters.UsageMode := umAllow   // umAllow  umAuto
  else
    UsageParameters.UsageMode := umDeny;
end;

Adding a Discount If an Order Contains Dishes from a Certain Category

Task: To create a script automatically adding a discount if an order contains dishes of the category indicated in that script:

Solution:

procedure DiscountUsage1002322(UsageParameters: TDiscountUsageParameters);
var i,sd,CategCode: integer;
    it: TCheckItem;
    Categ: TClassificatorGroup;
begin
  if not RKCheck.Valid then Exit;
  CategCode := 8;   // indicate category code
  Categ := TClassificatorGroup(getitemBycodeNum('ClassificatorGroups', CategCode));
  sd := 0;
  for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do begin
    it := RKCheck.CurrentOrder.Sessions.Lines[i];
    if SYS.ObjectInheritsFrom(TObject(it), 'TDish') then
      if TDish(it).Quantity > 0 then
        if Categ.IsChild(TDish(it).RefItem) then    // running a check by dish category
          sd := sd + 1;
  end;
  if sd>0 then
    UsageParameters.UsageMode := umAuto   // umAllow  umAuto
  else
    UsageParameters.UsageMode := umDeny;
end;


  • No labels