Yêu cầu từ chuỗi nhà hàng NYDC Vietnam |
Nếu trên order có Combo thì sẽ không cho phép áp dụng chiết khấu (discount) trên toàn bộ order đó. Lý do: Bản thân Combo đã là một hình thức chiết khấu.
var i: integer;
it: TCheckItem;
//----
begin
if (AEditType = etInsert) and SYS.ObjectInheritsFrom(AObjectAft, 'TDiscountItem') then begin
if TDiscountItem(AObjectAft).Localization = chlDish then begin
// không cho phép áp dụng giảm giá trên combo
if SYS.ObjectInheritsFrom(TObject(RKCheck.CurrentCheckItem), 'TDish') then
if TDish(RKCheck.CurrentCheckItem).IsComboComp then begin
AAllow := False;
AMessage := 'It is impossible to add discount for combo component';
end else if TDish(RKCheck.CurrentCheckItem).IsCombo then begin
AAllow := False;
AMessage := 'It is impossible to add discount for combo dish';
end;
end else begin
// không cho phép áp dụng giảm giá trên order nếu có combo trong 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 begin
if TDish(it).IsCombo then begin
AAllow := False;
AMessage := 'It is impossible to add discount since there is combo in order';
Exit;
end;
end;
end;
end;
end;
end;
|