Introduction to Scripts
The Service > Scripts reference contains almost all the scripts that can be used in the system. Scripts from this reference can be linked to operations in the Service > Operations reference.
Scripts can also be written in the form of an event handler (Options > User interface > Forms), in the Layout Editor, and in MCR algorithms.
Scripts can be of several pre-installed types:
- Cash operations control
- Awards/Penalties
- Other systems card processing
- Operations
- Discounts apply rules.
Scripts of the Cash operations control type describe some verifications, performed before the operation in the order editing form. Scripts of the Operations type process operations, not included in the list of pre-installed system operations.
For example, the following script adds a dish with an open price to the order and sets its price according to the value entered in the input window. In the Operations reference, the script is linked to a user operation (an operation belonging to the same-name operation group). Then the operation is linked to the function button, which should be dragged into the operations selector in the order editing form.
procedure ProcessOperation1001510(Parameter: integer); var NumberEditor: TNumEditor; SomeoneBonus: double; BonusPercent: double; MenuItemCode: string; begin MenuItemCode := '99'; if not RkCheck.Valid then exit; NumberEditor := TNumEditor(gui.FindComponentByName('Editor')); if assigned(NumberEditor) then begin BonusPercent := strtofloat(NumberEditor.Text); if BonusPercent = 0 then begin gui.ShowMessage('Enter a non-zero bonus percent'); exit; end; SomeoneBonus := RkCheck.CurrentOrder.ToPaySum * BonusPercent / 100; // Add a dish RkCheck.CreateCheckItemByReferenceCode(rkoDishSelector, MenuItemCode); // Specify price value NumberEditor.Text := floattostr(SomeoneBonus); // And set it o the just added dish RK7.PerformOperation(rkoEditOpenPrice, 0); // end; end;
To use scripts of the Cash operations control type, go to Options > User Interface > Form Schemes, select the required scripts on the Script links tab and assign the form schemes usage.
The syntax of the scripting language resembles the syntax of Pascal. In addition to using procedures and objects of its own design, it uses standard items of the Pascal language, such as functions for working with strings and numbers.
Overview of components
TForm | Form |
OnRefObject | |
OnProcessCard | |
TGButton | The button |
TGOperationButton | The button performing the standard operation |
OnPressButton | Button click handler TNotifyEvent |
TButtonPanel | The set of buttons |
TSelectorPanel | The selector |
OnSuitableObject | Checks whether to show this object procedure (Sender:tBasePanel;Obj: TObject;var Suitable:boolean) |
AfterConnectObject | Allows changing the properties of the button on which the object is displayed procedure(Obj:TObject; Button:TGCustomButton) |
OnContainChilds | Checks whether the object has subitems procedure(Sender: TCustomButtonPanel; Obj: TObject; var res: boolean) |
OnButtonPressed | The button click handler TNotifyEvent |
OnSelectItem | Called when an object is selected (more relevant for keyboard stations) procedure(Obj:TObject; Button:TGCustomButton) |
OnCanChangeSelection | Whether it is possible to move another item procedure (Sender:TCustomButtonPanel;var Allow:boolean) |
OnGetPanelSize | Setting the selector size procedure (Sender: TCustomButtonPanel; var RowCount, ColCount, MinRowCount, MinColCount: integer) |
TCheckView | Viewing the order content |
OnBeforeCheckViewEdit | Called before adding the item to the order procedure (Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject; var AAllow: boolean; var AMessage: string) |
OnAfterCheckViewEdit | Called after adding the item to the order procedure (Sender: TObject; AEditType: TEditType; AObjectBef, AObjectAft: TObject) |
OnOrderVerify | Called before important events procedure (Sender: TObject; AVerifyType: TVerifyType; oper: integer; var AContinue: boolean) |
BeforeCurItemChanged | Called before moving to another line in CheckView procedure (Sender: TObject; NewItem: integer; var Allow: boolean) |
OnGetColors | Allows coloring the CheckView depending on the order content procedure (Sender: TObject; CheckItem: TObject; Selected: boolean; var Color, FontColor: TColor) |
OnGetCollection | Sets which collection to show in the selector procedure (Sender:TSelectorPanel; var col:tReferentCollection; var ParentObject:tObject) |
OnCompare | Comparison of items. Called to sort the selector items by the custom type function(a,b:tObject):integer |
OnSendObject | procedure (Sender:TSelectorPanel; var item:tObject) |
TGEditor | Text input field |
OnChange | Called to check if the text can be changed procedure (Sender: TObject; var NewText: string; var Allow: boolean) |
OnChanged | Called when the text changes tNotifyEvent |
TNumEditor | Numbers input field |
OnEnterKey | Called when the Enter button is pressed procedure(Sender:TCustomNumEditor;var GoNextField:Boolean) |
TCodeEditor | Input field for selecting a reference item |
OnSuitableItem | Checks whether this object can be selected procedure (Sender:tBasePanel;item:tReferentItem;var Suitable:boolean) |
OnNewItem | Called when an object is selected procedure(Item:tReferentItem;Editor:tCodeEditor) |
TGLabel | Text label |
TGPanel | Panel |
TTimer | Timer |
OnTimer | The action to perform when the timer is triggered TNotifyEvent |
Classes Overview
There are two types of classes:
- Reference classes
- Checkitem classes.
Each reference item corresponds to a specific class. Below is a list of references and their corresponding classes.
TRK7MenuItem | Menu Item |
---|---|
TModifier | Modifier |
Now let's look at the classes for the receipt data
TCheckItem | Common ancestor |
---|---|
RO Sifr | Identifier |
RO State | Status: disOpened, disFixed, disPrinted, disPartClosed, disClosed, disDeleted |
RO Seat | Seat number |
TCheckItemList | Checkitems list |
TDish | Dish |
RO Quantity | Quantity |
RO SrcQuantity | Initial quantity (before voiding) |
RO Pieces | Amount of servings |
RO Price | Price |
RW IsUserPrice | "The price is set manually" flag |
RW UserPrice | Manual price |
RO PRListSum | Amount excluding discounts |
RO PaySum | Amount including discounts |
RO MinPrice | Minimum price |
RO Modifiers | List of modifiers |
RO Discounts | List of discounts for the dish |
RO Consumators | Consumators list |
RO Voids | Voids list |
RO PayBindings | Bindings list |
RW NeedRecalc | "You need to recalculate the amount of the dish: flag |
TPortion | Serving dish |
Weight | Dish weight |
PortionWeight | Weight of one serving |
WeightPrinted | "Weight has already been changed after service printing" flag |
TRatedDish | Rated dish |
TModiItem | Modifier |
TDiscountItem | Discount |
RO Localization | Discount localization (chlVisit, chlOrder, chlOrderSeat, chlDish) |
RW ChargeSource | Source of the discount: chsHuman (manual), chsPay (for payment), chsAuto (automatic), chsChangeTip(formed by tips), chsInterface (interface), chsMCR (from the card), chsXML. ChsCoupon (discount coupon) |
RW SrcAmount | Discount value in the case of a discount with a variable value |
RO CalcAmount | Calculated discount value |
RW BonusType | Bonus type ID |
RO CardCode | Card code |
RO AccountIdent | Account number |
RO MInterface | Interface ID |
TConsumItem | Consumant |
TVoidItem | Void |
TVisit | Visit |
RO Creator | ID of the employee who created the visit |
RO GuestType | Guest type ID |
RO GuestCnt | Guests quantity |
RO StartGuestCnt | Number of guests without regard to closed sits |
RO VisitExtraInfoToSave | Saved comment |
RO VisitOtherExtraInfo | Unsaved comment |
TOrder | Order |
RO OrderName | Order name |
RO BillExists | "Receipt printed for order" flag |
RO IsQuickCheck | "Order is a quick receipt" flag |
RO Paid | "Order paid (empty)" flag |
RO CalcBySeats | "The order is calculated by places" flag |
RO MainWaiter | Main waiter ID |
RO TableID | Table ID |
RO COT | Order type ID |
RO UOT | Order category ID |
RO Defaulter | Defaulter type ID |
RO PriceListSum | Amount excluding discounts |
RO ToPaySum | Payable amount |
RO PaidSum | Paid amount |
RO DiscountSum | The amount of discounts/markups (without regard to undistributed ones) |
RW UserTag1-UserTag4 | Free properties, for use in scripts |
TPayBinding | Binding |
TTaxItem | Tax item |
TDiscPartItem | Discount tax item |
TChargeLine | Undistributed markup |
TOrderSession | Package |
RO iSessionType | Package creation method: stAuto (automatic), stManual (manual), stTransferIn (transferring from another order), stTransferShift (transferring when closing the shift) |
RO iPriceScale | Price type ID |
RO iTradeGroup | Trade group ID |
RO iStation | ID of the station where the package was created |
RO Creator | Creator ID |
RO Author | ID of the last user who edited the order |
RO Lines | List of package items |
RO PrintFlag | Print flag: pfNo (not needed), pfNow (current time), pfLater (specified time), pfPrinted (already printed) |
RO PrintAt | Printing time |
RO RemindFlag | Reminder flag |
RO RemindAt | Reminder time |
RO ReadyFlag | Serving flag |
RO ReadyAt | Serving time |
RO KDSState | KDS Status |
TOrderSessions | Package list |
TPrintCheckItem | Receipt |
RO CheckNum | Unique receipt number |
RO PrintNumber | Printed receipt number |
RO BasicSum | Receipt amount |
RO PRListSum | Receipt amount without discounts |
RO TaxSum | Tax amount |
RO iPrintStation | ID of the station where the receipt was printed |
RO iPrinter | ID of the printer where the receipt was printed |
RO CloseDateTime | Date and time when the receipt was closed |
RO IsBill | "Bill" flag |
RO BillError | "Bill printing error" flag |
RO PrintError | "Receipt printing error" flag |
TPayLine | Payment |
RO OriginalSum | Payment amount |
RO BasicSum | Payment amount in the base currency |
RO NationalSum | Payment amount in the national currency |
RO DBKurs | Rate |
RO OwnerInfo | Client info |
RO PayLineType | Payment type: pltCash, pltCrCard, pltHotel, pltPayCard, pltCashExclude (fictitious change), pltOtherNonCash |
RO IsPrepay | "Prepayment" flag |
RO CardNum | Card number |
RO AccountIdent | Account number |
RO Defaulter | Defaulter type ID |
RO AuthType | Authorization type |
RO MInterface | Interface ID |
TCheckCurrLine | Payment item |
TMcrPay | |
TMcrCoupon |