/**
   * This method determines whether or not an asset has different object sub type codes in its
   * documents.
   *
   * @return true when the asset has payments with object codes that point to different object sub
   *     type codes
   */
  public boolean hasDifferentObjectSubTypes(
      List<CapitalAccountingLines> capitalAccountingLines, List<AccountingLine> accountingLines) {
    List<String> subTypes = new ArrayList<String>();
    List<String> objectSubTypeList = new ArrayList<String>();
    List<String> validObjectSubTypes = new ArrayList<String>();

    subTypes =
        new ArrayList<String>(
            SpringContext.getBean(ParameterService.class)
                .getParameterValuesAsString(
                    Asset.class,
                    KFSParameterKeyConstants.CamParameterConstants.OBJECT_SUB_TYPE_GROUPS));

    for (String subType : subTypes) {
      validObjectSubTypes = Arrays.asList(StringUtils.split(subType, ","));
    }

    for (CapitalAccountingLines capitalAccountLine : capitalAccountingLines) {
      if (capitalAccountLine.isSelectLine() && capitalAccountLine.isAmountDistributed()) {
        AccountingLine matchAccountingLine =
            findAccountingLine(accountingLines, capitalAccountLine);
        if (ObjectUtils.isNotNull(matchAccountingLine)) {
          matchAccountingLine.refreshReferenceObject("objectCode");
        }
        if (validObjectSubTypes.contains(
            matchAccountingLine.getObjectCode().getFinancialObjectSubTypeCode())) {
          if (!objectSubTypeList.contains(
              matchAccountingLine.getObjectCode().getFinancialObjectSubTypeCode())) {
            // different object subtypes
            return true;
          }
          objectSubTypeList.add(
              matchAccountingLine.getObjectCode().getFinancialObjectSubTypeCode());
        }
      }
    }

    if (objectSubTypeList.isEmpty()) {
      return false;
    }

    return false;
  }
  /**
   * Finds the accounting line that matches the capital accounting line.
   *
   * @param capitalAccountLine
   * @return accounting line
   */
  protected AccountingLine findAccountingLine(
      List<AccountingLine> accountingLines, CapitalAccountingLines capitalAccountingLine) {
    AccountingLine accountingLine = null;

    for (AccountingLine line : accountingLines) {
      if (capitalAccountingLine.getChartOfAccountsCode().equals(line.getChartOfAccountsCode())
          && capitalAccountingLine.getAccountNumber().equals(line.getAccountNumber())
          && capitalAccountingLine.getFinancialObjectCode().equals(line.getFinancialObjectCode())
          && capitalAccountingLine
              .getLineType()
              .equalsIgnoreCase(
                  line instanceof SourceAccountingLine
                      ? KFSConstants.SOURCE
                      : KFSConstants.TARGET)) {
        return line;
      }
    }

    return accountingLine;
  }