external:pro_bonus:98_dop:25_zapret_oplaty_bonusom

Это старая версия документа!


Либо начисление бонуса, либо оплата бонусами

Бывают случаи, когда программа лояльности предполагает запрет на оплату бонусами в заказе, где они начисляются. Т. е. можно либо оплатить заказ или его часть бонусами, либо начислить бонусы.

Такая задача решается с помощью кассового скрипта, размещаемого на форме «Редактирование заказа» и/или «Редактирование заказа (быстрый чек)» - в компоненте CheckView .

Скрипт вставляем в верхнюю часть обработчика (важна последовательность).
Внутри скрипта нужно поменять код валюты оплаты бонусами и код скидки-бонуса.

function DiscPres(DiscCode: integer; seatN:string):string;
var
j,i: integer;
it: tCheckitem;
aga:string;
begin
aga:='';
for j := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do
  begin
    it := RKCheck.CurrentOrder.Sessions.Lines[j];
    if SYS.ObjectInheritsFrom(TObject(it), 'TDiscountitem') then
        if (TDiscountitem(it).state=disdeleted) and (TDiscountitem(it).code=discCode) and(TDiscountItem(it).SeatName=seatN)  then aga:=TDiscountItem(it).CardCode;
  end;
result:=aga;
end;
procedure DesignFormOnOperation(Sender: TBasePanel; Operation, Param: integer; var res: integer);
var
k,i,diskcode:integer;
CheckView: TCheckView;
it,CurItem: TCheckItem;
d:TDiscountitem;
isDisk:boolean;
sl: TStringList;
begin
  diskcode:=35; // код скидки-бонуса
  dbg.dbgprint(inttostr(operation));
  SL:= TStringList.Create;
  if (((operation = rkoCalcOrder) or (operation = rkoBalanceReceipt)or (operation = rkoCalcBySeats)) and(RKCheck.CurrentOrder.BillExists=false)) or (operation = rkoPrintBill) or (operation = rkoPrintSeatBills) then
  begin
    CheckView := TCheckView(GUI.FindComponentByName('CheckView'));
    for i := 0 to RKCheck.CurrentOrder.Sessions.LinesCount - 1 do
      begin
        it := RKCheck.CurrentOrder.Sessions.Lines[i];
        if SYS.ObjectInheritsFrom(it, 'TDiscountItem') then
        if (TDiscountItem(it).code= diskcode) and (TDiscountItem(it).state<>disdeleted) then 
          begin
            isDisk:=true;            
            SL.AddObject(FormatFloat('00000000.00', TDiscountitem(it).code) + IntToStr(TDiscountitem(it).UNI), TObject(it));
          end;
      end;  

   if isdisk then
   begin
   for i:= 0 to SL.Count - 1 do
    begin

    d:= TDiscountitem(SL.Objects[i]);    
    k:=GUI.MessageDlgEx('Списываем бонусы или начисляем бонусы для места № '+inttostr(Tdiscountitem(d).seat)+'?',mtInformation, mbYes+mbNo, 'Списываем;Начисляем');
     if k= id_YES then 
     begin    
       CheckView.GotoItem(TObject(d));        
       RKCheck.DeleteCheckItem(d);
       RKCheck.CurrentOrder.Recalc();
     end;    
    end;
   end;
   SL.Free();
 end;
end;

procedure MainSelectorAfterConnectObjectScript(Obj: TObject; Button: TGCustomButton);
var
CurrCode, diskcode:integer;
CheckView: TCheckView;
CurItem: TCheckItem;
c: TVisualComponent;
begin
CurrCode:=10; //код валюты "оплата бонусами"
diskcode:=35; // код скидки-бонуса
CheckView:=TCheckView(GUI.FindComponentByName('CheckView'));
c := GUI.FindComponentByName('MainSelector');
if CheckView = Nil then Exit;
   if SYS.ObjectInheritsFrom(obj, 'TMcrPay') then
   begin
     CurItem := RKCheck.CurrentCheckItem;
     if SYS.ObjectInheritsFrom(TObject(curitem), 'TPrintCheckitem') then
     begin
        if DiscPres(diskcode, TPrintCheckitem(curitem).SeatName )=TMcrPay(obj).CardNum then 
               button.enabled :=true
               else button.enabled :=false;
     end;    
   end;
end;
  • external/pro_bonus/98_dop/25_zapret_oplaty_bonusom.1733983993.txt.gz
  • Последнее изменение: 2024/12/12 09:13
  • Алексей Коробов