/**
   * 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;
  }