Exemplo n.º 1
0
  /**
   * This method validates the overhead rate values. Appropriate validation error is returned in
   * each of the following scenarios:
   *
   * <ol>
   *   <li>If percentage is less than zero or greater than 100.
   *   <li>If neither of percentage or lump sum amount is present.
   *   <li>If start date is not present, or start date date falls after the end date.
   * </ol>
   *
   * @return a list of <code>ValidationError</code> containing the appropriate error messages or
   *     null in case of no errors.
   */
  @Override
  public List<ValidationError> validate() {
    final List<ValidationError> validationErrors = new ArrayList<ValidationError>();

    if (percentage < 0.0 || percentage > 100)
      validationErrors.add(
          new ValidationError("percentage", "estimate.overhead.percentage.lessthan.100"));

    if (percentage == 0.0 && (lumpsumAmount == null || lumpsumAmount.getValue() == 0.0))
      validationErrors.add(
          new ValidationError("percentage", "estimate.overhead.percentage_or_lumpsum_needed"));

    if (percentage > 0.0 && lumpsumAmount != null && lumpsumAmount.getValue() > 0.0)
      validationErrors.add(
          new ValidationError(
              "percentage", "estimate.overhead.only_one_of_percentage_or_lumpsum_needed"));

    if (validity == null
        || validity != null && !compareDates(validity.getStartDate(), validity.getEndDate()))
      validationErrors.add(new ValidationError("validity", "estimate.overhead.invalid_date_range"));

    if (!validationErrors.isEmpty()) return validationErrors;
    return null;
  }
Exemplo n.º 2
0
 public String toCurrency(final Money money) {
   return toCurrency(money.getValue());
 }