A script to open a custom selector when adding a specified dish to an order

procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);

var

Categ: TClassificatorGroup;

begin 

if TRK7Restaurant(RK7.CashGroup.MainParent).Code = 6 then

if (AEditType = etInsert) and SYS.ObjectInheritsFrom(AObjectAft, 'TDish') then begin

Categ := TClassificatorGroup(RK7.FindItemByCode(rkrefClassificatorGroups, 145)); // oeacaou eia eeanneoeeaoee

if Categ.IsChild(TDish(AObjectAft).RefItem) then

RK7.PostOperation(rkoPrepaySelector, 145);

end;

end;

A script to offer a dessert to a guest

The script should add the «Desserts» menu group when adding the «Beverages» menu group and if the guest gives agrees.

procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);

var MenuCode, GroupMenu: integer;


begin 

//********** Set parameters ***********//

MenuCode := 11; // code of the "Desserts" menu to be added

GroupMenu := 8; // "beverages" group menu

//********** Set parameters ***********//

if SYS.ObjectInheritsFrom(AObjectAft, 'TMenuGroupLine') then

begin

if (TMenuGroupLine(AObjectAft).Code = GroupMenu) then 

begin 

RK7.PerformRefObject(RK7.FindItemByCode(rkrefCategList, MenuCode )); //Code open menu

end

end

end;

A script to automatically turn on charging by time

The two restaurants have a common room and separate booths. There is a 10% extra charge for service both in the common room and booths. Besides, in the booths there is an additional minute-by-minute charging. Thus, an hour in the cabin costs 40 somoni, and a minute costs about 66 dirams. It’s necessary to make the system automatically turn on per-minute charging when opening an order in the booths, put it on pause when printing the bill and show the charging amount in the bill. Mobile Waiter is used in one of the restaurants, and a regular POS-terminal — in the second one.

On the receipt editing form of the object, insert the script in the event:

procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);

var i, CntDish: integer;

it: TCheckItem;

begin

if SYS.ObjectInheritsFrom(AObjectAft, 'TDish') then

begin

CntDish := 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 

CntDish := CntDish + 1;

end;

if CntDish = 1 then

RK7.PostOperation(rkoAddTariff, 0);

end;

end;  Instead of the bill selector, create your own variant and assign it a custom operation with the following script:   

procedure ProcessOperation1001625(Parameter: integer);

begin

RK7.PostOperation(rkoCloseTariff, 0);

end;

A script to change the weight of a dish with modifiers

When adding modifiers with the codes specified in the script, their weight specified in the extended property will be removed from the dish served by weight:

procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);

var j,ModifCode1,ModifCode2,ModifCode3: integer;

ed: TObject;

weight:double;

it: TCheckItem;

begin

ModifCode1 := 98;

ModifCode2 := 98;

ModifCode3 := 100;


weight:=0;


if SYS.ObjectInheritsFrom(AObjectAft, 'TModiItem') then

if (TModiItem(AObjectAft).code = ModifCode1)

or(TModiItem(AObjectAft).code = ModifCode2)

or(TModiItem(AObjectAft).code = ModifCode3) then

begin

it := RKCheck.CurrentCheckItem;

if TObject(it) = Nil then Exit;

if SYS.ObjectInheritsFrom(TObject(it), 'TPrintCheckItem') then Exit;

if SYS.ObjectInheritsFrom(TObject(it), 'TDish') then

begin

weight:= TDish(it).Quantity; 

ed := TObject(gui.FindComponentByName('Editor'));

if SYS.ObjectInheritsFrom(TObject(ed), 'TNumEditor') then

begin

weight:=StrToFloat(TModifier(TModiItem(AObjectAft).RefItem).genWeight0419);

TNumEditor(ed).Text := floatToStr(TDish(it).Quantity+(weight/1000)); // + if the modifier has a negative weight, and - if the modifier has a positive weight.

RK7.PerformOperation(rkoEditPortionWeight, 0);

TNumEditor(ed).Text := '';

end;

end; 

end; 

end;

A promotion script: order 2 dishes — get the cheapest 3d one for free

Respectively, two cheapest dishes are for free if 6 dishes are ordered.

On the check editing form of the CheckView object, insert the script in the OnAfterCheckViewEdit event:

procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);

begin

AddEveryOtherDiscount(11{DiscCode}); // 11 opened fixed amount discount on a dish

end;

Before the abovementioned script, add the following one:


Corrected version:


procedure AddEveryOtherDiscount(DiscCode: integer);

var i, j, k, evr, qntdsc, CategCode: integer;

it, CurItem: TCheckItem;

SL: TStringList;

a, q, Price: double;

d: TDish;

CheckView: TCheckView;

categ: TClassificatorGroup;

begin

evr := 3; // make discount every this count

qntdsc := 0;

CategCode := 5; //5 - paste your category code

CheckView := TCheckView(GUI.FindComponentByName('CheckView'));

if CheckView = Nil then Exit;

CurItem := RKCheck.CurrentCheckItem;

SL := TStringList.Create;

try

// Create list of the dishes, sorted by price 

SL.Sorted := True;

for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do begin

it := RKCheck.CurrentOrder.Sessions.Lines[i];

Categ := TClassificatorGroup(getitemBycodeNum('ClassificatorGroups', CategCode));

if SYS.ObjectInheritsFrom(TObject(it), 'TDish') then

if Categ.IsChild(it.RefItem) then //Check category of the dish 

// it := RKCheck.CurrentOrder.Sessions.Lines[i];

if not(TDish(it).IsComboComp) then

if ((it.State = disOpened) or (it.State = disPrinted)) then begin

// gui.showmessage(TDish(it).name);

if (TDish(it).Quantity = 0) or (TDish(it).PRListSum = 0) then Price := TDish(it).Price

else Price := TDish(it).PRListSum/TDish(it).Quantity;

SL.AddObject(FormatFloat('00000000.00', Price) + IntToStr(TDish(it).UNI), TObject(it));

end;

end;


if evr > 0 then

qntdsc := SL.Count div evr;


if SL.Count >= evr then 

for i := 0 to SL.Count - 1 do begin

d := TDish(SL.Objects[i]); 

a := 0;

q := d.Quantity;

if (d.Quantity = 0) or (d.PRListSum = 0) then Price := d.Price

else Price := d.PRListSum/d.Quantity;

while q + 0.0001 > 1 do begin 

//if (i+1) mod evr = 0 then

if ((i+1)<=qntdsc)and(qntdsc>0) then

a := a + Price;

q := q - 1;

end;


// Delete discount, if a sum changed

for j := RKCheck.CheckItemCount(TObject(d.Discounts)) - 1 downto 0 do begin

it := RKCheck.CheckItemByNumber(TObject(d.Discounts), j);

if (it.Code = DiscCode) then begin

if abs(TDiscountItem(it).SrcAmount) = a then

a := 0 

else RKCheck.DeleteCheckItem(it);

break;

end;

end;


// Create discount to a dish

if a > 0 then begin

CheckView.GotoItem(TObject(d));

RKCheck.CreateCheckItem(rkrefDiscounts, IntToStr(DiscCode), FloatToStr(a));

end;

end;

finally

SL.Free();

if CurItem <> Nil then

CheckView.GotoItem(CurItem);

end;

RKCheck.CurrentOrder.Recalc();

end;

A script to automatically add a bonus dish if a specified dish is ordered

The script adds a bonus dish when adding a promotional dish from a specified category.

procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);

var i, j, p, z, CategCode: integer;

Categ: TClassificatorGroup;

it, CurItem: TCheckItem;

DishCode, CntDish1, CntDish2: integer;

CheckView: TCheckView;

DishesCode: TStringList; 

begin

CheckView := TCheckView(GUI.FindComponentByName('CheckView'));

if CheckView = Nil then Exit;

DishesCode := TStringList.Create;

//********** Set parameters ***********//

DishesCode.Add('27;45'); // code of category of promotional dish, for which bonus dish is added; bonus dish code
DishesCode.Add('28;46');

DishesCode.Add('8;43');

//DishesCode.Add('17;24');

//DishesCode.Add('18;25');

//DishesCode.Add('19;26');

//DishesCode.Add('11;27');

//********** Set parameters ***********//

CurItem := RKCheck.CurrentCheckItem;

if SYS.ObjectInheritsFrom(AObjectAft, 'TDish') then //Check dish lines only 

try

for z := 0 to DishesCode.Count-1 do

begin

p:=pos(';',DishesCode.Strings[z]);

CategCode := StrToInt(copy(DishesCode.Strings[z],1,p-1)); // code of category of promotional dish, for which bonus dish is added; 

DishCode := StrToInt(copy(DishesCode.Strings[z],p+1,length(DishesCode.Strings[z])-p)); // bonus dish code

//dbg.dbgprint('CategCode = '+inttostr(CategCode)+' DishCode = '+inttostr(DishCode));

Categ := TClassificatorGroup(getitemBycodeNum('ClassificatorGroups', CategCode));//category code

//dbg.dbgprint('TDish(AObjectAft).Code = '+inttostr(TDish(AObjectAft).Code));

if (Categ.IsChild(TDish(AObjectAft).RefItem)) then // checking category of dish

begin

RKCheck.CreateCheckItem(rkrefMenuItems, IntToStr(DishCode), FloatToStr(TDish(AObjectAft).Quantity)); // add bonus dish

end;

end;

finally

DishesCode.Free();

if CurItem <> Nil then CheckView.GotoItem(CurItem); 

end;

RKCheck.CurrentOrder.Recalc(); // focus is broken if you uncomment

end;

A script to add a bonus dish for each 4th unique dish from the category

There is a «Shot» category of dishes. When four identical dishes from this category are ordered, a choice of one dish from the «Pizza» category should be provided. Pizza should be added with a zero price, or with a 100% discount.

Insert the script in the OnAfterCheckViewEdit event of the CheckView object on the check editing form. All dishes in the category are counted and a bonus dish is added to each nth dish.

procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);

var i, j, CategCode, every, p1, p2: integer;

Categ: TClassificatorGroup;

it, it2, CurItem: TCheckItem;

DishCode, CntDish1, CntDish2, AddDish2: integer;

mem, mem2, str: string;

CheckView: TCheckView; 

DishesCode: TStringList;

begin

CheckView := TCheckView(GUI.FindComponentByName('CheckView'));

if CheckView = Nil then Exit;

//********** Set parameters ***********//

CategCode := 27; // category code

DishCode := 45; // bonus dish code

every := 4;

//********** Set parameters ***********//

Categ := TClassificatorGroup(getitemBycodeNum('ClassificatorGroups', CategCode));//category code

CurItem := RKCheck.CurrentCheckItem;

if SYS.ObjectInheritsFrom(AObjectAft, 'TDish') then //Check dish lines only 

if (Categ.IsChild(TDish(AObjectAft).RefItem)) then // checking category of dish

begin

CntDish2 := 0; // promotional dish number counter

mem := '';

mem2 := '';

for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do

begin

it := RKCheck.CurrentOrder.Sessions.Lines[i];

if SYS.ObjectInheritsFrom(it, 'TDish') then

begin

if (Categ.IsChild(TDish(it).RefItem)) then // checking category of dish

begin

CntDish1 := 0; // promotional dish number counter  

if pos(';' + IntToStr(TDish(it).Sifr) + '=',mem)<=0 then

begin

mem := mem + ';' + IntToStr(TDish(it).Sifr) + '='+FloatToStr(TDish(it).Quantity);

for j := i to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do

begin

it2 := RKCheck.CurrentOrder.Sessions.Lines[j];

if SYS.ObjectInheritsFrom(TObject(it2), 'TDish') then

if (TDish(it2).code=TDish(it).code) then // checking category of dish

CntDish1 := CntDish1 + trunc(TDish(it2).Quantity);

end;

end;

if CntDish1>=every then

begin

mem2 := mem2 + ';' + IntToStr(TDish(it).code) + '='+FloatToStr(CntDish1);

end; 

end;


if (TDish(it).Code = DishCode) then

CntDish2 := CntDish2 + trunc(TDish(it).Quantity);

end;

end;

AddDish2 := 0;

while mem2<>'' do

begin

p1 := Pos(';', mem2);

if p1 > 0 then

begin

str := Copy(mem2, p1+1, 10000);

p2 := Pos(';', str);

if p2 = 0 then p2 := 10000;

str := Copy(mem2, p1+1, p2 - 1);

Delete(mem2, p1, p2);

CntDish1 := trunc(StrToFloat(Copy(str, Pos('=', str)+1, 10000))/every);

if CntDish1>0 then

AddDish2 := AddDish2 + CntDish1;

end;

end;


if (AddDish2 <> CntDish2) then

begin

if CntDish2 > 0 then

begin

for j := RKCheck.CurrentOrder.Sessions.LinesCount - 1 downto 0 do

begin

it := RKCheck.CurrentOrder.Sessions.Lines[j];

if SYS.ObjectInheritsFrom(it, 'TDish') then

if (TDish(it).Code = DishCode) then

RKCheck.DeleteCheckItem(it);

end;

end;

if CntDish1 > 0 then

RKCheck.CreateCheckItem(rkrefMenuItems, IntToStr(DishCode), FloatToStr(AddDish2)); // add bonus dish

end;


end;

if CurItem <> Nil then CheckView.GotoItem(CurItem); 

end;

A script to cancel the discount when adding another discount

procedure DiscountUsage1002304(UsageParameters: TDiscountUsageParameters);

var i,cntDiscount, DiscountCode1, DiscountCode2, DiscountCode3: integer;

it: TCheckItem;

begin

// if not RKCheck.Valid then exit; 

DiscountCode1 := 12; // discount code1

DiscountCode2 := 12; // discount code2

DiscountCode3 := 14; // discount code3

cntDiscount := 0; 

for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do

begin

it := RKCheck.CurrentOrder.Sessions.Lines[i];

if SYS.ObjectInheritsFrom(TObject(it), 'TDiscountItem') then

if (it.code = DiscountCode1)or(it.code = DiscountCode2)or(it.code = DiscountCode3) then 

if TDiscountItem(it).SrcAmount<>0 then

begin 

cntDiscount := cntDiscount + 1;

break;

end;

end;

if cntDiscount>0 then

UsageParameters.UsageMode := umDeny

else

UsageParameters.UsageMode := umAllow;

end;

A script for automatic markup depending on the location

For example: after logging in, the cashier opened the charged place and gave the guest a card, the guest went to the bar and the bartender added dishes to his order on the card.

You need to add a markup at the moment when the bartender opened the order for editing.

procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);

var Categ: TClassificatorGroup;

it: TCheckItem;

i, CategCode, DiscCode, DiscCnt: Integer;

begin

CategCode := 8; // specify the category code

DiscCode := 5; // markup code

DiscCnt := 0;

if AEditType = etInsert then

begin

for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do

begin

it := RKCheck.CurrentOrder.Sessions.Lines[i];

if SYS.ObjectInheritsFrom(TObject(it), 'TDiscountItem') then //Check dish lines only

if (TDiscountItem(it).Code = DiscCode) then

DiscCnt := DiscCnt + 1;

end;


// add discount

Categ := TClassificatorGroup(getitemBycodeNum('ClassificatorGroups', CategCode));

if SYS.ObjectInheritsFrom(TDish(AObjectAft), 'TDish') then

if Categ.IsChild(TDish(AObjectAft).RefItem) then

if DiscCnt = 0 then

RKCheck.CreateCheckItem(rkrefDiscounts, IntToStr(DiscCode), FloatToStr(100)); // add discount with code 11

end; 

end;

A script to adding a free dish on a specified day of the week, at a certain time, when a specified dish is ordered

On the edit form of the CheckView component, insert the script in the OnAfterCheckViewEdit event:

procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);

var i, j: integer;

it: TCheckItem;

DiscCode, DishCode, CntDish1, CntDish2, AddDishCode: integer; 


disk : integer;

disksum: double;

CurrTime, Time1, Time2: TDateTime; 

begin

Time1 := EncodeTime(08,00,00,00); // special offer start

Time2 := EncodeTime(21,00,00,00); // special offer end

DiscCode := 12; // discount code

DishCode := 13; // bonus dish code

AddDishCode := 7; // promotional dish code


CntDish1 := 0;

CntDish2 := 0;

CurrTime := Time;  

//1 = Sunday
 
//2 = Monday
 
//3 = Tuesday
 
//4 = Wednesday
 
//5 = Thursday
 
//6 = Friday
 
//7 = Saturday

if DayOfWeek(Now)=5 then // day of the week check

if (Time1<=CurrTime) and(CurrTime<=Time2) then

if SYS.ObjectInheritsFrom(AObjectAft, 'TDish') then //Check dish lines only

if (TDish(AObjectAft).Code = AddDishCode) then

begin


for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do

begin

it := RKCheck.CurrentOrder.Sessions.Lines[i];

if SYS.ObjectInheritsFrom(it, 'TDish') then

begin

if (TDish(it).Code = AddDishCode) then

CntDish1 := CntDish1 + trunc(TDish(it).Quantity);

if (TDish(it).Code = DishCode) then

CntDish2 := CntDish2 + trunc(TDish(it).Quantity);

end; 

end; 


if GUI.CheckFormInPayMode then Exit;

if RK7.CashUser.ConfirmOperation(rkoCreateVoid) = False then Exit;


if (CntDish1 <> CntDish2) then

begin

if CntDish2 > 0 then

begin

if GUI.CheckFormInPayMode then Exit;

if RK7.CashUser.ConfirmOperation(rkoCreateVoid) = False then Exit;

RK7.PerformOperation(rkoHome, 0);

while True do begin

it := RKCheck.CurrentCheckItem;

if TObject(it) = Nil then break;

if SYS.ObjectInheritsFrom(TObject(it), 'TPrintCheckItem') then break;

if SYS.ObjectInheritsFrom(TObject(it), 'TDish') then

if (TDish(it).Code = DishCode) then begin

if it.State = disOpened then begin

RK7.PerformOperation(rkoDeleteLine, 1); // deletion

continue;

end else

RKCheck.CreateCheckItem(rkrefOrderVoids, '1', FloatToStr(TDish(it).Quantity)); // write-off

end;

RK7.PerformOperation(rkoDown, 0);

end;

end;

if CntDish1 > 0 then

begin

RKCheck.CreateCheckItem(rkrefMenuItems, IntToStr(DishCode), FloatToStr(CntDish1)); // adding a dish

RKCheck.CreateCheckItem(rkrefDiscounts, IntToStr(DiscCode), '0'); // adding a discount

end;

end;

end;

end;

On the edit form of the CheckView component, insert the script in the OnBeforeCheckViewEdit event:

procedure CheckViewOnBeforeCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject; var AAllow: boolean; var AMessage: string);

var i, j: integer;

it: TCheckItem;

DiscCode, DishCode, CntDish1, CntDish2, AddDishCode: integer; 


disk : integer;

disksum: double;

CurrTime, Time1, Time2: TDateTime; 

begin

Time1 := EncodeTime(08,00,00,00); // special offer start

Time2 := EncodeTime(21,00,00,00); // special offer end

DiscCode := 12; // discount code

DishCode := 13; // bonus dish code

AddDishCode := 7; //promotional dish code


CntDish1 := 0;

CntDish2 := 0;

CurrTime := Time;  

//1 = Sunday
 
//2 = Monday
 
//3 = Tuesday
 
//4 = Wednesday
 
//5 = Thursday
 
//6 = Friday
 
//7 = Saturday
  
if DayOfWeek(Now)=5 then // day of the week check

if (Time1<=CurrTime) and(CurrTime<=Time2) then

if SYS.ObjectInheritsFrom(AObjectBef, 'TDish') then //Check dish lines only

if (TDish(AObjectBef).Code = AddDishCode) then

if (AEditType = etRemove) then

begin

for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do

begin

it := RKCheck.CurrentOrder.Sessions.Lines[i];

if SYS.ObjectInheritsFrom(it, 'TDish') then

begin

if (TDish(it).Code = AddDishCode) then

CntDish1 := CntDish1 + trunc(TDish(it).Quantity);

if (TDish(it).Code = DishCode) then

CntDish2 := CntDish2 + trunc(TDish(it).Quantity);

end; 

end; 

CntDish1 := CntDish1 - trunc(TDish(AObjectBef).Quantity);


if GUI.CheckFormInPayMode then Exit;

if RK7.CashUser.ConfirmOperation(rkoCreateVoid) = False then Exit;


if (CntDish1 <> CntDish2) then

begin

if CntDish2 > 0 then

begin 

if GUI.CheckFormInPayMode then Exit;

if RK7.CashUser.ConfirmOperation(rkoCreateVoid) = False then Exit;

RK7.PerformOperation(rkoHome, 0);

while True do begin

it := RKCheck.CurrentCheckItem;

if TObject(it) = Nil then break;

if SYS.ObjectInheritsFrom(TObject(it), 'TPrintCheckItem') then break;

if SYS.ObjectInheritsFrom(TObject(it), 'TDish') then

if (TDish(it).Code = DishCode) then begin

if it.State = disOpened then begin

RK7.PerformOperation(rkoDeleteLine, 1); // deletion

continue;

end else

RKCheck.CreateCheckItem(rkrefOrderVoids, '1', FloatToStr(TDish(it).Quantity)); // write-off

end;

RK7.PerformOperation(rkoDown, 0);

end; 

end;

if CntDish1 > 0 then

begin

RKCheck.CreateCheckItem(rkrefMenuItems, IntToStr(DishCode), FloatToStr(CntDish1)); // adding a dish

RKCheck.CreateCheckItem(rkrefDiscounts, IntToStr(DiscCode), '0'); // adding a discount

end;

end; 

end;

end;


A script to add or to remove dishes at a specified order amount

There is a promotional dish with a zero price. A customer wants this dish to be automatically added to the order if the order amount has reached 999 rubles and to be deleted if the order amount is lower than 999 rubles (they do not trust the staff).

On the order editing form of the CheckView object, insert the script in the OnBeforeCheckViewEdit event:

procedure CheckViewOnBeforeCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject; var AAllow: boolean; var AMessage: string);

var i, j: integer;

it: TCheckItem;

limit, sum : double; 

DiscCode, DishCode, CntDish1: integer; 

begin

limit := 200; 

DishCode := 43; // special dish code

CntDish1 := 0;


// {blocking special dish addition of  if the amount is less specified.
if AEditType = etInsert then

if RKCheck.CurrentOrder.UnpaidSum < limit then

if (TDish(AObjectBef).Code = DishCode) then // dish code

if SYS.ObjectInheritsFrom(AObjectAft, 'TDish') then

begin 

AAllow := false;

AMessage := 'The dish cannot be added because the order is less than 200 rubles';

end;

// }


if SYS.ObjectInheritsFrom(AObjectBef, 'TDish') then

if AEditType = TdiscountItem

e then

begin

sum := 0;

for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do

begin

it := RKCheck.CurrentOrder.Sessions.Lines[i];

if SYS.ObjectInheritsFrom(it, 'TDish') then

if (TDish(it).Code = DishCode) then

CntDish1 := CntDish1 + trunc(TDish(it).Quantity);

end; 

if (TDish(AObjectBef).Code = DishCode) then // dish code

CntDish1 := CntDish1 - trunc(TDish(AObjectBef).Quantity);


if AEditType = etRemove then

sum := RKCheck.CurrentOrder.UnpaidSum - (TDish(AObjectBef).PRListSum)

else

sum := RKCheck.CurrentOrder.UnpaidSum;


if sum < limit then // if the amount is less than the limit, then delete the special dish  

if CntDish1 > 0 then

begin

for j := RKCheck.CurrentOrder.Sessions.LinesCount - 1 downto 0 do begin

it := RKCheck.CurrentOrder.Sessions.Lines[j];

if SYS.ObjectInheritsFrom(it, 'TDish') then

if (TDish(it).Code = DishCode) then

RKCheck.DeleteCheckItem(it);

end;

end; 


if RKCheck.CurrentOrder.UnpaidSum >= limit then // check limit exceed, if the check amount is equal to or exceeds the limit, add the special dish

if CntDish1 = 0 then

RKCheck.CreateCheckItem(rkrefMenuItems, IntToStr(DishCode), '1');

end;

end;

On the order editing form of the CheckView object, insert the script in the OnAfterCheckViewEdit event:

procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);

var i, j: integer;

it: TCheckItem;

limit, sum, Price: double; 

DiscCode, DishCode, CntDish1: integer; 


begin

// if AEditType = etInsert then

if SYS.ObjectInheritsFrom(AObjectAft, 'TDish') then


begin 

sum := 0;

limit := 200; 

DishCode := 43; // special dish code

CntDish1 := 0;


for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do

begin

it := RKCheck.CurrentOrder.Sessions.Lines[i];

if SYS.ObjectInheritsFrom(it, 'TDish') then

if (TDish(it).Code = DishCode) then

CntDish1 := CntDish1 + trunc(TDish(it).Quantity);

end; 


if (TDish(AObjectBef).Code = DishCode) then // dish code

CntDish1 := CntDish1 - trunc(TDish(AObjectBef).Quantity);


Price := (TDish(AObjectAft).PRListSum) - (TDish(AObjectBef).PRListSum);


sum := RKCheck.CurrentOrder.UnpaidSum + Price;

if sum < limit then 

if CntDish1 > 0 then

begin

for j := RKCheck.CurrentOrder.Sessions.LinesCount - 1 downto 0 do begin

it := RKCheck.CurrentOrder.Sessions.Lines[j];

if SYS.ObjectInheritsFrom(it, 'TDish') then

if (TDish(it).Code = DishCode) then

RKCheck.DeleteCheckItem(it);

end;

end;


if sum >= limit then //check limit exceed, if the check amount is equal to or exceeds the limit, add the special dish  

if CntDish1 = 0 then

RKCheck.CreateCheckItem(rkrefMenuItems, IntToStr(DishCode), '1');


end; 

end;

A script to automatically add a dish to an order

If the order amount is more than 1000 rubles, a specified dish is added to the order, and if the order amount is more than 2000 rubles, another specified dish is added.

Also, a 20% discount is automatically applied if you add a dish at the price of 1000 rubles (the order amount will be 800 rubles in this case).

A free dish is added when the order is gradually formed. When the order amount is reduced, the dish is deleted. If the order exceeds the amount of 2000 rubles, a free dish with the condition order>2000 rubles is added, and a dish with the condition order>1000 rubles is removed. And if you reduce the order amount from 2000 to 1500, then the dish with the condition order>2000 rubles is removed, and the dish with the condition order>1000 rubles should be added.

procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);

var i, j: integer;

it: TCheckItem;

limit1, limit2, sum, Price: double; 

DishCode1, DishCode2, CntDish1, CntDish2: integer;

go1: boolean;

begin

sum := 0;

limit1 := 1000;

limit2 := 2000;

DishCode1 := 45; // special dish code

DishCode2 := 46; // special dish code

CntDish1 := 0;

CntDish2 :=0;

Price := 0;

go1 := false;


if SYS.ObjectInheritsFrom(AObjectAft, 'TDish') then

if (TDish(AObjectAft).code <> DishCode1) and (TDish(AObjectAft).code <> DishCode2) then

go1 := true;

if go1 or SYS.ObjectInheritsFrom(AObjectAft, 'TDiscountItem') then 

begin


for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do

begin

it := RKCheck.CurrentOrder.Sessions.Lines[i];

if SYS.ObjectInheritsFrom(it, 'TDish') then

begin

if (TDish(it).Code = DishCode1) then

CntDish1 := CntDish1 + trunc(TDish(it).Quantity)

else 

if (TDish(it).Code = DishCode2) then

CntDish2 := CntDish2 + trunc(TDish(it).Quantity);

end;

end; 


if SYS.ObjectInheritsFrom(AObjectAft, 'TDish') then

if ( (TDish(AObjectAft).code <> DishCode1) and (TDish(AObjectAft).code <> DishCode2) ) then

begin

if (TDish(AObjectBef).Code = DishCode1) then // dish code

CntDish1 := CntDish1 - trunc(TDish(AObjectBef).Quantity)

else

if (TDish(AObjectBef).Code = DishCode2) then // dish code

CntDish2 := CntDish2 - trunc(TDish(AObjectBef).Quantity);


// Price := (TDish(AObjectAft).PRListSum) - (TDish(AObjectBef).PRListSum);

Price := (TDish(AObjectAft).SumWithDiscounts) - (TDish(AObjectBef).SumWithDiscounts); // SumWithDiscounts

end;


sum := RKCheck.CurrentOrder.ToPaySum + Price+ RKCheck.CurrentOrder.DiscountSum;


// if SYS.ObjectInheritsFrom(AObjectAft, 'TDiscountItem') then 

// gui.showmessage('ToPaySum='+FloatToStr(RKCheck.CurrentOrder.ToPaySum)+' Price='+FloatToStr(Price)+' Discountsum='+FloatToStr(RKCheck.CurrentOrder.DiscountSum)+' CalcAmount='+FloatToStr(TDiscountItem(AObjectAft).CalcAmount));


if sum < limit2 then

if CntDish2 > 0 then

begin

for j := RKCheck.CurrentOrder.Sessions.LinesCount - 1 downto 0 do

begin

it := RKCheck.CurrentOrder.Sessions.Lines[j];

if SYS.ObjectInheritsFrom(it, 'TDish') then

if (TDish(it).Code = DishCode2) then

RKCheck.DeleteCheckItem(it);

end;

end;


if (sum < limit1) or (sum >=limit2) then

if CntDish1 > 0 then

begin

for j := RKCheck.CurrentOrder.Sessions.LinesCount - 1 downto 0 do

begin

it := RKCheck.CurrentOrder.Sessions.Lines[j];

if SYS.ObjectInheritsFrom(it, 'TDish') then

if (TDish(it).Code = DishCode1) then

RKCheck.DeleteCheckItem(it);

end;

end;


if sum >= limit2 then // check limit exceed ???? ????? ????? ??? ?????? ??????, ?? ???????? ????.?????

begin

if CntDish2 <= 0 then

RKCheck.CreateCheckItem(rkrefMenuItems, IntToStr(DishCode2), '1');

end

else

if sum >= limit1 then // check limit exceed ???? ????? ????? ??? ?????? ??????, ?? ???????? ????.?????

if CntDish1 <= 0 then

RKCheck.CreateCheckItem(rkrefMenuItems, IntToStr(DishCode1), '1');


end;

end;




procedure CheckViewOnBeforeCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject; var AAllow: boolean; var AMessage: string);

var i, j: integer;

it: TCheckItem;

limit1, sum, limit2 : double;

DiscCode, DishCode1, CntDish1, DishCode2, CntDish2: integer;

begin

limit1 := 1000;

limit2 := 2000;

DishCode1 := 45; // special dish code

DishCode2 := 46; // special dish code

CntDish1 := 0;

CntDish2 :=0;


if SYS.ObjectInheritsFrom(AObjectBef, 'TDish') then

if AEditType = etRemove then

begin

sum := 0;

for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do

begin

it := RKCheck.CurrentOrder.Sessions.Lines[i];

if SYS.ObjectInheritsFrom(it, 'TDish') then

begin

if (TDish(it).Code = DishCode1) then

CntDish1 := CntDish1 + trunc(TDish(it).Quantity)

else 

if (TDish(it).Code = DishCode2) then

CntDish2 := CntDish2 + trunc(TDish(it).Quantity);

end;

end;

if (TDish(AObjectBef).Code = DishCode1) then // dish code

CntDish1 := CntDish1 - trunc(TDish(AObjectBef).Quantity)

else

if (TDish(AObjectBef).Code = DishCode2) then // dish code

CntDish2 := CntDish2 - trunc(TDish(AObjectBef).Quantity); 


if AEditType = etRemove then

// sum := RKCheck.CurrentOrder.UnpaidSum - (TDish(AObjectBef).PRListSum)

sum := RKCheck.CurrentOrder.UnpaidSum - (TDish(AObjectBef).SumWithDiscounts)

else

sum := RKCheck.CurrentOrder.UnpaidSum;


if sum < limit2 then // ???? ????? ?????? ??????, ?? ??????? ??????????? ?????

if CntDish2 > 0 then

begin

for j := RKCheck.CurrentOrder.Sessions.LinesCount - 1 downto 0 do begin

it := RKCheck.CurrentOrder.Sessions.Lines[j];

if SYS.ObjectInheritsFrom(it, 'TDish') then

if (TDish(it).Code = DishCode2) then

RKCheck.DeleteCheckItem(it);

end;

end; 


if (sum < limit1) or (sum >=limit2) then // ???? ????? ?????? ??????, ?? ??????? ??????????? ?????

if CntDish1 > 0 then

begin

for j := RKCheck.CurrentOrder.Sessions.LinesCount - 1 downto 0 do begin

it := RKCheck.CurrentOrder.Sessions.Lines[j];

if SYS.ObjectInheritsFrom(it, 'TDish') then

if (TDish(it).Code = DishCode1) then

RKCheck.DeleteCheckItem(it);

end;

end;


if sum >= limit2 then // check limit exceed ???? ????? ????? ??? ?????? ??????, ?? ???????? ????.?????

begin

if CntDish2 <= 0 then

RKCheck.CreateCheckItem(rkrefMenuItems, IntToStr(DishCode2), '1');

end

else

if sum >= limit1 then // check limit exceed ???? ????? ????? ??? ?????? ??????, ?? ???????? ????.?????

if CntDish1 <= 0 then

RKCheck.CreateCheckItem(rkrefMenuItems, IntToStr(DishCode1), '1');


end;

end;

A script to automatically add a free (starter) dish to an order when creating a new order

procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);

var codedish1: integer;

begin

codedish1 := 23; // dish code for autoadding

if RKCheck.CurrentOrder.IsEmpty then

if AEditType = etInsert then

if SYS.ObjectInheritsFrom(TDish(AObjectAft), 'TDish') then

begin

RKCheck.CreateCheckItem(rkrefMenuItems, IntToStr(codedish1), IntToStr(RKCheck.CurrentOrder.GuestsCount)); // add dish

end;

end;

A script to accumulate bonuses depending on the time

Bonuses are valid until 22:00. A guest came at 21:50 and ordered juice for 100 rubles. At 22:20 they ordered a pie for 50 rubles. At 22:40 (or at 01:00am), they asked for a bill and gave the card - bonuses should be credited for the juice, but not for the pie, despite the time of using the card.

A script for the OnAfterCheckViewEdit event in the CheckView object on the order editing form:

procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);

var

i, cntDish, DishCode: integer;

it: TCheckItem;

a, Price: double;

CurrTime, Time1: TDateTime; 

begin

DishCode := 43; // code of dish with open price 

Time1 := EncodeTime(18,05,00,00); // critical time

if (AEditType=etInsert)or(AEditType=etChange) then 

if SYS.ObjectInheritsFrom(AObjectAft, 'TDish') then 

if (TDish(AObjectAft).Code <> DishCode) then

begin

a := 0;

cntDish := 0;

Price := 0;

CurrTime := Time;

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).Code = DishCode) then

cntDish := cntDish + 1

else

begin

if (StrToTime(TimeToStr(TDish(it).Session.StartService)) < Time1) then

a := a + TDish(it).PRListSum;

end;

end; 

if (a > 0.00001) then

begin

if (cntDish = 0) then

RKCheck.CreateCheckItem(rkrefMenuItems, IntToStr(DishCode), FloatToStr(1)) // ?????????? ? ????? ????? ? ????? 43

else

begin


if GUI.CheckFormInPayMode then Exit;

if RK7.CashUser.ConfirmOperation(rkoCreateVoid) = False then Exit;

RK7.PerformOperation(rkoHome, 0);

while True do begin

it := RKCheck.CurrentCheckItem;

if TObject(it) = Nil then break;

if SYS.ObjectInheritsFrom(TObject(it), 'TPrintCheckItem') then break;

if SYS.ObjectInheritsFrom(TObject(it), 'TDish') then begin

if (TDish(it).Code = DishCode) then 

if a <> TDish(it).UserPrice then

if it.State = disOpened then begin

RK7.PerformOperation(rkoDeleteLine, 1);

continue;

end else

RKCheck.CreateCheckItem(rkrefOrderVoids, '1', FloatToStr(TDish(it).Quantity));

end;

RK7.PerformOperation(rkoDown, 0);

end;

if CurrTime < Time1 then 

RKCheck.CreateCheckItem(rkrefMenuItems, IntToStr(DishCode), FloatToStr(1)) 


end; 

if CurrTime < Time1 then 

if trk7menuItem(TDish(RKCheck.CurrentCheckItem).RefItem).OpenPrice then

begin

TDish(RKCheck.CurrentCheckItem).IsUserPrice := true;

TDish(RKCheck.CurrentCheckItem).UserPrice := a;

end;

end;

end;

end;

A script for the OnBeforeCheckViewEdit event in the CheckView object on the order editing form:

procedure CheckViewOnBeforeCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject; var AAllow: boolean; var AMessage: string);

var

i, j, cntDish, DishCode: integer;

it: TCheckItem;

a, Price: double;

CurrTime, Time1: TDateTime; 

begin

DishCode := 43; // code for dish with open price 

Time1 := EncodeTime(18,05,00,00); // critical time

if (AEditType=etRemove) then // etChange etRemove

if SYS.ObjectInheritsFrom(AObjectBef, 'TDish') then 

if (TDish(AObjectBef).Code <> DishCode) then

begin

a := 0;

cntDish := 0;

Price := 0;

CurrTime := Time;

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).Code = DishCode) then

cntDish := cntDish + 1

else

begin


if (StrToTime(TimeToStr(TDish(it).Session.StartService)) < Time1) then

a := a + TDish(it).PRListSum;

end;

end; 


// if (StrToTime(TimeToStr(TDish(AObjectBef).Session.StartService)) < Time1) then // take into account deleted dish cost / uncomment when the bug is fixed  

a := a - TDish(AObjectBef).PRListSum;


if (a > 0.00001) then

begin

if (cntDish = 0) then

RKCheck.CreateCheckItem(rkrefMenuItems, IntToStr(DishCode), FloatToStr(1)) 

else

if CurrTime < Time1 then

begin


if GUI.CheckFormInPayMode then Exit;

if RK7.CashUser.ConfirmOperation(rkoCreateVoid) = False then Exit;

RK7.PerformOperation(rkoHome, 0);

while True do begin

it := RKCheck.CurrentCheckItem;

if TObject(it) = Nil then break;

if SYS.ObjectInheritsFrom(TObject(it), 'TPrintCheckItem') then break;

if SYS.ObjectInheritsFrom(TObject(it), 'TDish') then begin

if (TDish(it).Code = DishCode) then 

if a <> TDish(it).UserPrice then

if it.State = disOpened then begin

if trk7menuItem(TDish(it).RefItem).OpenPrice then

begin

TDish(it).IsUserPrice := true;

TDish(it).UserPrice := a;

end; 

end else

RKCheck.CreateCheckItem(rkrefOrderVoids, '1', FloatToStr(TDish(it).Quantity));

end;

RK7.PerformOperation(rkoDown, 0);

end;

end; 

end;

end;

end;

In the scripts, set the appropriate values for DishCode and Time1.

A script to display a discount in the order when printing the bill

procedure DiscountUsage1001731(UsageParameters: TDiscountUsageParameters);

var i: integer;

it: TCheckItem;

a: double; 

begin 

a := 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

a := a + TDish(it).PRListSum

else if SYS.ObjectInheritsFrom(TObject(it), 'TChargeLine') then

a := a + TChargeLine(it).CalcAmount;

end;


if a >= 150 then

UsageParameters.UsageMode := umAuto

else UsageParameters.UsageMode := umDeny;

end;

A script to add a discount when ordering any two dishes for delivery or take-out

There is no delivery system. All delivery orders are assigned to the table 80, and take-out orders —to the table 70.

A script for the CheckView object in the OnBeforeCheckViewEdit event.

procedure CheckViewOnBeforeCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject; var AAllow: boolean; var AMessage: string);

var ToPaySum, sumDiscount : double;

i, CntDicount, DiscCode, sumActtion: integer;

it: TCheckItem;

begin

CntDicount := 0;

DiscCode := 18; // code of fixed amount discount added within special offer  

sumActtion := 700; // receipt amount to activate special offer  

sumDiscount := 70; // amount of applied discount (insert amount from fixed amount discount settings)  

ToPaySum := RKCheck.CurrentOrder.ToPaySum;

if AEditType = etRemove then

begin

for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do begin

it := RKCheck.CurrentOrder.Sessions.Lines[i];

if SYS.ObjectInheritsFrom(TObject(it), 'TDiscountItem') then

if (it.Code = DiscCode) then

CntDicount := CntDicount + 1;

end;


if SYS.ObjectInheritsFrom(AObjectBef, 'TDish') then 

ToPaySum := ToPaySum - TDish(AObjectBef).PRListSum;

if CntDicount > 0 then

ToPaySum := ToPaySum + sumDiscount;

if ToPaySum >= sumActtion+sumDiscount then

begin

if CntDicount = 0 then

RKCheck.CreateCheckItem(rkrefDiscounts, IntToStr(DiscCode), FloatToStr(0));

end

else

if CntDicount > 0 then

for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do begin

it := RKCheck.CurrentOrder.Sessions.Lines[i];

if SYS.ObjectInheritsFrom(TObject(it), 'TDiscountItem') then

if (it.Code = DiscCode) then begin

RKCheck.DeleteCheckItem(it);

CntDicount := 0;

end;

end; 

end; 

end;

For the CheckView object in the OnAfterCheckViewEdit event

procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);

var ToPaySum, sumDiscount, sumActtion: double;

i, CntDicount, DiscCode: integer;

it: TCheckItem;

begin

CntDicount := 0;

DiscCode := 18; // code of fixed amount discount added within special offer  

sumActtion := 700; // receipt amount to activate special offer  

sumDiscount := 70; // amount of applied discount(insert amount from fixed amount discount settings)  

if not(AEditType = etRemove) then

begin

ToPaySum := RKCheck.CurrentOrder.ToPaySum;

for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do begin

it := RKCheck.CurrentOrder.Sessions.Lines[i];

if SYS.ObjectInheritsFrom(TObject(it), 'TDiscountItem') then

if (it.Code = DiscCode) then

CntDicount := CntDicount + 1;

end;


if SYS.ObjectInheritsFrom(AObjectAft, 'TDish') then 

begin 

if AEditType = etInsert then

ToPaySum := ToPaySum + TDish(AObjectAft).PRListSum

else if AEditType = etChange then

ToPaySum := ToPaySum + TDish(AObjectAft).PRListSum - TDish(AObjectBef).PaySum; 

end;


if ToPaySum >= sumActtion+sumDiscount then

begin

if CntDicount = 0 then

RKCheck.CreateCheckItem(rkrefDiscounts, IntToStr(DiscCode), FloatToStr(0));

end

else

if CntDicount > 0 then

for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do begin

it := RKCheck.CurrentOrder.Sessions.Lines[i];

if SYS.ObjectInheritsFrom(TObject(it), 'TDiscountItem') then

if (it.Code = DiscCode) then begin

RKCheck.DeleteCheckItem(it);

CntDicount := 0;

end;

end; 

end;

end;

A script to transfer dishes with a 100% discount to a separate block

If a 100% discount is applied to a dish that has a price greater than 0 at that moment, then this dish is transferred to a new block with a zero price.

When transferring a dish, the name of the discount is saved under this dish. And then you can see the report on these discounts.

procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);

begin

if AEditType = etInsert then

begin

if SYS.ObjectInheritsFrom(AObjectAft, 'TDiscountItem') then

if (TDiscountItem(AObjectAft).Code = 1000105) then // discount code

begin

if trk7menuItem(TDish(RKCheck.CurrentCheckItem).RefItem).OpenPrice then

begin

TDish(RKCheck.CurrentCheckItem).IsUserPrice := true;

TDish(RKCheck.CurrentCheckItem).UserPrice := 0;

end;

RK7.PerformOperation(rkoMoveCurrentDishToSes, 1000155) // ident of course

if SYS.ObjectInheritsFrom(RKCheck.CurrentCheckItem, 'TDish') then

if RKCheck.CurrentCheckItem.Session.iKurs <> 1000155 then

RKCheck.DeleteCheckItem(TDiscountItem(AObjectAft)); 

end;

end; 

end;

Dish status check.

procedure ProcessOperation1001712(Parameter: integer);

var

it: TCheckItem;

i, code: integer;

qntnew, qntold, pricenew: double;

CurItem: TCheckItem;

ed: TObject;

begin

qntnew := 0;

pricenew := 100;

if not RKCheck.Valid then

exit //important checking

else

begin

CurItem := RKCheck.CurrentCheckItem;

if not(TDish(CurItem).State = disOpened) then

begin

gui.showmessage('You can''t move saved dish!!!');

exit;

end; 

ed := TObject(gui.FindComponentByName('Editor'));

if SYS.ObjectInheritsFrom(TObject(ed), 'TNumEditor') then

if (length(TNumEditor(ed).Text)>0) then

qntnew := StrToFloat(TNumEditor(ed).Text)

else

qntnew := 1;

if SYS.ObjectInheritsFrom(TObject(CurItem), 'TDish') then

if (TDish(CurItem).quantity > qntnew) and (qntnew > 0) then

begin

TNumEditor(ed).Text := FloatToStr(TDish(CurItem).quantity-qntnew);

RK7.PerformOperation(rkoEditAmount, 0);

code := CurItem.code; 

RK7.PerformOperation(rkoDown, 0);

RKCheck.CreateCheckItem(rkrefMenuItems, IntToStr(code), IntToStr(Trunc(qntnew))); // add dish

end;

end;

TNumEditor(ed).Text := FloatToStr(qntnew);

// RK7.PerformOperation(rkoMoveCurrentDishToSes, 1000155) // ident of course 

RK7.PerformOperation(rkoMoveCurrentDishToSes, 1) // ident of course 

TNumEditor(ed).Text := '';

RK7.PostOperation(rkoDiscountSelector, 0); 

end;

A script to display a message when adding special dishes

When combo dishes from the «49 rubles» classification are ordered, «Offer an additive for 49 rubles» should appear on the screen.

1) Insert the script in the OnAfterCheckViewEdit event of the CheckView object on the order editing form:

procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);

var

Categ: TClassificatorGroup;

begin 

if AEditType = etInsert then

if SYS.ObjectInheritsFrom(AObjectAft, 'TDish') then

if TDish(AObjectAft).IsCombo then

begin

Categ := TClassificatorGroup(RK7.FindItemByCode(rkrefClassificatorGroups, 8)); // specify classification code

if Categ.IsChild(TDish(AObjectAft).RefItem) then

gui.ShowMessage('Offer an additive for 49 rubles');

end; 

end;

2) Add an extended property in the restaurant

Message_Addon_49

3) Insert the script in the quick receipt form

procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);

var

Categ: TClassificatorGroup;

begin

if ( TRK7Restaurant(RK7.CashGroup.MainParent).genMessage_Addon_49='1') then

if AEditType = etInsert then

if SYS.ObjectInheritsFrom(AObjectAft, 'TDish') then

if TDish(AObjectAft).IsCombo then

begin

Categ := TClassificatorGroup(RK7.FindItemByCode(rkrefClassificatorGroups, 144)); // specify classification code

if Categ.IsChild(TDish(AObjectAft).RefItem) then

gui.ShowMessage('Offer the guest an additive to the combo for 49 rubles');

end;

end;

To start showing this message in the restaurant, specify «1» in the Message_Addon_49 extended property

A script for the forced choice of the consumator when choosing a dish

On the check editing form for the CheckView object, in the OnAfterCheckViewEdit event insert a script to open the choice of a consumator when adding a specified dish:

procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);

var

i, DishCode: integer;

it: TCheckItem; 

begin

DishCode := 13; // код контролируемого блюда

if (AEditType=etInsert)or(AEditType=etChange) then 

if SYS.ObjectInheritsFrom(AObjectAft, 'TDish') then 

if (TDish(AObjectAft).Code = DishCode) then

begin

RK7.PerformOperation(rkoConsumatorSelector, 1);

end;

end;

On the check editing form for the CheckView object, in the OnOrderVerify event insert the script to disable further work when printing a receipt or a bill if there is no consummator for a controlled dish:

procedure CheckViewOnOrderVerify(Sender: TObject; AVerifyType: TVerifyType; oper: integer; var AContinue: boolean);

var

i, DishCode: integer;

it: TCheckItem; 

begin

DishCode := 13; // controlled dish code

if (AVerifyType = vtBill)or(AVerifyType = vtPrintReceipt) then // work when printing receipt or bill

for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do

begin

it := RKCheck.CurrentOrder.Sessions.Lines[i];

if SYS.ObjectInheritsFrom(it, 'TDish') then

if (TDish(it).Code = DishCode) then

begin

// checking by Consumators

if TDish(it).Consumators.Count = 0 then

begin 

gui.ShowMessage('The operation is prohibited because no consumator is selected!');

AContinue := false;

end;

end;

end; 

end;

To prohibit the exit from the receipt, if the dish does not have a consumator, change the condition in the line:

 if (AVerifyType = vtBill)or(AVerifyType = vtPrintReceipt) then // work when printing receipt and bill

to

if (AVerifyType = vtBeforeSave)or(AVerifyType = vtBill)or(AVerifyType = vtPrintReceipt) then // work when saving order, printing receipt and bill

A script for automatic price change

It is necessary to change the price of coffee when selling coffee together with any dish from the «Food» classification (not the category).

procedure ChangePrice;

var i, CategCode1, CategCode2, Categ2DishCnt, course1, course2: integer; 

Categ1, Categ2: TClassificatorGroup;

it, CurItem: TCheckItem;

CheckView: TCheckView;

begin

//********** Set parameters ***********//

course1 := 1002378; // ident of course 1 // pecify ID of serving order to which price type for category 1 dish is linked if there are dishes from category 2 in the order  

course2 := 1002379; // ident of course 2 // pecify ID of serving order to which price type for category 1 dish is linked if there are dishes from category 2 in the order  

CategCode1 := 8; // code of category for cofe // code of category 1

CategCode2 := 27; // code of category FOOD // code of category 2

//********** Set parameters ***********//

CheckView := TCheckView(GUI.FindComponentByName('CheckView'));

if CheckView = Nil then Exit;

Categ2DishCnt := 0;

Categ1 := TClassificatorGroup(getitemBycodeNum('ClassificatorGroups', CategCode1));//category code

Categ2 := TClassificatorGroup(getitemBycodeNum('ClassificatorGroups', CategCode2));//category code

for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do

begin

it := RKCheck.CurrentOrder.Sessions.Lines[i];

if SYS.ObjectInheritsFrom(it, 'TDish') then

if Categ2.IsChild(TDish(it).RefItem) then

if TDish(it).Quantity > 0 then

Categ2DishCnt := Categ2DishCnt + 1;

end;

CurItem := RKCheck.CurrentCheckItem;

RK7.PerformOperation(rkoHome, 0);

while True do begin

it := RKCheck.CurrentCheckItem;

if TObject(it) = Nil then break;

if SYS.ObjectInheritsFrom(TObject(it), 'TPrintCheckItem') then break;

if SYS.ObjectInheritsFrom(TObject(it), 'TDish') then

if (Categ1.IsChild(TDish(it).RefItem)) then // checking category of dish

if Categ2DishCnt > 0 then

begin 

if TRk7MenuItem(it.RefItem).Kurs <> course1 then

RK7.PerformOperation(rkoMoveCurrentDishToSes, course1) // change course

end

else

begin 

if TRk7MenuItem(it.RefItem).Kurs <> course2 then

RK7.PerformOperation(rkoMoveCurrentDishToSes, course2); // change course;

end;

RK7.PerformOperation(rkoDown, 0);

end; 

if CurItem <> Nil then CheckView.GotoItem(CurItem);

end;


procedure CheckViewOnAfterCheckViewEdit(Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject);

begin

ChangePrice;

end;


procedure CheckViewCurItemChangedScript(Sender: TObject);

begin

ChangePrice;

end;
  • No labels