Scripts in MCR Algorithms
Script for MCR Algorithm to Obtain a Card Number after Scanning a QR Code with a Camera
It is required to register a QR code in the order using an Ipod and a tablet POS.
QR code format:
QRC=<card info>:<var info>
Example:
QRC=123456789:121212
card info - 123456789
var info - 121212
Card code = card info meaning (year ( whole ) + month (1–12) + day).
That is, if there is a card with the No. 5555, the Card info as of May 13, 2015, is equal to Card
Code(5555)+Year(2015)+Month(5)+Day(13)
5555+2015+5+13=7588
As the result, we shall get the Card code.
function MCR1002183(DeviceSignal: Integer; DeviceIdent: Integer; var Parameter: String): Boolean;
begin
// for input parameter: QRC=123456789:121212
Result := False;
if pos('QRC=',parameter) > 0 then
begin
parameter := copy(parameter,5,pos(':',parameter)-5);
Parameter := IntToStr(StrToInt(Parameter)-(StrToInt(FormatDateTime('yyyy',now))+StrToInt(FormatDateTime('mm',now))+StrToInt(FormatDateTime('dd',now))));
Result := True;
end;
end;
Script for Table Selection
It is required to ensure that, when a customer card is swiped, a table with the number programmed on the card is shown in the order editing window.
function MCR1001882(DeviceSignal: Integer; DeviceIdent: Integer; var Parameter: String): Boolean;
begin
Result := False;
{ 999table_identifier }
if pos('999', Parameter) = 1 then begin
delete(Parameter, 1,3);
if length(Parameter) > 0 then begin
gui.showmessage(Parameter);
RK7.PerformRefObject(RK7.FindItemByCode(rkrefTables, StrToInt(Parameter)))
Result := true;
end;
end;
end;
Script for Converting Hex to bin
function MCR1001196(DeviceSignal: Integer; DeviceIdent: Integer; var Parameter: String): Boolean;
var RestCode: integer;
i, j: Integer;
hex, t1, res1: string;
begin
Result := false;
Parameter := Trim(Parameter);
if length(Parameter) > 0 then begin
Res1 := '';
for i:=1 to length(Parameter) do
begin
hex := Copy(Parameter, i, 1);
t1 := '';
case hex of
'0': t1 := '0000';
'1': t1 := '0001';
'2': t1 := '0010';
'3': t1 := '0011';
'4': t1 := '0100';
'5': t1 := '0101';
'6': t1 := '0110';
'7': t1 := '0111';
'8': t1 := '1000';
'9': t1 := '1001';
'A': t1 := '1010';
'B': t1 := '1011';
'C': t1 := '1100';
'D': t1 := '1101';
'E': t1 := '1110';
'F': t1 := '1111';
end;
Res1 := Res1 + t1;
end;
Result := true;
Parameter:= Res1;
end;
end;
Script for Converting HEX to DEC
function MCR1001665(DeviceSignal: Integer; DeviceIdent: Integer; var Parameter: String): Boolean;
var RestCode: integer;
i, j, t1, S: Integer;
res1, t2: int64;
hex,resulttext: string;
begin
Result := false;
{ 778=HEX?????? }
Parameter:= Trim(Parameter);
if Pos('ISD=',Parameter) > 0 then begin
if length(Parameter) >= 8 then
Parameter := Copy(Parameter, 5, 8);
Parameter:= Int64ToStr(StrToInt64('0x'+Parameter)and StrToInt64('0x7FFFFFFF'));
Result := true;
end;
end;
Script for Converting Dec to Oct
Software:
- r_keeper 7.5.3.279
- SkiBars2
Problem:
- PRX KE (PS/2) readers were used for processing SkiBars cards at existing r_keeper 7 stations
- new stations have arrived that are equipped with other readers, SRCh125 (RS232)
- the clue problem is that the same card is processed differently by these readers
Run a check at the station using MCR Algorithm Debugging
PRX KE (PS/2): 0,41153061004700
SRCh125 (RS232): 0,3684940
The script converts entries of the 0,3684940 type to 0,41153061000000
function MCR1001908(DeviceSignal: Integer; DeviceIdent: Integer; var Parameter: String): Boolean;
var
i,len, ost1,ost2:integer;
s,res: string;
begin
Result := False;
if pos(',',Parameter)=2 then
begin
s:=copy(Parameter,3,9);
res:='';
ost1 := StrToInt(s);
While ost1<>0 do
begin
ost2 := ost1 mod 8;
ost1 := ost1 div 8;
res := IntToStr(ost2) + res;
end;
s:='';
len := length(res);
for i:=1 to len do
begin
s:=res[i]+s;
end;
for i:=1 to 14-len do
begin
s := s + '0';
end;
Parameter := '0,'+s;
Result := True;
end;
end;
Script for Adding a 0 Rub Dish When Swiping a MasterCard Card
function MCR1001296(DeviceSignal: Integer; DeviceIdent: Integer; var Parameter: String): Boolean;
begin
Result := False;
if (pos('=',Parameter)>=12) and (copy(Parameter,1,2)>='51') and (copy(Parameter,1,2)<='55') then
if RKCheck.CurrentOrder.ToPaySum >= 300 then // checking order amount
begin // Parameter := '22'; Result := True;
if GUI.RKMessageDlg('A Mastercard special offer is available for you. Do you want to add the dish?', 3, 3, 0) = 6 then
begin
RKCheck.CreateCheckItem(rkrefMenuItems, IntToStr(43), '1'); // adding the dish with the 43 code to the order
Parameter := '8081';
Result := True;
end
else
Result := False;
end;
end;
Script for Using the Corporation Code+Restaurant Code+Card Code When Creating an Employee Card
function MCR1002181(DeviceSignal: Integer; DeviceIdent: Integer; var Parameter: String): Boolean;
var s:string;
begin
if length(Parameter)=4 then // checking the number of characters in a parameter
if TRK7Restaurant(RK7.CashGroup.MainParent).Code = 79 then // checking restaurant code
begin
s := IntToStr(TRK7Restaurant(RK7.CashGroup.MainParent).Code);
s := copy('000'+s,length('000'+s)-4,4); // displaying restaurant code as four characters
Parameter := '99999'+s+Parameter;
Result := true;
end;
end;
Script for Controlling the Addition of the Second CRM Card
Adding discounts to a bill, as well as bonus crediting and write-off must be performed only using the card that was added first.
function MCR1006889(DeviceSignal: Integer; DeviceIdent: Integer; var Parameter: String): Boolean;
var RestCode,i,DiscCode,DiscCnt: integer;
it: TCheckItem;
begin
//************************** Set parameters **********************************//
DiscCode := 11;
//************************** Set parameters **********************************//
Result := false;
if not RKCheck.Valid then Exit;
if (GUI.CheckFormInPayMode) then exit;
DiscCnt := 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 //Check dish lines only
if (TDiscountItem(it).Code = DiscCode) then
if TDiscountItem(it).CalcAmount <> 0 then
DiscCnt := DiscCnt + 1;
end;
if DiscCnt > 0 then
begin
gui.showmessage('The order already has a card.');
Result := False;
end
else
{ 778=RestaurantCode=CardCode }
if pos('778=', Parameter) = 1 then begin
delete(Parameter, 1, 4);
if pos('=', Parameter) > 1 then begin
RestCode := StrToIntDef(copy(Parameter, 1, pos('=', Parameter) - 1),-1);
delete(Parameter, 1, pos('=', Parameter));
if RestCode mod 10000 = 0 then
{without restaurant code, for the company}
Result := RestCode div 10000 = IntParam('EnterpriseCode')
else
Result := RestCode = IntParam('RestaurantCode');
end;
end;
end;