Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
procedure ProcessOperation1001537(Parameter: integer);

var i: integer;

Limit: double;

CardCode: string;

McrPay: TMcrPay;

begin

if TObject(RKCheck.CurrentOrder) = Nil then Exit;


// Limit calculation

Limit := 0;

CardCode := '';

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

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

Limit := Limit + McrPay.MaxAmount;

CardCode := McrPay.CardNum;

end;

if CardCode = '' then Exit

else

gui.Showmessage('Card '+CardCode+' balance '+FloatToStr(Limit)+' р.');

end;

Limiting the 100% Category Discount

Mission: The 100% discount should apply only to one dish item belonging to the category.

Solution:

Code Block
procedure ProcessOperation1001621(Parameter: integer);

...



var i, j, numcateg: integer;

...



DiscCode: integer;

...



it, CurItem: TCheckItem;

...



SL: TStringList;

...



a, q, Price: double;

...



d: TDish;

...



CheckView: TCheckView;

...



Categ: TClassificatorGroup;

...



skip: boolean;

...



begin

...



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;

...



DiscCode := 11;

...



numcateg := 8; //5 - category code

...



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

...



begin

...



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

...



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

...



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

...



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

...



// if (it.RefItem.MainParent.code =11 ) then // if dish from category of menu and have same code

...



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

...



begin

...



skip := false;

...



for j:=0 to SL.Count - 1 do

...



begin

...



d:= TDish(SL.Objects[j]);

...



if d.code=it.code then

...



Skip := True;

...



end;

...



if not(skip) then

...



begin

...



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;

...



end;

...




//Magic

...



q:=0;

...



for i:= 0 to SL.Count - 1 do

...



begin

...



a:= 0;

...



d:= TDish(SL.Objects[i]);

...



q:= d.Quantity;

...



if (d.Quantity = 0) or (d.PRListSum = 0) then Price := d.Price

...



else Price := d.PRListSum/d.Quantity;

...



a:= a + Price;

...




// Delete discount if the 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;

Opening the Browser WIndow for Displaying POS Operation Reports

Mission: It is required to create a function button in the main POS menu that when pressed will execute the command fsWeb.exe "https://172.22.4.57:8088/csthtm/overall1.html", where 172.22.4.57 is the value of an extended restaurant property

...