示例#1
0
  public Bill getPendingBill() {
    // status of the bill could have been updated by some other process, so also checking if the
    // bill is pending
    if (this.pendingBill != null
        && this.pendingBill.getStatus().equals(BillStatusEnum.PENDING.getValue())) {
      return pendingBill;
    }

    Bill bill = null;
    Iterator itr = this.getBills().iterator();
    while (itr.hasNext()) {
      Bill tempBill = (Bill) itr.next();
      if (tempBill.getStatus().equals(BillStatusEnum.PENDING.getValue())) {
        if (bill != null) {
          throw new MultiplePendingBillsException(
              "User with userid, username : "******", "
                  + this.getUsername()
                  + "has multiple pending Bills");
        }
        bill = tempBill;
      }
    }

    return bill;
  }
示例#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;
  }