1. General


1.1. Main principles and functions are in

1.2. Here we summarize some common ways to implement in RK7 scripts.


2. Coding


2.1. Control order content in doscash.exe

2.1.1. This function will check existing of some discount in current order:

function checkingForDiscount(it: TObject; DiscCode:integer):boolean;
var i:integer;
begin
result := false;
if SYS.ObjectInheritsFrom(TObject(it), 'TDish') then
begin
For i := 0 to TDish(it).Discounts.Count - 1 do
if (TDish(it).Discounts.Items[i].Code=DiscCode) then result := true;
end;
end;

2.1.2. This will check if object is not deleted

if TDiscountItem(it).State <> disDeleted then

2.1.3. This will check is object is active

if TDiscountItem(it).State = disOpened then

6. Examples


6.1. Making FarCards transaction (PDS)

6.1.1. If you want to make a simple transaction through any interface (that supports these transactions – for example, for current moment it is PDS-FarCards), you should fill structure TsimpleTransactionInfo as below and call function DoPDSTransactionfor example:

var TransactionInfo: TsimpleTransactionInfo;
...
TransactionInfo.InterfaceCode := 1;          // PDS interface code
TransactionInfo.Kind := 20;                        // some code
TransactionInfo.Sum := 600;                     // some data
DoPDSTransaction(TransactionInfo);

6.1.2. All transactions are made using card code and AccountIdent for last usedcardthis data is returned in structure as a result of operation processing:

 TSimpleTransactionInfo = record
    InterfaceCode: integer;
    AccountIdent : integer; // is returned
    CardCode: string;       // is returned
    Kind    : byte;
    Sum     : int64;
    RKDate : integer;
    RKUnit : integer;
    RKCheck : integer;
    OpResult: integer;      // is returned
 end;

6.1.3. In GetCardInfoEx and TransactionEx function will be "CHECK" tag with "chmode" =0

6.2. Menu items sorting in main selector

6.2.1. Add the following script to your form main selector "OnCompare" property as in 2.3.1 to make it be sorted by Alt.Name.

function MainSelectorOnCompare(a, b: tObject): integer;
var i1, i2: TVisualNamedClassifierItem;
begin
if SYS.ObjectInheritsFrom(a, 'TVisualNamedClassifierItem')
and SYS.ObjectInheritsFrom(b, 'TVisualNamedClassifierItem')
then begin
i1 := TVisualNamedClassifierItem(a);
i2 := TVisualNamedClassifierItem(b);
if i1.AltName > i2.AltName then
Result := 1
else if i1.AltName < i2.AltName then
Result := -1
else Result := 0;
end;
end;

6.2.2. Select MainSelector "Properties" tab "Behavior" section "Sort type" parameter to "Custom" in that form editor.
 6.2.3. Set "Main selector sort type" to "Unsorted".

6.2.4. If you want to sort by ShortName instead you have to use two functions (below) the same way.

function CompareStr(s1, s2: string): integer;
begin
if s1 > s2 then Result := 1
else if s1 < s2 then Result := -1
else Result := 0;
end;

function MainSelectorOnCompareScript(a, b: tObject): integer;
begin
if SYS.ObjectInheritsFrom(a, 'TRk7MenuItem')
and SYS.ObjectInheritsFrom(b, 'TRk7MenuItem')
then
Result := CompareStr(TRK7MenuItem(a).ShortName, TRK7MenuItem(b).ShortName)
else if SYS.ObjectInheritsFrom(a, 'TVisualNamedClassifierItem')
and SYS.ObjectInheritsFrom(b, 'TVisualNamedClassifierItem')
then
Result := CompareStr(TVisualNamedClassifierItem(a).RightLangName,
TVisualNamedClassifierItem(b).RightLangName)
else Result := 0;
end;

6.3. Clear open price


6.3.1. SETUP MANAGER STATION

6.3.1.1. To use Scripts as operations you are to do the following:
1) service>scripts>all>operations>scripts (create new); Input your script to “somescript”. Follow 2.1.1.
2) service>operations>all>user operations>[free] (rename any); Set script creared. Follow 2.1.2.
3) options>user interface>function keys>all>order operations>operation selector; Create new function key; choose its operation and select selector types where to show it. Follow 2.1.4.
4) options>user interface>selectors>order>operation's selector>receipt operation's selector>standard supply; Copy standard supply and paste with subitems nearby; add the new button to operation’s selector; add new selectors to its usage. Follow 2.1.5.
6.3.1.2. This script enables function button that changes the price of all the open price menu items entered to zero:

procedure ProcessOperation102808(Parameter: integer);
var i: integer;
it: TCheckItem;
begin
// bug#10115
for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do begin
it := RKCheck.CurrentOrder.Sessions.Lines[i];
if SYS.ObjectInheritsFrom(TObject(it), 'TDish') then begin
if trk7menuItem(TDish(it).RefItem).OpenPrice and (it.State = disOpened) then begin
TDish(it).IsUserPrice := true;
TDish(it).UserPrice := 0;
end;
end;
end;
RKCheck.CurrentOrder.Recalc();
end;


6.3.2. OPERATE ON CASH STATION

6.3.2.1. Open the order form and enter any quantity of menu items;
6.3.2.2. Press the button “free” and you can see the changes.
6.3.3.1. Example button changes all entered menu items with open price to zero, so if you want to save ordered items with original price, not press this button after entered them, or not use open price for them.
6.3.3.2. Use RK7 version 7.4.2.56 and later.

6.4. Printing confirmation

6.4.1. This script enables the enquiry that confirms printing of a bill:

procedure CheckOperation107503(Operation, Parameter: integer; var ValidResult, CallNextTime: boolean);
begin
if operation = rkoPrintBill then
ValidResult := GUI.RKMessageDlg('Print Bill?', 0, 3, 10000) = 6;
end;
end;

6.5. Bill print with cancel it

6.5.1. This script will print bill layout (only if one of them in printing scheme) and cancel it in one button.

procedure ProcessOperation1007402(Parameter: integer);
begin
rk7.performOperation(rkoPrintBill,0);
rk7.performOperation(rkoUnlockBill,0);
end;

6.5.2. You have to disable parameter "Finish order editing on bill" to run this script on cash without error.
 

6.5.3. If you want to close order after bill cancell, add the following string to the script: "RK7.PerformOperation(rkoOk,0);".
6.5.4. Follow 2.1.1., 2.1.2., 2.1.4., 2.1.5. to make a button on cash station that will run this script.


6.6. User document with confirmation

6.6.1. To make the system print some user document with confirmation ("yes/no" dialog), use the following script.

procedure CheckViewOnOrderVerify(Sender: TObject; AVerifyType: TVerifyType; oper: integer; var AContinue: boolean);
begin
if AVerifyType = vtPrintReceipt then begin
if GUI.RKMessageDlg('Do you need parking ticket?', 0, 3, 10000) = 6 then
RK7.PerformRefObject(RK7.FindItemByCode(rkrefMaketSchemeDetails,1234));
end;
end;

6.6.2. This script you have to put to OnOrderVerify event of OrderEdition form CheckView element.
6.6.3. Point legacy [Main]->[Code] layout view property (from Printing scheme) of "User document" (check in [Basic]->[Document] property) dataset layout.


6.7. Money back from order edition

6.7.1. This script is to be used in case of fiscal money out (necessary for system balance decrease) from order edition form.

procedure MakeTransaction(CurrID, ReasonID: integer; Amount: double);
var edtAmount: TNumEditor;
    edtCurrency: TCodeEditor;
    edtReason: TCodeEditor;
begin
  edtAmount := TNumEditor(gui.FindComponentByName('edtAmount'));
  edtCurrency := TCodeEditor(gui.FindComponentByName('edtCurrency'));
  edtReason := TCodeEditor(gui.FindComponentByName('edtReason'));
  edtAmount.Text := FloatToStr(Amount);
  edtCurrency.ItemID := CurrID;
  edtReason.ItemID := ReasonID;  
end;
procedure userGButton15centOUTOnButtonPressScript(Sender: TGCustomButton);
begin
MakeTransaction(2, 1001279, 0.15);  
end;

6.7.2. This script should be added to "TGButton" (create new) element "OnButtonPress" event of "Money pay in/collect out" form.

6.7.3. If you want this form to be shown above Order edition, set in its properties higher Resolution than original (inside the form layout).

6.7.4. Regular money out will be available as usually. The exit button will take you back to Order edition.

6.7.5. You have to assign the new form to Scheme and check the usage.

6.7.6. MakeTransaction function has 3 parameters: Currency ID, Reason ID (shown below, must be "cash out reason") and Amount.

6.8. Call external file start from user button

6.8.1. To start external software you have to add the following script to Scripts->All->Operations.

procedure ProcessOperation1001149(Parameter: integer);
begin
GUI.CmdExec('c:\tcpview.exe');
end ; 

6.8.2. Add this script to user operation.

6.8.3. Assign this operation to user button.

6.8.4. Put the button to necessary selector.

  • No labels