/**
   * This method sums the totals of each accounting line, making an entry in a map for each unique
   * pay fiscal year and pay period.
   *
   * @param accountingLines
   * @return
   */
  protected Map sumAccountingLineAmountsByPayFYAndPayPeriod(List accountingLines) {

    ExpenseTransferAccountingLine line = null;
    KualiDecimal linesAmount = KualiDecimal.ZERO;
    Map linesMap = new HashMap();
    String payFYPeriodKey = null;

    // go through source lines adding amounts to appropriate place in map
    for (Iterator i = accountingLines.iterator(); i.hasNext(); ) {
      // initialize
      line = (ExpenseTransferAccountingLine) i.next();
      linesAmount = KualiDecimal.ZERO;

      // create hash key
      payFYPeriodKey =
          createPayFYPeriodKey(
              line.getPayrollEndDateFiscalYear(), line.getPayrollEndDateFiscalPeriodCode());

      // if entry exists, pull from hash
      if (linesMap.containsKey(payFYPeriodKey)) {
        linesAmount = (KualiDecimal) linesMap.get(payFYPeriodKey);
      }

      // update and store
      linesAmount = linesAmount.add(line.getAmount());
      linesMap.put(payFYPeriodKey, linesAmount);
    }

    return linesMap;
  }
Пример #2
0
 /** @see java.lang.Object#hashCode() */
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((adjustmentKey == null) ? 0 : adjustmentKey.hashCode());
   result = prime * result + ((offCampusRate == null) ? 0 : offCampusRate.hashCode());
   result = prime * result + ((onCampusRate == null) ? 0 : onCampusRate.hashCode());
   result = prime * result + ((rateClassType == null) ? 0 : rateClassType.hashCode());
   result = prime * result + ((validRatesId == null) ? 0 : validRatesId.hashCode());
   return result;
 }
  /**
   * This method checks that the total amount of labor ledger accounting lines in the document's
   * FROM section is equal to the total amount on the labor ledger accounting lines TO section for
   * each unique combination of pay fiscal year and pay period. A value of true is returned if all
   * amounts for each unique combination between source and target accounting lines match, false
   * otherwise.
   *
   * @param sourceLinesMap
   * @param targetLinesMap
   * @return
   */
  protected boolean compareAccountingLineTotalsByPayFYAndPayPeriod(
      Map sourceLinesMap, Map targetLinesMap) {

    boolean isValid = true;
    Map.Entry entry = null;
    String currentKey = null;
    KualiDecimal sourceLinesAmount = KualiDecimal.ZERO;
    KualiDecimal targetLinesAmount = KualiDecimal.ZERO;

    // Loop through source lines comparing against target lines
    for (Iterator i = sourceLinesMap.entrySet().iterator(); i.hasNext() && isValid; ) {
      // initialize
      entry = (Map.Entry) i.next();
      currentKey = (String) entry.getKey();
      sourceLinesAmount = (KualiDecimal) entry.getValue();

      if (targetLinesMap.containsKey(currentKey)) {
        targetLinesAmount = (KualiDecimal) targetLinesMap.get(currentKey);

        // return false if the matching key values do not total each other
        if (sourceLinesAmount.compareTo(targetLinesAmount) != 0) {
          isValid = false;
        }

      } else {
        isValid = false;
      }
    }

    /*
     * Now loop through target lines comparing against source lines. This finds missing entries from either direction (source or
     * target)
     */
    for (Iterator i = targetLinesMap.entrySet().iterator(); i.hasNext() && isValid; ) {
      // initialize
      entry = (Map.Entry) i.next();
      currentKey = (String) entry.getKey();
      targetLinesAmount = (KualiDecimal) entry.getValue();

      if (sourceLinesMap.containsKey(currentKey)) {
        sourceLinesAmount = (KualiDecimal) sourceLinesMap.get(currentKey);

        // return false if the matching key values do not total each other
        if (targetLinesAmount.compareTo(sourceLinesAmount) != 0) {
          isValid = false;
        }

      } else {
        isValid = false;
      }
    }
    return isValid;
  }
Пример #4
0
 /** @see java.lang.Object#equals(java.lang.Object) */
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   final ValidRates other = (ValidRates) obj;
   if (adjustmentKey == null) {
     if (other.adjustmentKey != null) return false;
   } else if (!adjustmentKey.equals(other.adjustmentKey)) return false;
   if (offCampusRate == null) {
     if (other.offCampusRate != null) return false;
   } else if (!offCampusRate.equals(other.offCampusRate)) return false;
   if (onCampusRate == null) {
     if (other.onCampusRate != null) return false;
   } else if (!onCampusRate.equals(other.onCampusRate)) return false;
   if (rateClassType != other.rateClassType) return false;
   if (validRatesId == null) {
     if (other.validRatesId != null) return false;
   } else if (!validRatesId.equals(other.validRatesId)) return false;
   return true;
 }
 /**
  * Converts the value into a string, with the appropriate formatting
  *
  * @param fieldActualValue actual field value
  * @param fieldType field type (i.e. "String", "Integer", "Date")
  * @return String object value as a string
  */
 public static String convertToString(Object fieldActualValue, String fieldType) {
   if (fieldActualValue == null) {
     return "";
   }
   if ("String".equals(fieldType)) {
     return (String) fieldActualValue;
   } else if ("Integer".equals(fieldType)) {
     Integer i = (Integer) fieldActualValue;
     return i.toString();
   } else if ("KualiDecimal".equals(fieldType)) {
     KualiDecimal kd = (KualiDecimal) fieldActualValue;
     return kd.toString();
   } else if ("BigDecimal".equals(fieldType)) {
     BigDecimal bd = (BigDecimal) fieldActualValue;
     return bd.toString();
   } else if ("Date".equals(fieldType)) {
     Date d = (Date) fieldActualValue;
     SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
     return df.format(d);
   }
   return "";
 }