/**
   * Gets the inquiryUrl attribute.
   *
   * @return Returns the inquiryUrl for the detail lines in the document.
   */
  protected List<Map<String, HtmlData>> getDetailLineFieldInquiryUrl(
      List<EffortCertificationDetail> detailLines) {
    LOG.debug("getDetailLineFieldInquiryUrl(List<EffortCertificationDetail>) start");

    Map<String, String> noninquirableFieldValues = this.getNoninquirableFieldValues();
    Inquirable inquirable = this.getInquirable();

    List<Map<String, HtmlData>> inquiryURL = new ArrayList<Map<String, HtmlData>>();
    for (EffortCertificationDetail detailLine : detailLines) {
      detailLine.refreshNonUpdateableReferences();

      Map<String, HtmlData> inquiryURLForAttribute = new HashMap<String, HtmlData>();
      for (String attributeName : this.getInquirableFieldNames()) {
        // exclude the non inquirable field values
        Object attributeValue = ObjectUtils.getPropertyValue(detailLine, attributeName);
        String noninquirableFieldValue = noninquirableFieldValues.get(attributeName);
        if (noninquirableFieldValue != null && noninquirableFieldValue.equals(attributeValue)) {
          continue;
        }

        HtmlData inquiryHref;
        if (this.getCustomizedInquirableFieldNames().contains(attributeName)) {
          inquiryHref = this.getCustomizedInquiryUrl(detailLine, attributeName);
        } else {
          inquiryHref = inquirable.getInquiryUrl(detailLine, attributeName, false);
        }

        inquiryURLForAttribute.put(attributeName, inquiryHref);
      }

      inquiryURL.add(inquiryURLForAttribute);
    }

    return inquiryURL;
  }
  /**
   * initialize a new detail line
   *
   * @return the initialized detail line
   */
  public EffortCertificationDetail createNewDetailLine() {
    EffortCertificationDetail detailLine = new EffortCertificationDetail();
    detailLine.setEffortCertificationUpdatedOverallPercent(null);
    detailLine.setEffortCertificationPayrollAmount(null);
    detailLine.setSubAccountNumber(null);

    return detailLine;
  }
  /**
   * Gets the totalFringeBenefit attribute.
   *
   * @return Returns the totalFringeBenefit.
   */
  public static KualiDecimal getTotalFringeBenefit(
      List<EffortCertificationDetail> effortCertificationDetailLines) {
    KualiDecimal totalFringeBenefit = KualiDecimal.ZERO;

    for (EffortCertificationDetail detailLine : effortCertificationDetailLines) {
      totalFringeBenefit = totalFringeBenefit.add(detailLine.getFringeBenefitAmount());
    }

    return totalFringeBenefit;
  }
  /**
   * calculate the total payroll amount of the given detail lines
   *
   * @param the given detail lines
   * @return Returns the total original payroll amount
   */
  public static KualiDecimal getTotalPersistedPayrollAmount(
      List<EffortCertificationDetail> effortCertificationDetailLines) {
    KualiDecimal totalPayrollAmount = KualiDecimal.ZERO;

    for (EffortCertificationDetail detailLine : effortCertificationDetailLines) {
      totalPayrollAmount = totalPayrollAmount.add(detailLine.getPersistedPayrollAmount());
    }

    return totalPayrollAmount;
  }
  /**
   * calculate the total original effort percent of the given detail lines
   *
   * @param the given detail lines
   * @return Returns the total original effort percent
   */
  public static Integer getTotalOriginalEffortPercent(
      List<EffortCertificationDetail> effortCertificationDetailLines) {
    Integer totalOriginalEffortPercent = 0;

    for (EffortCertificationDetail detailLine : effortCertificationDetailLines) {
      totalOriginalEffortPercent += detailLine.getEffortCertificationCalculatedOverallPercent();
    }

    return totalOriginalEffortPercent;
  }
  /**
   * calculate the total persised effort percent of the given detail lines
   *
   * @param the given detail lines
   * @return Returns the total persisted effort percent
   */
  public static Integer getTotalPersistedEffortPercent(
      List<EffortCertificationDetail> effortCertificationDetailLines) {
    Integer totalEffortPercent = 0;

    for (EffortCertificationDetail detailLine : effortCertificationDetailLines) {
      totalEffortPercent += detailLine.getPersistedEffortPercent();
    }

    return totalEffortPercent;
  }
  /**
   * Gets the fieldInfo attribute.
   *
   * @return Returns the fieldInfo.
   */
  protected List<Map<String, String>> getFieldInfo(List<EffortCertificationDetail> detailLines) {
    LOG.debug("getFieldInfo(List<EffortCertificationDetail>) start");

    List<Map<String, String>> fieldInfo = new ArrayList<Map<String, String>>();
    EffortCertificationDocument document = (EffortCertificationDocument) this.getDocument();
    KualiDecimal totalOriginalPayrollAmount = document.getTotalOriginalPayrollAmount();

    for (EffortCertificationDetail detailLine : detailLines) {
      detailLine.refreshNonUpdateableReferences();

      Map<String, String> fieldInfoForAttribute = new HashMap<String, String>();

      fieldInfoForAttribute.put(
          KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE,
          detailLine.getChartOfAccounts().getFinChartOfAccountDescription());

      String accountInfo = buildAccountInfo(detailLine.getAccount());
      fieldInfoForAttribute.put(KFSPropertyConstants.ACCOUNT_NUMBER, accountInfo);

      SubAccount subAccount = detailLine.getSubAccount();
      if (ObjectUtils.isNotNull(subAccount)) {
        fieldInfoForAttribute.put(
            KFSPropertyConstants.SUB_ACCOUNT_NUMBER, subAccount.getSubAccountName());
      }

      ObjectCode objectCode = detailLine.getFinancialObject();
      if (ObjectUtils.isNotNull(objectCode)) {
        fieldInfoForAttribute.put(
            KFSPropertyConstants.FINANCIAL_OBJECT_CODE, objectCode.getFinancialObjectCodeName());
      }

      Account sourceAccount = detailLine.getSourceAccount();
      if (ObjectUtils.isNotNull(sourceAccount)) {
        fieldInfoForAttribute.put(
            EffortPropertyConstants.SOURCE_ACCOUNT_NUMBER, sourceAccount.getAccountName());
      }

      Chart sourceChart = detailLine.getSourceChartOfAccounts();
      if (ObjectUtils.isNotNull(sourceChart)) {
        fieldInfoForAttribute.put(
            EffortPropertyConstants.SOURCE_CHART_OF_ACCOUNTS_CODE,
            sourceChart.getFinChartOfAccountDescription());
      }

      KualiDecimal originalPayrollAmount = detailLine.getEffortCertificationOriginalPayrollAmount();
      String actualOriginalPercent =
          PayrollAmountHolder.recalculateEffortPercentAsString(
              totalOriginalPayrollAmount, originalPayrollAmount);
      fieldInfoForAttribute.put(
          EffortPropertyConstants.EFFORT_CERTIFICATION_CALCULATED_OVERALL_PERCENT,
          actualOriginalPercent);

      fieldInfo.add(fieldInfoForAttribute);
    }

    return fieldInfo;
  }
  /** recalculate the original fringe benefit of the current detail line */
  public static KualiDecimal calculateFringeBenefit(
      EffortCertificationDetail detailLine, KualiDecimal payrollAmount) {
    LaborModuleService laborModuleService = SpringContext.getBean(LaborModuleService.class);
    Integer fiscalYear = EffortCertificationParameterFinder.getCreateReportFiscalYear();
    String chartOfAccountsCode = detailLine.getChartOfAccountsCode();
    String objectCode = detailLine.getFinancialObjectCode();
    String accountNumber = detailLine.getAccountNumber();
    String subAccountNumber = detailLine.getSubAccountNumber();

    return laborModuleService.calculateFringeBenefit(
        fiscalYear,
        chartOfAccountsCode,
        objectCode,
        payrollAmount,
        accountNumber,
        subAccountNumber);
  }
  /**
   * get the relationship metadata for the detail line fields
   *
   * @return the relationship metadata for the detail line fields
   */
  public Map<String, DataObjectRelationship> getRelationshipMetadata() {
    LOG.debug("getRelationshipMetadata() start");

    PersistenceStructureService persistenceStructureService =
        SpringContext.getBean(PersistenceStructureService.class);

    Map<String, DataObjectRelationship> relationshipMetadata =
        new HashMap<String, DataObjectRelationship>();
    for (String attributeName : this.getInquirableFieldNames()) {
      Map<String, Class<? extends BusinessObject>> primitiveReference =
          LookupUtils.getPrimitiveReference(newDetailLine, attributeName);

      if (primitiveReference != null && !primitiveReference.isEmpty()) {
        DataObjectRelationship primitiveRelationship =
            this.getPrimitiveDataObjectRelationship(
                persistenceStructureService.getRelationshipMetadata(
                    newDetailLine.getClass(), attributeName));
        relationshipMetadata.put(attributeName, primitiveRelationship);
      }
    }

    return relationshipMetadata;
  }
 /** recalculate the original fringe benefit of the current detail line */
 public void recalculateOriginalFringeBenefit() {
   KualiDecimal originalPayrollAmount = this.getEffortCertificationOriginalPayrollAmount();
   KualiDecimal fringeBenefit =
       EffortCertificationDetail.calculateFringeBenefit(this, originalPayrollAmount);
   this.setOriginalFringeBenefitAmount(fringeBenefit);
 }
  /**
   * Gets the fringeBenefitAmount attribute.
   *
   * @return Returns the fringeBenefitAmount.
   */
  public KualiDecimal getFringeBenefitAmount() {
    KualiDecimal payrollAmount = this.getEffortCertificationPayrollAmount();

    return EffortCertificationDetail.calculateFringeBenefit(this, payrollAmount);
  }
 public EffortCertificationDetail(EffortCertificationDetail effortCertificationDetail) {
   super();
   if (effortCertificationDetail != null) {
     this.chartOfAccountsCode = effortCertificationDetail.getChartOfAccountsCode();
     this.accountNumber = effortCertificationDetail.getAccountNumber();
     this.subAccountNumber = effortCertificationDetail.getSubAccountNumber();
     this.positionNumber = effortCertificationDetail.getPositionNumber();
     this.financialObjectCode = effortCertificationDetail.getFinancialObjectCode();
     this.sourceChartOfAccountsCode = effortCertificationDetail.getSourceChartOfAccountsCode();
     this.sourceAccountNumber = effortCertificationDetail.getSourceAccountNumber();
     this.effortCertificationPayrollAmount =
         effortCertificationDetail.getEffortCertificationPayrollAmount();
     this.effortCertificationCalculatedOverallPercent =
         effortCertificationDetail.getEffortCertificationCalculatedOverallPercent();
     this.effortCertificationUpdatedOverallPercent =
         effortCertificationDetail.getEffortCertificationUpdatedOverallPercent();
     this.universityFiscalYear = effortCertificationDetail.getUniversityFiscalYear();
     this.costShareSourceSubAccountNumber =
         effortCertificationDetail.getCostShareSourceSubAccountNumber();
     this.effortCertificationOriginalPayrollAmount =
         effortCertificationDetail.getEffortCertificationOriginalPayrollAmount();
     this.originalFringeBenefitAmount = effortCertificationDetail.getOriginalFringeBenefitAmount();
     this.effectiveDate = effortCertificationDetail.getEffectiveDate();
   }
 }