Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

Solution:

Code Block
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

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

Solution:

Code Block
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

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

Solution:

Code Block
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;

...