예제 #1
0
  /**
   * 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;
  }
예제 #2
0
  /**
   * Validates the sub account of the origin entry
   *
   * @param originEntry the origin entry being scrubbed
   * @param workingEntry the scrubbed version of the origin entry
   * @return a Message if an error was encountered, otherwise null
   */
  protected Message validateSubAccount(
      LaborOriginEntry originEntry,
      LaborOriginEntry workingEntry,
      LaborAccountingCycleCachingService laborAccountingCycleCachingService) {
    LOG.debug("validateSubAccount() started");

    // when continuationAccount used, the subAccountNumber should be changed to dashes and skip
    // validation subAccount process
    if (continuationAccountIndicator) {
      workingEntry.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
      return null;
    }

    // If the sub account number is empty, set it to dashes.
    // Otherwise set the workingEntry sub account number to the
    // sub account number of the input origin entry.
    if (org.springframework.util.StringUtils.hasText(originEntry.getSubAccountNumber())) {
      // sub account IS specified
      if (!KFSConstants.getDashSubAccountNumber().equals(originEntry.getSubAccountNumber())) {
        SubAccount originEntrySubAccount =
            laborAccountingCycleCachingService.getSubAccount(
                originEntry.getChartOfAccountsCode(),
                originEntry.getAccountNumber(),
                originEntry.getSubAccountNumber());
        // SubAccount originEntrySubAccount = getSubAccount(originEntry);
        if (originEntrySubAccount == null) {
          // sub account is not valid
          return MessageBuilder.buildMessage(
              KFSKeyConstants.ERROR_SUB_ACCOUNT_NOT_FOUND,
              originEntry.getChartOfAccountsCode()
                  + "-"
                  + originEntry.getAccountNumber()
                  + "-"
                  + originEntry.getSubAccountNumber(),
              Message.TYPE_FATAL);
        } else {
          // sub account IS valid
          if (originEntrySubAccount.isActive()) {
            // sub account IS active
            workingEntry.setSubAccountNumber(originEntry.getSubAccountNumber());
          } else {
            // sub account IS NOT active
            if (parameterService
                .getParameterValueAsString(
                    KfsParameterConstants.GENERAL_LEDGER_BATCH.class,
                    KFSConstants.SystemGroupParameterNames.GL_ANNUAL_CLOSING_DOC_TYPE)
                .equals(originEntry.getFinancialDocumentTypeCode())) {
              // document IS annual closing
              workingEntry.setSubAccountNumber(originEntry.getSubAccountNumber());
            } else {
              // document is NOT annual closing
              return MessageBuilder.buildMessage(
                  KFSKeyConstants.ERROR_SUB_ACCOUNT_NOT_ACTIVE,
                  originEntry.getChartOfAccountsCode()
                      + "-"
                      + originEntry.getAccountNumber()
                      + "-"
                      + originEntry.getSubAccountNumber(),
                  Message.TYPE_FATAL);
            }
          }
        }
      } else {
        // the sub account is dashes
        workingEntry.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
      }
    } else {
      // No sub account is specified.
      workingEntry.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
    }

    return null;
  }