...
The script should add the "Desserts" «Desserts» menu group when adding the "Beverages" «Beverages» menu group and if the guest gives agrees.
...
Code Block | ||
---|---|---|
| ||
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:
Code Block | ||
---|---|---|
| ||
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.
...
Code Block | ||
---|---|---|
| ||
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.
...
A script to add a bonus dish for each 4th unique dish from the category
There is a "Shot" «Shot» category of dishes. When four identical dishes from this category are ordered, a choice of one dish from the "pizza" «Pizza» category should be provided. Pizza should be added with a zero price, or with a 100% discount.
...
A script for automatic markup depending on the location
ExampleFor 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.
...
Code Block | ||
---|---|---|
| ||
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; |
Скрипт на добавлении скидки при заказе любых двух блюд с доставкой или самовыносом !!!!!!!!!!!!!!!!!!
Системы доставки нет. Вся доставка просто бьется на стол 80, а самовынос - на стол 70.
...
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.
Code Block | ||
---|---|---|
| ||
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 по акции sumActtion := 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; |
Для объект CheckView в событии OnAfterCheckViewEditFor the CheckView object in the OnAfterCheckViewEdit event
Code Block | ||
---|---|---|
| ||
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; |
Скрипт на перенос блюда со 100% скидкой в отдельный пакет
Если 100% скидка применяется на блюдо, у которого цена в момент добавления скидки больше 0, то тогда такое блюдо перемещается в новый пакет с нулевой ценой.
...
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.
Code Block | ||
---|---|---|
| ||
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.
Code Block | ||
---|---|---|
| ||
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; |
Скрипт, выводящий сообщение при добавлении спецблюд
Необходимо, чтобы при пробитии комбо-блюд, относящихся к классификации «49 рублей» на экране выходило информационное окно с текстом «предложи добавку за 49 рублей»
...
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:
Code Block | ||
---|---|---|
| ||
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
Code Block | ||
---|---|---|
| ||
Message_Addon_49 |
3) Назначить скрипт на форму быстрого чекаInsert the script in the quick receipt form
Code Block | ||
---|---|---|
| ||
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; |
Для того ,чтобы в ресторане начали показывать сообщение, нужно указать «1» в расширенном свойстве 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:
Code Block | ||
---|---|---|
| ||
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:
Code Block | ||
---|---|---|
| ||
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:
Code Block | ||
---|---|---|
| ||
if (AVerifyType = vtBill)or(AVerifyType = vtPrintReceipt) then // срабатыватьwork приwhen печатиprinting чекаreceipt иand пречекаbill |
наto
Code Block | ||
---|---|---|
| ||
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).
Code Block | ||
---|---|---|
| ||
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 1is при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 1is при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; |