A script to prohibit adding dishes if the order amount is less than the specified one

The script prohibits adding a gift dish if the order amount is less than the specified one (300 rubles):

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

var DishCode1: integer;

begin

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

DishCode1 := 46; // non-addable dish code

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

if RKCheck.CurrentOrder.ToPaySum < 300 then // the check amount below which the dish selector is hidden   

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

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

begin

AAllow := false;

AMessage := 'Запрещено добавлять блюдо '+TDish(AObjectAft).Name+' !'; 

end; 

end;

A script to prohibit the payment in the currency with the code «1», if there is a discount or a markup with the code «5» in the receipt

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

var i, discpresent: integer;

it: TCheckItem;

begin

discpresent := 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 = 5) then

discpresent := discpresent + 1;

end;

if discpresent > 0 then

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

if (TPayLine(AObjectAft).code=1) then

begin 

AAllow := false;

AMessage := 'Payment in this currency is prohibited!';

end;

end;

A script to prohibit the payment of the order to everyone except the main waiter of the order

On the check 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);

begin

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

if tClassifierItem(RK7.FindItemBySifr(rkrefEmployees,rk7.CashUser.Ident)).MainParent.Code <> 2 then // check for manager

if RKCheck.CurrentOrder.MainWaiter <> RK7.CashUser.ident then // check mainwaiter with current waiter

begin 

AAllow := false;

AMessage := 'You aren't mainwaiter for this order!';

end;

end;

A script for editing an order if a PDS discount is available

Cashiers should be prohibited to add new dishes after entering the customer's card details. But they should be able to edit the order (apply bonuses, delete or replace the customer's card in the order, etc.)

On the check 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, discCode, currCode:integer;

discPresent:boolean;

it: TCheckItem;

begin

discPresent := false;

discCode := 14; //код скидки ПДС

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

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

begin

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

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

if (it.code = discCode) and (TDiscountItem(it).State <> disDeleted) then discPresent := true;

end;


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

begin 

AAllow := false;

AMessage := 'Adding dishes is prohibited because the card is used.';

end;

end;

A script to prohibit the payment in a specified currency if there are discounts in the receipt

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

var i, discCode, currCode:integer;

discPresent:boolean;

it: TCheckItem;

begin

discPresent := false;

discCode := 3; //discount code

currCode := 1; //prohibited currency code

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

begin

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

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

if it.code = discCode then discPresent := true;

end;


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

if ((TPayLine(AObjectAft).code=currCode) and discPresent) then // specify prohibited currency code

begin 

AAllow := false;

AMessage := 'Payment is prohibited if there is a discount';

end;

end;

A script to prohibit making a prepayment if there is no discount in the order

On the check 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, discountpresent, DiscountCode: integer;

it: TCheckItem;

begin

DiscountCode := 10; // manageable discount code

discountpresent := 0;

// checking discount presence in the order

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 TDiscountItem(it).Code=DiscountCode then

if TDiscountItem(it).CalcAmount < 0 then

discountpresent := discountpresent + 1;

end; 

// payment control

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

if discountpresent > 0 then

AAllow:= True

else

begin 

AAllow := false;

AMessage := 'Apply the discount!';

end; 

end;

A script to restrict the payment in a certain currency in the receipt

There are coupons with certain denominations (2000 rubles). If the order amount is < 2000 rubles, the guest can pay the order in full in this currency. If the amount is > 2000 rubles, 2000 rubles can be paid in this currency, and the rest — either in cash or by non-cash payment.

Add a script to the OnBeforeCheckViewEdit event of 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, codecurr: integer;

currsum, limitcurrsum: double;

it: TCheckItem;

begin

currsum := 0;

limitcurrsum := 2000; // currency payment limit  

codecurr := 5; // currency code

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

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

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

if (it.Code = codecurr) then

currsum := currsum + TPayLine(it).NationalSum;

end;


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

if (TPayLine(AObjectAft).code = codecurr) then

if (currsum + TPayLine(AObjectAft).NationalSum) > limitcurrsum then

begin 

AAllow := false;

AMessage := 'Payment in this currency is limited to '+FloatToStr(limitcurrsum)+' !';

end;

end;

A script to change the activity of the national currency button

When paying, the script checks the currency of the payment. If it coincides there with the first currency code, payment in the second currency will be prohibited.

Replace the currency codes with the current ones in the script lines with comments.

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

var i, currpresent: integer;

it: TCheckItem;

begin

currpresent := 0;

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

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

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

if (it.Code = 1) then // code of first currency (Lit)

if TPayLine(it).CurrLineSum > 0 then

currpresent := currpresent + 1;

end;

if currpresent > 0 then

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

if (TPayLine(AObjectAft).code=2) then // code of second currency (Euro) 

if TPayLine(AObjectAft).CurrLineSum >=0 then 

begin 

AAllow := false;

AMessage := 'Payment in this currency is prohibited!';

end;

end;

A script to prohibit a combined payment in fiscal and non-fiscal currencies

The script prohibits combining the specified currency type with other currency types. Insert it in the OnBeforeCheckViewEdit event, on the receipt editing form for the CheckView object:

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

var i, CurrType1Code, CntCurrType1, CntCurrTypeOther: integer;

it: TCheckItem;

begin

CurrType1Code := 91; // code of the currency type for which to prohibit combining with other currencies  

if not SYS.ObjectInheritsFrom(AObjectAft, 'TPayLine') then Exit;

CntCurrType1 := 0;

CntCurrTypeOther := 0;


if TCurrencyType(TCurrency(TPayLine(AObjectAft).RefItem).MainParent).Code=CurrType1Code then

CntCurrType1 := CntCurrType1 + 1

else

CntCurrTypeOther := CntCurrTypeOther + 1;


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

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

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

if TCurrencyType(TCurrency(TPayLine(it).RefItem).MainParent).Code=CurrType1Code then

CntCurrType1 := CntCurrType1 + 1

else

CntCurrTypeOther := CntCurrTypeOther + 1; 

end;

end;


if (CntCurrType1 > 0) and (CntCurrTypeOther > 0) then

begin

AAllow := False;

AMessage := 'This currency combination is prohibited!';

Exit;

end; 

end;

A script for combining fiscal and non-fiscal currencies with PDS payments

Non-cash payments should be combined only with payment cards, but it should be allowed to combine PDS payments with other groups.

The script prohibits combining the CurrType1Code and CurrType2Code currency types with other currencies but allows to combine them with each other.

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

var i, CurrType1Code, CurrType2Code, CntCurrType1, CntCurrType2, CntCurrTypeOther: integer;

it: TCheckItem;

begin

CurrType1Code := 91; // code of the currency type for which to prohibit combining with other currencies    

CurrType2Code := 99; // code of the currency type for which to prohibit combining with other currencies    

if not SYS.ObjectInheritsFrom(AObjectAft, 'TPayLine') then Exit;

CntCurrType1 := 0;

CntCurrType2 := 0;

CntCurrTypeOther := 0;


if TCurrencyType(TCurrency(TPayLine(AObjectAft).RefItem).MainParent).Code=CurrType1Code then

CntCurrType1 := CntCurrType1 + 1

else

if TCurrencyType(TCurrency(TPayLine(AObjectAft).RefItem).MainParent).Code=CurrType2Code then

CntCurrType2 := CntCurrType2 + 1

else

CntCurrTypeOther := CntCurrTypeOther + 1;


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

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

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

if TCurrencyType(TCurrency(TPayLine(it).RefItem).MainParent).Code=CurrType1Code then

CntCurrType1 := CntCurrType1 + 1

else

if TCurrencyType(TCurrency(TPayLine(it).RefItem).MainParent).Code=CurrType2Code then

CntCurrType2 := CntCurrType2 + 1

else

CntCurrTypeOther := CntCurrTypeOther + 1; 

end;

end;


if ((CntCurrType1 > 0)or(CntCurrType2 > 0)) and (CntCurrTypeOther > 0) then

begin

AAllow := False;

AMessage := 'This currency combination is prohibited!';

Exit;

end; 

end;

Currency type 1 is allowed to combine with currency type 2, but is prohibited to combine with other currencies.

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

var i, CurrType1Code, CurrType2Code, CntCurrType1, CntCurrType2, CntCurrTypeOther: integer;

it: TCheckItem;

begin

CurrType1Code := 91; //  code of the currency type for which to prohibit combining with other currencies except for currency type 2     

CurrType2Code := 99; // currency type code

if not SYS.ObjectInheritsFrom(AObjectAft, 'TPayLine') then Exit;

CntCurrType1 := 0;

CntCurrType2 := 0;

CntCurrTypeOther := 0;


if TCurrencyType(TCurrency(TPayLine(AObjectAft).RefItem).MainParent).Code=CurrType1Code then

CntCurrType1 := CntCurrType1 + 1

else

if TCurrencyType(TCurrency(TPayLine(AObjectAft).RefItem).MainParent).Code=CurrType2Code then

CntCurrType2 := CntCurrType2 + 1

else

CntCurrTypeOther := CntCurrTypeOther + 1;


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

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

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

if TCurrencyType(TCurrency(TPayLine(it).RefItem).MainParent).Code=CurrType1Code then

CntCurrType1 := CntCurrType1 + 1

else

if TCurrencyType(TCurrency(TPayLine(it).RefItem).MainParent).Code=CurrType2Code then

CntCurrType2 := CntCurrType2 + 1

else

CntCurrTypeOther := CntCurrTypeOther + 1; 

end;

end;


if (CntCurrType1 > 0) and (CntCurrTypeOther > 0) then

begin

AAllow := False;

AMessage := 'This currency combination is prohibited!';

Exit;

end; 

end;

A script to combine fiscal and non-fiscal currencies

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

var i, CurrType1Code1,CurrType1Code2,CurrType1Code3,CurrType1Code4, CurrType2Code1,CurrType2Code2,CurrType2Code3,CurrType2Code4, CntCurrType1, CntCurrType2, CntCurrTypeOther: integer;

it: TCheckItem;

begin

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

CurrType1Code1 := 91; // fiscal currency type code  

CurrType1Code2 := 93; // fiscal currency type code  

CurrType1Code3 := 1; // fiscal currency type code  

CurrType1Code4 := 2; // fiscal currency type code   

CurrType2Code1 := 14; // non-fiscal currency type code  

CurrType2Code2 := 94; // non-fiscal currency type code  

CurrType2Code3 := 13; // non-fiscal currency type code  

CurrType2Code4 := 24; // non-fiscal currency type code    

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


if not SYS.ObjectInheritsFrom(AObjectAft, 'TPayLine') then Exit;

CntCurrType1 := 0;

CntCurrType2 := 0;

CntCurrTypeOther := 0;


if (TCurrencyType(TCurrency(TPayLine(AObjectAft).RefItem).MainParent).Code=CurrType1Code1)

or(TCurrencyType(TCurrency(TPayLine(AObjectAft).RefItem).MainParent).Code=CurrType1Code2)

or(TCurrencyType(TCurrency(TPayLine(AObjectAft).RefItem).MainParent).Code=CurrType1Code3)

or(TCurrencyType(TCurrency(TPayLine(AObjectAft).RefItem).MainParent).Code=CurrType1Code4)

then

CntCurrType1 := CntCurrType1 + 1

else

if (TCurrencyType(TCurrency(TPayLine(AObjectAft).RefItem).MainParent).Code=CurrType2Code1)

or(TCurrencyType(TCurrency(TPayLine(AObjectAft).RefItem).MainParent).Code=CurrType2Code2)

or(TCurrencyType(TCurrency(TPayLine(AObjectAft).RefItem).MainParent).Code=CurrType2Code3)

or(TCurrencyType(TCurrency(TPayLine(AObjectAft).RefItem).MainParent).Code=CurrType2Code4)

then

CntCurrType2 := CntCurrType2 + 1

else

CntCurrTypeOther := CntCurrTypeOther + 1;


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

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

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

if TPayLine(it).state <> disDeleted then begin // payment status

if (TCurrencyType(TCurrency(TPayLine(it).RefItem).MainParent).Code=CurrType1Code1)

or(TCurrencyType(TCurrency(TPayLine(it).RefItem).MainParent).Code=CurrType1Code2)

or(TCurrencyType(TCurrency(TPayLine(it).RefItem).MainParent).Code=CurrType1Code3)

or(TCurrencyType(TCurrency(TPayLine(it).RefItem).MainParent).Code=CurrType1Code4)

then

CntCurrType1 := CntCurrType1 + 1

else

if (TCurrencyType(TCurrency(TPayLine(it).RefItem).MainParent).Code=CurrType2Code1)

or(TCurrencyType(TCurrency(TPayLine(it).RefItem).MainParent).Code=CurrType2Code2)

or(TCurrencyType(TCurrency(TPayLine(it).RefItem).MainParent).Code=CurrType2Code3)

or(TCurrencyType(TCurrency(TPayLine(it).RefItem).MainParent).Code=CurrType2Code4)

then

CntCurrType2 := CntCurrType2 + 1

else

CntCurrTypeOther := CntCurrTypeOther + 1; 

end;

end;


if (CntCurrType1 > 0) and (CntCurrType2 > 0) then

begin

AAllow := False;

AMessage := 'This currency combination is prohibited!';

Exit;

end; 

end;

A script to restrict payments in different currencies

The script prohibits mixed payment - you can not pay the bill in both rubles and a credit card

or make two payments: rubles+rubles or credit card+credit card

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

var i, CurrCode1, CurrCode2, curr1present, curr2present: integer; 

it: TCheckItem;

Categ: TClassificatorGroup;

CategCode: integer;

begin

CategCode := 17; // category code

CurrCode1 := 1; // currency code 1 (rubles+rubles)

CurrCode2 := 5: // currency code 2 (credit card+credit card)

curr1present := 0;

curr2present := 0;

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

if not(AEditType = etRemove) then

if RKCheck.CurrentOrder.UserTag1 = 0 then

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

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

if GUI.RKMessageDlg('HAVE YOU CHECKED THE DOCUMENTS ?! '+#13#10+' We do not sell beer to Guests born later than ' +FormatDateTime('dd mmmm ',Date-1)+IntToStr(StrToInt(FormatDateTime('yyyy',Date))- 18)+#13#10+' '+#13#10+'FINE FOR ADMINISTRATIVE OFFENSE IS 30 000 rub. FROM THE CASHIER!', 0, 3, 100000) = 6 then

begin

RKCheck.CurrentOrder.UserTag1 := 1; // label to avoid dialog reopening

AAllow := True

end 

else

begin

RK7.PostOperation(rkoDishSelector, 0);

AAllow := False;

end;

if not SYS.ObjectInheritsFrom(AObjectAft, 'TPayLine') then Exit;


// Check that there are no payments in other currencies in the order  

// (change can only be given in the same currency)

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

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

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

if (it.Code = CurrCode1 ) then // code of first currency (Lit)

if TPayLine(it).CurrLineSum > 0 then

curr1present := curr1present + 1;

if (it.Code = CurrCode2 ) then // code of first currency (Lit)

if TPayLine(it).CurrLineSum > 0 then

curr2present := curr2present + 1;


if TPayLine(it).Sifr <> TPayLine(AObjectAft).Sifr then begin

AAllow := False;

AMessage := 'The change must be given in the same currency as the main payment';

Exit;

end; 

end;

end;


// Prohibit making a payment less than the order amount  

if (TPayLine(AObjectAft).BasicSum > 0)

and (TPayLine(AObjectAft).BasicSum < RKCheck.CurrentOrder.UnpaidSum)

then begin

AAllow := False;

AMessage := 'You can't pay less than the order amount';

end;


// Entering more than one payment is prohibited  

if curr1present > 0 then

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

if (TPayLine(AObjectAft).code=CurrCode1) then // code of 1st currency

if TPayLine(AObjectAft).CurrLineSum >=0 then 

begin 

AAllow := false;

AMessage := 'Payment prohibited because there was already a payment in this currency!';

end;

if curr2present > 0 then

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

if (TPayLine(AObjectAft).code=CurrCode2) then // code of 2nd currency

if TPayLine(AObjectAft).CurrLineSum >=0 then 

begin 

AAllow := false;

AMessage := 'Payment prohibited because there was already a payment in this currency!';

end;

end;

A modified script for two types of credit cards:

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

var i, CurrCode1, CurrCode2, CurrCode2_2, curr1present, curr2present: integer; 

it: TCheckItem;

Categ: TClassificatorGroup;

CategCode: integer;

begin  

CategCode := 17; // category code
 
CurrCode1 := 1; // currency code 1 (rubles+rubles)
 
CurrCode2 := 5: // currency code 2 (credit card+credit card)
 
CurrCode2_2 := 6; // currency code 2 (credit card+credit card)
  
curr1present := 0;

curr2present := 0;

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

if not(AEditType = etRemove) then

if RKCheck.CurrentOrder.UserTag1 = 0 then

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

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

if GUI.RKMessageDlg('HAVE YOU CHECKED THE DOCUMENTS ?! '+#13#10+' We do not sell beer to Guests born later than ' +FormatDateTime('dd mmmm ',Date-1)+IntToStr(StrToInt(FormatDateTime('yyyy',Date))- 18)+#13#10+' '+#13#10+'FINE FOR ADMINISTRATIVE OFFENSE IS 30 000 rub. FROM THE CASHIER!', 0, 3, 100000) = 6 then

begin

RKCheck.CurrentOrder.UserTag1 := 1; // label to avoid dialog reopening  

AAllow := True

end 

else

begin

RK7.PostOperation(rkoDishSelector, 0);

AAllow := False;

end;

if not SYS.ObjectInheritsFrom(AObjectAft, 'TPayLine') then Exit;

// Check that there are no payments in other currencies in the order  

// (change can only be given in the same currency)

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

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

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

if (it.Code = CurrCode1 ) then // code of first currency (Lit)

if TPayLine(it).CurrLineSum > 0 then

curr1present := curr1present + 1;

if (it.Code = CurrCode2 ) or (it.Code = CurrCode2_2) then // code of first currency (Lit)

if TPayLine(it).CurrLineSum > 0 then

curr2present := curr2present + 1;


if TPayLine(it).Sifr <> TPayLine(AObjectAft).Sifr then begin

AAllow := False;

AMessage := 'The change must be given in the same currency as the main payment';

Exit;

end; 

end;

end;


// prohibit making a payment less than the order amount  

if (TPayLine(AObjectAft).BasicSum > 0)

and (TPayLine(AObjectAft).BasicSum < RKCheck.CurrentOrder.UnpaidSum)

then begin

AAllow := False;

AMessage := 'You can't pay less than the order amount';

end;


// Entering more than one payment is prohibited  

if curr1present > 0 then

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

if (TPayLine(AObjectAft).code=CurrCode1) then // code of 1st currency

if TPayLine(AObjectAft).CurrLineSum >=0 then 

begin 

AAllow := false;

AMessage := 'Payment prohibited because there was already a payment in this currency!;

end;

if curr2present > 0 then

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

if (TPayLine(AObjectAft).code=CurrCode2) or (TPayLine(AObjectAft).code=CurrCode2_2) then // code of 2nd currency

if TPayLine(AObjectAft).CurrLineSum >=0 then 

begin 

AAllow := false;

AMessage := 'Payment prohibited because there was already a payment in this currency!';

end;

end;

A script to limit the payment amount in the currency

Cashiers should not be able to enter 100% payment with loyalty points.

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

var i, CurrencyCode: integer;

currsum: double;

it: TCheckItem;

begin

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

CurrencyCode := 1; // currency (bonuses) code  

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

currsum := 0;

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

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

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

if (it.Code = CurrencyCode) then

currsum := currsum + TPayLine(it).NationalSum;

end;


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

if (TPayLine(AObjectAft).code = CurrencyCode) then

if ((currsum+TPayLine(AObjectAft).NationalSum) > (RKCheck.CurrentOrder.ToPaySum-1)) then

begin

AAllow := false;

AMessage := 'Payment by bonuses is exceeded!';

end;

end;

A script for limiting the payment amount  by the classification

The script calculates the amount of dishes from the specified category and does not allow to enter the amount of currency that exceeds this amount. The limit on exceeding the maximum amount is also checked by setting the MaxCurrSum variable.

Insert the script on the order editing form in the OnBeforeCheckViewEdit event of the CheckView object:

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

var i, CurrencyCode, CategCode: integer;

currsum, MaxCurrSum, CategSum: double;

it: TCheckItem;

Categ: TClassificatorGroup;

begin

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

CurrencyCode := 1; // currency (bonuses) code
 
CategCode := 25; // food category code to limit the payment amount in currency
 
MaxCurrSum := 500; // maximum payment amount in the specified currency
  

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

currsum := 0;

CategSum := 0;

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

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

if (TPayLine(AObjectAft).code = CurrencyCode) then

begin

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

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

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

if (it.Code = CurrencyCode) then

currsum := currsum + TPayLine(it).NationalSum;

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

if Categ.IsChild(it.RefItem) then

if (TDish(it).Quantity > 0) then

CategSum := CategSum + TDish(it).PRListSum

end;


if ((currsum+TPayLine(AObjectAft).NationalSum) > CategSum) then

begin

AAllow := false;

AMessage := 'Currency payment exceeded !';

end;


if ((currsum+TPayLine(AObjectAft).NationalSum) > MaxCurrSum) then

begin

AAllow := false;

AMessage := 'Maximum amount of currency payment exceeded !';

end;

end;

end;

A script to limit vouchers to 50%

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

var i, codecurr: integer;

currsum, limitcurrsum: double;

it: TCheckItem;

begin

currsum := 0;

limitcurrsum := round(RKCheck.CurrentOrder.ToPaySum*0.5); // limit sum

codecurr := 16; // Currency code

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

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

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

if (it.Code = codecurr) then

begin

dbg.dbgprint('TPayLine(it).NationalSum='+floattostr(TPayLine(it).NationalSum));

currsum := currsum + TPayLine(it).NationalSum;

end;

end;


dbg.dbgprint('currsum='+floattostr(currsum));

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

begin

//dbg.dbgprint('TPayLine(AObjectAft).code='+inttostr(TPayLine(AObjectAft).code)); 

if (TPayLine(AObjectAft).code = codecurr) then

begin

dbg.dbgprint('TPayLine(AObjectAft).BasicSum='+floattostr(TPayLine(AObjectAft).BasicSum));

dbg.dbgprint('TPayLine(AObjectAft).OriginalSum='+floattostr(TPayLine(AObjectAft).OriginalSum)); 

dbg.dbgprint('TPayLine(AObjectAft).DBKurs='+floattostr(TPayLine(AObjectAft).DBKurs));

if (currsum + TPayLine(AObjectAft).BasicSum) > limitcurrsum then

begin 

dbg.dbgprint('(currsum + TPayLine(AObjectAft).BasicSum) > '+floattostr(limitcurrsum)); 

AAllow := false;

AMessage := 'Payment is limited by this currency '+FloatToStr(limitcurrsum)+' !';

end;

end;

end;

end;

A script to limit the purchase of dishes (no more than twice a day)

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

var i,dd: integer;

tmp1 : string;

begin

dd := 0;

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

if TDiscountItem(AObjectAft).CardCode <> '' then begin

tmp1 := TDiscountItem(AObjectAft).CardCode;

if pos('778=', tmp1) = 1 then begin

delete(tmp1, 1, 4);

tmp1 :=copy(tmp1, pos('=', tmp1) + 1, 7);


i := RKCheck.GetDiscountCount(TDiscountItem(AObjectAft).Sifr, TDiscountItem(AObjectAft).MInterface, TDiscountItem(AObjectAft).CardCode);


dd := StrToIntDef(tmp1,0);

if (dd>=100) and (dd<=500) then

if i > 0 then begin

AAllow := False;

AMessage := 'PDS can be used only once a day!';

end;

if (dd>=5001) and (dd<=6000) then

if i > 1 then begin

AAllow := False;

AMessage := 'PDS can be used only twice a day!';

end;

end;

end;

end;

end;

A script to add a free dish

A special offer: order 2 desserts (1st category of dishes) and get a free drink (2nd category of dishes). You need a script to add a 100% discount to a dish of the 2nd category if 2 dishes of the 1st category are added to the order.

Insert the script specified below on the order form for the CheckView component in the OnAfterCheckViewEdit event. Specify the corresponding category codes in this script. Для блюд из бесплатной категории выставить свойства: For dishes from the free category, set the following properties:

    • Prices — an open price: V
    • Servings — Add to order: "Separate line for each serving"

The script resets the price of the added dish from the «bonus» category to zero if the required number of dishes from the main category is ordered. 

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

var i, j, k: integer;

it: TCheckItem;

a: double;

CntCateg1, CntCateg2: integer; 

Categ1, Categ2: TClassificatorGroup;

begin

CntCateg1 := 0;

CntCateg2 := 0;

k := 0;

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

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


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

if Categ1.IsChild(TDish(AObjectBef).RefItem) then //Check category of the dish

begin


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

begin

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

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

begin

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

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

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

if TDish(it).Price = 0 then

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

end;

end;

if Categ1.IsChild(TDish(AObjectBef).RefItem) then //Check category of the dish

CntCateg1 := CntCateg1 - 1;


if Categ2.IsChild(TDish(AObjectBef).RefItem) then //Check category of the dish

CntCateg2 := CntCateg2 - 1;


k := (CntCateg1 div 2) - CntCateg2;

if k>0 then

begin 

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

if Categ2.IsChild(TDish(AObjectAft).RefItem) then //Check category of the dish

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

begin

TDish(AObjectAft).IsUserPrice := true;

TDish(AObjectAft).UserPrice := 0;

end;

end; 


if k<0 then

while k<0 do

begin 

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

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

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

if TDish(it).Price = 0 then

begin

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

RKCheck.DeleteCheckItem(it);

end;

end;

end;

end;

end;

A script to confirm payment by a defaulter

«Whole amount+confirmation» is set in the currency «Autofill» property. When paying for the order in this currency, the following message appears: «Do you want to pay the bill using "Staff meals?»

The scripts, given below, provide the user's confirmation of payment in currency with the code «1». They are triggered by entering the amount of this currency in the check. 

First, you need to create an empty script for a custom operation:

procedure ProcessOperation1001446(Parameter: integer);

begin


end; 

Assign this script to a custom operation.  Give the access rights for this user operation only to the manager. 

On the order editing form for 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);

begin

begin

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

if (TPayLine(AObjectAft).code=1) then

if RK7.CashUser.ConfirmOperation(rkoUser07) then

AAllow := True

else

begin 

AAllow := false;

AMessage := 'Payment in this currency is prohibited!';

end;

end;

end;

A script to remove discounts when paying by a defaulter

A script for the OnBeforeCheckViewEdit event of the CheckView component on the order editing form:

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

var i: integer;

it: TCheckItem;

begin

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

if TCurrencyType(TCurrency(TPayLine(AObjectAft).RefItem).MainParent).Code=91 then // 91 - code of currency type for which to prohibit discounts in the check
begin

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

begin

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

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

RKCheck.DeleteCheckItem(it);

end; 

end;

end;

the MainParent property is implemented in 7.5.2.253.

There is no such property in the 7.4.21 branch.

A script to prohibit more than 15 dishes in the order

On the edit form for 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: integer;

qnt: double;

it: TCheckItem;

begin

qnt := 0;

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

if not(AEditType = etRemove) then

begin

qnt := TDish(AObjectAft).Quantity-TDish(AObjectBef).Quantity; 

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

begin

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

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

qnt := qnt + TDish(it).Quantity;

end; 

end;

if qnt > 15 then // check limit exceed

begin 

AAllow := false;

AMessage := 'Quantity exceeded the permitted limit ';

end;

end;

A script to add only dishes from a certain category to the check

The scenario:

  1. Create an order.
  2. Add the first dish. It is placed in the category with code, f.ex., 257.
  3. Add the second dish.
    1. The script verifies the category code of the added dish and compares it with the category code of the first added dish.
    2. If they are equal, then add the dish to the order.
    3. If different, it outputs the message «This dish has different department code. \n Please create different (next) order with this dish» and the dish is not added to the order.
  4. Check every next dish the same way.

The objective: to ensure that only dishes from the same category of the classification are included in the check.

The classification code can also be specified in the script for verification.


The script checks the menu category of the first dish in the order and does not allow to add dishes from other menu groups.

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

var i,CntDish1,numcateg:integer;

it: TCheckItem;

Categ: TClassificatorGroup;

firstdish: boolean;

begin

if AEditType = etInsert then

begin

CntDish1 := 0;

firstdish := false;

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

begin

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

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

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

if TDish(it).Quantity > 0 then

begin

if not(firstdish) then

begin

numcateg := TDish(it).RefItem.MainParent.code;

firstdish := true;

end;

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

break;

end;

end;

if CntDish1<>0 then

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

begin

if (TDish(AObjectAft).RefItem.MainParent.code <> numcateg) then //Check category of the dish 

begin

AMessage := 'This dish has different department code.'+#10#13+'Please create different (next) order with this dish';

AAllow := false;

end;

end;

end;

end;

The script controls adding the dishes from the specified classification according to the category of the first dish in the order:

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

var i,j,CntDish1,ClassifCode1:integer;

it: TCheckItem;

Categ1Firts,Categ1,Classif1: TClassificatorGroup;

firstdish: boolean;

begin

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

ClassifCode1 := 16; // code classificator

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


if AEditType = etInsert then

begin

CntDish1 := 0;

firstdish := false;

Classif1 := TClassificatorGroup(getitemBycodeNum('ClassificatorGroups', ClassifCode1));

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

begin

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

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

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

if TDish(it).Quantity > 0 then

begin

if not(firstdish) then

begin

for j := 0 to Classif1.ChildCount - 1 do begin

Categ1 := TClassificatorGroup(Classif1.ChildItem(j));

if Categ1.IsChild(it.RefItem) then begin

Categ1Firts := Categ1;

break; 

end;

end;

firstdish := true;

end;

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

break;

end;

end;

if CntDish1<>0 then

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

begin

if not(Categ1Firts.IsChild(TDish(AObjectAft).RefItem)) then //Check category of Classification

begin

AMessage := 'This dish has different department code.'+#10#13+'Please create different (next) order with this dish';

AAllow := false;

end;

end;

end;

end;

A script to control alcohol sale

The operation mode of the cash register is a quick check. When adding a dish from a certain category to the order (for KFC, the Crunch/18Alkdish category is alcoholic beverages), the following dialog box is displayed to the cashier:

_____________________________

HAVE YOU CHECKED THE DOCUMENTS?! (large)

YES button NO button

we do not sell alcohol to guests born

later than October 15, 1996*

____________________________


*the system calculates the legal age tip for the cashier

(so that they do not have to count) automatically - 18 years + 1 day

  1. If the cashier chooses YES, then the dish is added to the order.
  2. Another dish from this category added to the same order does not re-open this dialog box. The dish selector remains in the same folder.
  3. If the cashier selects NO, then the dish is not added to the order and the cash register returns to the root folder of the menu.

On the quick check editing form, insert the 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 Categ: TClassificatorGroup;

CategCode: integer;

begin

CategCode := 8; // category code

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

if not(AEditType = etRemove) then

if RKCheck.CurrentOrder.UserTag1 = 0 then

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

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

if GUI.RKMessageDlg('HAVE YPU CHECKED THE DOCUMENTS?! '+#13#10+' We do not sale alcohol to the Guests born later than '+FormatDateTime('dd mmmm ',Date-1)+IntToStr(StrToInt(FormatDateTime('yyyy',Date)) - 18), 0, 3, 100000) = 6 then

begin

RKCheck.CurrentOrder.UserTag1 := 1; // label to avoid dialog re-opening  

AAllow := True

end 

else

begin

RK7.PostOperation(rkoDishSelector, 0);

AAllow := False;

end;

end;

A script for the CheckView object in the OnOrderVerify event:

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

begin

if AVerifyType = vtNewQuickCheck then

if RKCheck.CurrentOrder.IsEmpty then 

RKCheck.CurrentOrder.UserTag1 := 0;

end;

A script to display a message requesting the guest's age when selling alcohol

On the order editing form, insert the CheckViewOnBeforeCheckViewEdit script and specify the SliceStrToStrings auxiliary procedure above it.

procedure SliceStrToStrings(StrIn,marker:String; var StringsOut:TStringList);

var s,s1:string; i:Integer;

begin

s:=StrIn;

while length(s)<>0 do begin

i:=pos(marker,s);

if i=0 then begin

s1:=s;

delete(s,1,length(s1));

StringsOut.Add(s1);

end

else begin

s1:=copy(s,1,i-1);

delete(s,1,i);

StringsOut.Add(s1)

end;

end;

end;


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

var Categ, Categ2: TClassificatorGroup;

CategCode, CategCode2: integer;

sdate: string;

bdate, cdate: TDateTime;

Day, Year, Month: integer;

SLtmp: TStringList;

begin

CategCode := 8; // enter the alcohol category code here  

CategCode2 := 5; // enter the alcohol category code here   

cdate := EncodeDate((StrToInt(FormatDateTime('yyyy',Date)) - 18), StrToInt(FormatDateTime('mm',Date-1)),StrToInt(FormatDateTime('dd',Date-1)));

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

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


if RKCheck.CurrentOrder.UserTag2 = 20000 then

if RK7.CashUser.ConfirmOperation(rkoUser08) then

AAllow := True

else

begin 

AAllow := false;

AMessage := 'Manager confirmation required!';

exit;

end;


if not(AEditType = etRemove) then

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

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

or (Categ2.IsChild(TDish(AObjectAft).RefItem))

then

if (RKCheck.CurrentOrder.UserTag2 <> 10000) then

begin

AAllow := False;

AMessage := 'Wrong date format!!!';

sdate:=gui.InputBox('Date of birth dd. mm. yyyy', 'Enter the guest's date of birth', '', true);

if length(trim(sdate))<>10 then

begin

AMessage := 'Wrong date format!';

AAllow := False;

end

else

try

SLtmp := TStringList.Create;

SLtmp.Clear;

SLtmp.Sorted := false;

SliceStrToStrings(sdate,'.',SLtmp);

bdate := EncodeDate(StrToInt(SLtmp.strings[2]),StrToInt(SLtmp.strings[1]),StrToInt(SLtmp.strings[0]));

if bdate<=cdate then

begin

RKCheck.CurrentOrder.UserTag2 := 10000;

RKCheck.UpdateVisitComment('',DateToStr(bdate));

AAllow := True;

end

else if bdate>cdate then

begin

RKCheck.CurrentOrder.UserTag2 := 20000;

AMessage := 'Guest under the age of 18. Alcohol sale prohibited!';

AAllow := False;

end

else gui.showmessage('Error of birth date input');

finally

SLtmp.Free();

end;

end;

end;

A script to add no more than one combo dish with a certain code into a quick check 

A script to add no more than one combo dish «STAFF MEALS» with the code 157 into a quick check.

Insert the script on the quick check editing form of the CheckView object in the OnBeforeCheckViewEdit event.

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

var i, DishCode1: integer;

qnt, qntMax: double;

it: TCheckItem;

begin

qnt := 0;

DishCode1 := 34; // special dish code  

qntMax := 1; // special dish max quantity in the order.  

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

if TDish(AObjectAft).code = DishCode1 then

if not(AEditType = etRemove) then

begin

qnt := TDish(AObjectAft).Quantity-TDish(AObjectBef).Quantity; 

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 = DishCode1 then 

qnt := qnt + TDish(it).Quantity;

end; 

end;

if qnt > qntMax then // check limit exceed

begin 

AAllow := false;

AMessage := 'Quantity exceeded the permitted limit ';

end;

end;

The script checks the dish added to the order, counting its current quantity. If it exceeds the specified limit, the addition of the dish is blocked.

A script to prohibit the payment for the table before swiping the loyalty card (PDS)

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

The example for three categories:

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

var i, CategCode, CategCode2, CategCode3, dishpresent: integer;

it: TCheckItem;

Categ, Categ2, Categ3: TClassificatorGroup;

CardCode: string;

McrPay: TMcrPay;

begin

CategCode := 8; // special dishes category  

dishpresent := 0;

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

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

Categ3 := TClassificatorGroup(getitemBycodeNum('ClassificatorGroups', CategCode3));

CardCode := '';

// checking the card presence in the order  

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

McrPay := TMcrPay(RKCheck.CurrentOrder.Sessions.McrPays.Items[i]);

CardCode := McrPay.CardNum;

end;

// checking the special dishes presence in the order  

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 Categ.IsChild(it.RefItem) then

dishpresent := dishpresent + 1;

if Categ2.IsChild(it.RefItem) then

dishpresent := dishpresent + 1;

if Categ3.IsChild(it.RefItem) then

dishpresent := dishpresent + 1;

end;

// payment control  

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

if dishpresent > 0 then

if CardCode <> '' then

AAllow:= True

else

begin 

AAllow := false;

AMessage := 'Use PLASTEK card!';

end; 

end;

A script for changing the payment type

The scripts block adding any objects to the receipt except for the payment in the allowed currency when changing the payment currency in a closed receipt.

A script for the selector:

procedure ProcessOperation1003036(Parameter: integer);

var i, HaveCurrency1, HaveDenyCurr, AllowCurrType1, DennyCurrType1: integer;

it: TCheckItem;

begin

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

DennyCurrType1 := 91; // Code of currency type

AllowCurrType1 := 15; // Code of currency type

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

HaveCurrency1 := 0;

HaveDenyCurr := 0;

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

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

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

begin

if (TCurrencyType(TCurrency(TPayLine(it).RefItem).MainParent).Code = AllowCurrType1) then

HaveCurrency1 := HaveCurrency1 + 1;

if (TCurrencyType(TCurrency(TPayLine(it).RefItem).MainParent).Code = DennyCurrType1) then

HaveDenyCurr := HaveDenyCurr + 1;

end;

end;

if HaveDenyCurr > 1 then

begin

gui.showmessage('You can''t change this payment!');

exit;

end;

if HaveCurrency1 > 0 then

begin 

RKCheck.CurrentOrder.UserTag1 := 10000;

RK7.PerformOperation(rkoUndoReceipt,0);

RKCheck.CurrentOrder.UserTag1 := 10000;

end

else

gui.showmessage('You can''t change this payment!');

end;

On the check 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 AllowCurrType1: integer;

i, numcateg, TypeCurrCode, CurrCode, maxqntvoucher: integer;

categsum, currsum,vouchersum: double;

it: TCheckItem;

Categ: TClassificatorGroup;

begin

//********************* 54276 *********************

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

numcateg := 39; // Code of dish category

TypeCurrCode := 91; // Code of currency type

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

currsum := 0;

categsum := 0;

maxqntvoucher := 0;

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


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

if TCurrencyType(TCurrency(TPayLine(AObjectAft).RefItem).MainParent).Code=TypeCurrCode then // checking dish category

begin

CurrCode := TPayLine(AObjectAft).Code;


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

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

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

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

if TDish(it).Quantity > 0 then

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

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

if (it.Code = CurrCode) then

if (TPayLine(it).BasicSum > 0) then

currsum := currsum + TPayLine(it).NationalSum;

end;


vouchersum := TPayLine(AObjectAft).DBKurs;

maxqntvoucher := trunc(0.99+categsum / vouchersum);

if (categsum > 0) and (maxqntvoucher=0) then

maxqntvoucher := 1; 

if ((currsum + vouchersum*TPayLine(AObjectAft).OriginalSum)/vouchersum) > (maxqntvoucher) then

begin

AAllow := false;

AMessage := 'Decreese quantity of vouchers to '+IntToStr(maxqntvoucher)+' !';

end;

end;

//********************* 54276 *********************

//********************* 53641 *********************

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

AllowCurrType1 := 91; // allow curency type

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

if RKCheck.CurrentOrder.UserTag1 = 10000 then // it's don't work in current version R-Keeper

begin


AMessage := 'Denied this action!';

AAllow := False;

if not(AEditType = etRemove) then

if SYS.ObjectInheritsFrom(TObject(AObjectAft), 'TPayLine') then

if TCurrencyType(TCurrency(TPayLine(AObjectAft).RefItem).MainParent).Code=AllowCurrType1 then // ??? ???? ?????? ??? ???????? ?????????????? ?????????? ?????? 

begin

AAllow := True

end 

else

begin

AMessage := 'You can''t add this currency';

AAllow := False;

end;

if AAllow then

begin

RK7.PerformRefObject(RK7.FindItemByCode(rkrefMaketSchemeDetails,342)); // print check

end;

end;

//********************* 53641 *********************

end;

A script to change the payment type

You need a script allowing you to change the payment type in the already printed receipt.

Preparation:

  1. Create 2 currencies:
    • the first currency type is Cash.
    • the second currency type is Cards.
  2. Specify script codes for these currencies.
  3. Create canceling reason (Change payment type) Specified its code in the script.

The scenario:

  1. Print the receipt
  2. Go to closed orders.
  3. Choose the receipt to change the payment type for.
  4. Press the «Change payment type» button.
  5. The script checks the code of the currency for which the receipt is closed:
    1. If the receipt is closed for any other currency, the code of which we did not specify in the script, then we do not perform the operation, but issue a message to the user that this operation is not possible.
    2. If the currency code is the one specified in the script, then make the following steps.
  6. The script cancels the receipt, specify the reason.
  7. The script adds a saved comment to the order from this receipt (f.ex.: «Receipt canceled when changing currency from EUR to VISA»).

    • It is advisable to specify the number of the next receipt in this comment, the one that will be closed for the desired currency.
  8. The script prints a new receipt with the same content, but we close it for a different currency, the code of which is specified in the script. 
    1. When printing a new receipt, write in the memo, or in the unsaved comment, or in some other field, «A receipt with a changed payment currency, printed instead of NUMBER OF THE CANCELED RECEIPT».
    2. In the saved order comment, add «Correct receipt - THE NUMBER OF THE NEW RECEIPT».

A script for a custom operation, assigned to the closed receipt form selector.

procedure ProcessOperation1002528(Parameter: integer);

var i, HaveCurrency1, HaveDenyCurr, AllowCurrType1, DennyCurrType1, CheckNum: integer;

CurrName: string;

it: TCheckItem;

begin

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

DennyCurrType1 := 91; // Code of currency type

AllowCurrType1 := 13; // Code of currency type

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

HaveCurrency1 := 0;

HaveDenyCurr := 0;

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

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

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

begin

if (TCurrencyType(TCurrency(TPayLine(it).RefItem).MainParent).Code = AllowCurrType1) then

begin

HaveCurrency1 := HaveCurrency1 + 1;

CurrName := TCurrencyType(TCurrency(TPayLine(it).RefItem).MainParent).Name;

end;

if (TCurrencyType(TCurrency(TPayLine(it).RefItem).MainParent).Code = DennyCurrType1) then

HaveDenyCurr := HaveDenyCurr + 1;

end;

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

CheckNum := TPrintCheckItem(it).CheckNum;

end;

if HaveDenyCurr > 1 then

begin

gui.showmessage('You can''t change this payment!');

exit;

end;

if HaveCurrency1 > 0 then

begin 

RKCheck.CurrentOrder.UserTag1 := 10000;

RK7.PerformOperation(rkoUndoReceipt,0);

RKCheck.UpdateVisitComment(' #'+IntToStr(CheckNum)+' currency '+CurrName, '');

RKCheck.CurrentOrder.UserTag1 := 10000;

end

else

gui.showmessage('You can''t change this payment!');

end;

On the check editing form, insert the 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 AllowCurrType1: integer;

i, numcateg, TypeCurrCode, CurrCode, maxqntvoucher: integer;

categsum, currsum,vouchersum: double;

it: TCheckItem;

Categ: TClassificatorGroup;

begin

//********************* 81848 *********************

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

AllowCurrType1 := 91; // allow curency type

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

if RKCheck.CurrentOrder.UserTag1 = 10000 then 

begin


AMessage := 'Denied this action!';

AAllow := False;

if not(AEditType = etRemove) then

if SYS.ObjectInheritsFrom(TObject(AObjectAft), 'TPayLine') then

if TCurrencyType(TCurrency(TPayLine(AObjectAft).RefItem).MainParent).Code=AllowCurrType1 then

begin

AAllow := True

end 

else

begin

AMessage := 'You can''t add this currency';

AAllow := False;

end;

if AAllow then

begin

RKCheck.UpdateVisitComment('Change payment '+RKCheck.CurrentOrder.VisitExtraInfo+' to '+TCurrencyType(TCurrency(TPayLine(AObjectAft).RefItem).MainParent).Name, ''); 

RK7.PerformRefObject(RK7.FindItemByCode(rkrefMaketSchemeDetails,342)); // print check

end;

end;

//********************* 81848 *********************

end;

For a user operation assigned to the selector for changing payment in the closed receipt, enable "Log entry", rename the operation itself as you would like to see it in the operation log.

A script to limit the number of vouchers

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

var i, numcateg, codecurr, maxqntvoucher: integer;

categsum, currsum,vouchersum: double;

it: TCheckItem;

Categ: TClassificatorGroup;

begin

numcateg := 4; // categorycode for special dishes

vouchersum := 500; // sum of 1 voucher

currsum := 0;

categsum := 0;

maxqntvoucher := 0;

codecurr := 14; 

Categ := TClassificatorGroup(getitemBycodeNum('ClassificatorGroups', numcateg)); //5 - category code

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

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

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

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

if TDish(it).Quantity > 0 then

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

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

if (it.Code = codecurr) then

currsum := currsum + TPayLine(it).NationalSum;

end;


maxqntvoucher := trunc(0.99+categsum / vouchersum);

if (categsum > 0) and (maxqntvoucher=0) then

maxqntvoucher := 1; 


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

if (TPayLine(AObjectAft).code = codecurr) then

if ((currsum + vouchersum*TPayLine(AObjectAft).OriginalSum)/vouchersum) > (maxqntvoucher) then

begin

AAllow := false;

AMessage := 'Decreese quantity of vouchers to '+IntToStr(maxqntvoucher)+' !';

end;

end;

A script to restrict the deletion of dishes from an unsaved order

You need a script that implements the following:

  • the cashier can independently delete dishes from the order before the "Payment" button is clicked
  • it is impossible to delete all the dishes, at least one must remain in the order.

1. Add a script.

procedure ProcessOperation1000185(Parameter: integer);

begin

end;

2. Add it to the user operation, remember its number, and set up the access control property.

3. Add manager permission to use this custom operation in the user roles properties.

4. Add the following line in the DesignForm object on the «Editing order: Quick check» form:

if Operation = 454 then RKCheck.CurrentOrder.UserTag1 := 1;

5. Next are the CheckView object and the OnBeforeCheckView event. The script body with variables from other KFC scripts included:

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

var i, CurrCode1, CurrCode2, CurrCode2_2, curr1present, curr2present: integer; 

it: TCheckItem;

Categ: TClassificatorGroup;

CategCode: integer;

j,cntrl: integer;

it1:tobject; 

begin

//--------------- 63889 --------------------------

cntrl:=0;

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

// begin

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

// if SYS.ObjectInheritsFrom(it, 'TDish') then cntrl:=cntrl+1;

// end;


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

begin

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

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

begin

cntrl:=cntrl+1;

if TDish(it1).IsComboComp then cntrl:=cntrl-1;

// gui.showmessage(intToStr(cntrl));

end;

end;


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

if AEditType=etRemove then

begin

if cntrl<2 then

begin

AAllow:=false;

AMessage:='At least one dish required for the order';

end

else 

if RKCheck.CurrentOrder.UserTag2 = 1 then

if RK7.CashUser.ConfirmOperation(rkoUser03) then AAllow:=true

else

begin

AAllow:=false;

AMessage:='Deletion is not possible'+#13#10+'no access!';

end; 

end;


end;

6. Add the following in the CheckViewOnOrderVerify procedure after the first «begin»:

if AVerifyType=vtPrintReceipt then begin

RKCheck.CurrentOrder.UserTag2 := 0;

//gui.showmessage('reset control variable');

end; 

A script to prohibit quantity changing

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

var i, integer;

it: TCheckItem;

qnt,qntbefore: double;

begin

//Start Lock change DISH QNT for Categ CRM

qnt := 0;

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

if not(AEditType = etRemove) then

if (TDish(AObjectAft).RefItem.MainParent.code = 3100) and (TDish(AObjectBef).Quantity <> 0) then //Check category of the dish

begin

//Gui.SHowMessage('3' + ' QNTBef=' + FloatToStr(TDish(AObjectBef).Quantity));

qntBefore := TDish(AObjectBef).Quantity;

qnt := TDish(AObjectAft).Quantity-TDish(AObjectBef).Quantity;

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

begin

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

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

qnt := qnt + TDish(it).Quantity;

end; 

end;

if qnt <> qntBefore then // check limit exceed

begin 

AAllow := false;

AMessage := 'You dont have permissions for change dish quantyti';

end;

//End Lock change DISH QNT for Categ CRM

end;
  • No labels