private void setDiscount(boolean discount, Data data) {
    double totalPrice = bill.getTotalPrice();
    LocalDate date = data.getDate();
    if ((date.equals(hollidayChristmas))
        || (date.equals(hollidayIndepenanceDay))
        || (date.equals(hollidayProgrammerDay))) {
      totalPrice *= 0.5;
      bill.setTotalPrice(totalPrice);
      discount = false;
      logger.info(resourceBundle.getString("economyHollidays") + bill.getTotalPrice());
      bill.setHollidays(
          resourceBundle.getString("economyHollidays")
              + String.format(" %.2f ", bill.getTotalPrice()));
    } else {
      logger.info(resourceBundle.getString("noEconomy"));
      bill.setHollidays(resourceBundle.getString("noEconomy"));
    }

    if (discount == true) {
      double discountPay = bill.getTotalPrice() * 0.1;
      totalPrice *= 0.9;
      bill.setTotalPrice(totalPrice);
      logger.info(resourceBundle.getString("yourDiscount") + discountPay);
      bill.setDiscount(
          resourceBundle.getString("yourDiscount") + " " + String.format(" %.2f ", discountPay));
    } else if (discount == false) {
      totalPrice *= 1;
      bill.setTotalPrice(totalPrice);
      logger.info(resourceBundle.getString("noDiscount"));
      bill.setDiscount(resourceBundle.getString("noDiscount"));
    }
  }
 @Override
 public boolean equals(Object obj) {
   if (obj == null) return false;
   if (obj.getClass() != getClass()) return false;
   CheckoutRecordEntry e = (CheckoutRecordEntry) obj;
   return checkoutDate.equals(e.checkoutDate)
       && dueDate.equals(e.dueDate)
       && copy.getBook().equals(e.copy.getBook())
       && copy.getCopyNumuber() == e.copy.getCopyNumuber();
 }
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Lot lot = (Lot) o;

    if (item != null ? !item.equals(lot.item) : lot.item != null) return false;
    if (owner != null ? !owner.equals(lot.owner) : lot.owner != null) return false;
    if (datePlaced != null ? !datePlaced.equals(lot.datePlaced) : lot.datePlaced != null)
      return false;
    if (dateEnd != null ? !dateEnd.equals(lot.dateEnd) : lot.dateEnd != null) return false;
    if (startPrice != null ? !startPrice.equals(lot.startPrice) : lot.startPrice != null)
      return false;
    if (buyer != null ? !buyer.equals(lot.buyer) : lot.buyer != null) return false;
    return !(currentPrice != null
        ? !currentPrice.equals(lot.currentPrice)
        : lot.currentPrice != null);
  }
Beispiel #4
0
  @Override
  public boolean equals(Object obj) {
    if (this == obj) return true;
    if (obj == null) return false;
    if (getClass() != obj.getClass()) return false;

    ExchangeRate other = (ExchangeRate) obj;
    if (!time.equals(other.time)) return false;
    return value.equals(other.value);
  }
 @Override
 public boolean equals(Object x, Object y) throws HibernateException {
   if (x == y) {
     return true;
   }
   if (x == null || y == null) {
     return false;
   }
   LocalDate dtx = (LocalDate) x;
   LocalDate dty = (LocalDate) y;
   return dtx.equals(dty);
 }
Beispiel #6
0
 /*
  * (non-Javadoc)
  *
  * @see java.lang.Object#equals(java.lang.Object)
  */
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (!super.equals(obj)) return false;
   if (getClass() != obj.getClass()) return false;
   DeadLineTask other = (DeadLineTask) obj;
   if (endDate == null) {
     if (other.endDate != null) return false;
   } else if (!endDate.equals(other.endDate)) return false;
   if (endTime == null) {
     if (other.endTime != null) return false;
   } else if (!endTime.equals(other.endTime)) return false;
   return true;
 }
 // See https://en.wikipedia.org/wiki/Day_count_convention#30E.2F360_ISDA
 private int diff360EIsda(final LocalDate start, final LocalDate end) {
   if (start.equals(end)) {
     return 0;
   }
   int dayStart = start.getDayOfMonth();
   int dayEnd = end.getDayOfMonth();
   if (start.getMonth().length(start.isLeapYear()) == dayStart) {
     dayStart = MONTH_30_DAYS;
   }
   if (end.getMonth() != Month.FEBRUARY && end.getMonth().length(end.isLeapYear()) == dayEnd) {
     dayEnd = MONTH_30_DAYS;
   }
   return (end.getYear() - start.getYear()) * YEAR_360
       + (end.getMonthValue() - start.getMonthValue()) * MONTH_30_DAYS
       + dayEnd
       - dayStart;
 }
Beispiel #8
0
  @Override
  public boolean equals(Object object) {
    if (object == null) return false;

    if (object == this) {
      return true;
    }
    if (!(object instanceof ServiceInfo)) {
      return false;
    }
    ServiceInfo info = (ServiceInfo) object;
    if ((login.equals(info.getLogin()))
        && (password.equals(info.getPassword()))
        && (dateOfRegistration.equals(info.getDateOfRegistration()))
        && (email.equals(info.email))) return true;

    return false;
  }
Beispiel #9
0
 @Test
 public void localDateFunctions() throws IOException {
   ServiceLocator locator = container;
   DataContext db = locator.resolve(DataContext.class);
   LocalDate ld = LocalDate.now();
   Clicked cl = new Clicked().setDate(ld);
   db.submit(cl);
   Query<Clicked> query = db.query(Clicked.class);
   String uri = cl.getURI();
   boolean found1 =
       query.anyMatch(it -> it.getURI().equals(uri) && ld.compareTo(it.getDate()) == 0);
   boolean found2 =
       query.anyMatch(
           it -> it.getURI().equals(uri) && ld.equals(it.getDate()) && ld.isEqual(it.getDate()));
   boolean notFound =
       query.anyMatch(it -> it.getURI().equals(uri) && ld.compareTo(it.getDate()) != 0);
   Assert.assertTrue(found1);
   Assert.assertTrue(found2);
   Assert.assertFalse(notFound);
 }
 public boolean equals(Object o) {
   return o instanceof LocalDateRange
       && startDate.equals(((LocalDateRange) o).startDate)
       && endDate.equals(((LocalDateRange) o).endDate);
 }
Beispiel #11
0
 // -------------------------------------------------------------------------
 @Override
 public RatePaymentPeriod adjustPaymentDate(TemporalAdjuster adjuster) {
   LocalDate adjusted = paymentDate.with(adjuster);
   return adjusted.equals(paymentDate) ? this : toBuilder().paymentDate(adjusted).build();
 }