Esempio n. 1
0
 public boolean equals(Object obj) {
   if (null == obj) return false;
   if (!(obj instanceof com.floreantpos.model.Discount)) return false;
   else {
     com.floreantpos.model.Discount discount = (com.floreantpos.model.Discount) obj;
     if (null == this.getId() || null == discount.getId()) return false;
     else return (this.getId().equals(discount.getId()));
   }
 }
Esempio n. 2
0
 public List<Discount> getValidCoupon(MenuItem menuItem) {
   List<Discount> discountList = new ArrayList<Discount>();
   for (Discount discount : getValidCoupons()) {
     if (discount.getMenuItems().contains(menuItem) || discount.isApplyToAll()) {
       discountList.add(discount);
     }
   }
   return discountList;
 }
Esempio n. 3
0
  public void updateCouponView(Discount coupon) {
    if (coupon == null) {
      tfName.setText(""); // $NON-NLS-1$
      tfNumber.setText(""); // $NON-NLS-1$
      tfType.setText(""); // $NON-NLS-1$
      tfValue.setText(""); // $NON-NLS-1$
      return;
    }

    btnEditValue.setEnabled(false);

    tfName.setText(coupon.getName());
    if (coupon.getType() == Discount.FREE_AMOUNT) {
      btnEditValue.setEnabled(true);
    }

    tfNumber.setText(String.valueOf(coupon.getId()));
    tfType.setText(Discount.COUPON_TYPE_NAMES[coupon.getType()]);
    tfValue.setText(NumberUtil.formatNumber(coupon.getValue()));

    double totalDiscount = 0;
    double subtotal = ticket.getSubtotalAmount();

    ticketCoupon.setDiscountId(coupon.getId());
    ticketCoupon.setName(coupon.getName());
    ticketCoupon.setType(coupon.getType());
    ticketCoupon.setValue(coupon.getValue());

    totalDiscount = ticket.calculateDiscountFromType(ticketCoupon, subtotal);
    ticketCoupon.setValue(totalDiscount);

    lblTotalDiscount.setText(NumberUtil.formatNumber(totalDiscount));
  }
Esempio n. 4
0
 @Override
 public Component getListCellRendererComponent(
     JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   Discount coupon = (Discount) value;
   //			String displayText = "<html><body>";
   //			displayText += "<p align='center'>Name:" + coupon.getName() + "</p>";
   //			displayText += "<p align='center'>" + coupon.getValue() + "</p>";
   //			displayText += "</body></html>";
   return super.getListCellRendererComponent(
       list, coupon.getName(), index, isSelected, cellHasFocus);
 }