Beispiel #1
0
  /**
   * Fetches the last {@link Bill} that the user Paid. If User has not paid any bill, then returns
   * null
   *
   * @return
   * @since 1.0
   */
  public Bill getLastPaidBill() {
    Bill bill = null;
    int maxBillId = 0;

    Iterator itr = this.getBills().iterator();
    while (itr.hasNext()) {
      Bill tempBill = (Bill) itr.next();
      if (tempBill.getStatus().equals(BillStatusEnum.PAID.getValue())) {
        if (tempBill.getBillId() > maxBillId) maxBillId = tempBill.getBillId();
        bill = tempBill;
      }
    }

    return bill;
  }
Beispiel #2
0
  /**
   * Checks if bill has been created for a User and returns true if a Paid or Pending bill exists.
   * If no {@link Bill} in {@link BillStatusEnum#PAID} or {@link BillStatusEnum#PENDING} status
   * exists, returns false.
   *
   * <p>Note: Cancelled Bill is not considered since it will never be paid by the user, so a
   * cancelled Bill is a non billed user.
   *
   * @return
   * @since 1.0
   */
  public boolean isUserBeenBilledOnce() {
    //  status of the bill could have been updated by some other process, so also checking if the
    // bill is pending
    // if there is a pending bill, then this is not the first bill
    if (this.pendingBill != null
        && this.pendingBill.getStatus().equals(BillStatusEnum.PENDING.getValue())) {
      return true;
    }

    // if user has a paid bill, then this is not the first bill
    Iterator itr = this.getBills().iterator();
    while (itr.hasNext()) {
      Bill tempBill = (Bill) itr.next();
      if (tempBill.getStatus().equals(BillStatusEnum.PAID.getValue())) {
        return true;
      }
    }

    return false;
  }