public boolean isConsideredEntered() {
   // if all are not null then return true
   return !((ObjectUtils.isNull(this.getItemReceivedTotalQuantity())
           || this.getItemReceivedTotalQuantity().isZero())
       && (ObjectUtils.isNull(this.getItemDamagedTotalQuantity())
           || this.getItemDamagedTotalQuantity().isZero())
       && (ObjectUtils.isNull(this.getItemReturnedTotalQuantity())
           || this.getItemReturnedTotalQuantity().isZero()));
 }
  public boolean processSyncModularBusinessRules(Document document) {
    if (!(document instanceof BudgetDocument)) {
      return false;
    }

    boolean valid = true;

    BudgetDocument budgetDocument = (BudgetDocument) document;

    GlobalVariables.getErrorMap().addToErrorPath("document");

    List budgetPeriods = budgetDocument.getBudget().getBudgetPeriods();
    if (ObjectUtils.isNotNull(budgetPeriods) || budgetPeriods.size() >= 1) {
      BudgetPeriod period1 = (BudgetPeriod) budgetPeriods.get(0);
      if (ObjectUtils.isNull(period1.getBudgetLineItems())
          || period1.getBudgetLineItems().isEmpty()) {
        valid = false;
      }
    } else {
      valid = false;
    }

    if (!valid) {
      GlobalVariables.getErrorMap()
          .putError("modularBudget", KeyConstants.ERROR_NO_DETAILED_BUDGET);
    }

    GlobalVariables.getErrorMap().removeFromErrorPath("document");

    return valid;
  }
 public UnitOfMeasure getItemUnitOfMeasure() {
   if (ObjectUtils.isNull(itemUnitOfMeasure)
       || (!itemUnitOfMeasure
           .getItemUnitOfMeasureCode()
           .equalsIgnoreCase(getItemUnitOfMeasureCode()))) {
     refreshReferenceObject(PurapPropertyConstants.ITEM_UNIT_OF_MEASURE);
   }
   return itemUnitOfMeasure;
 }
  /**
   * @see
   *     org.kuali.kfs.sys.document.service.impl.AccountingLineRuleHelperServiceImpl#isValidAccount(org.kuali.kfs.coa.businessobject.Account,
   *     org.kuali.rice.kns.datadictionary.DataDictionary, java.lang.String)
   */
  @Override
  public boolean isValidAccount(
      Account account, DataDictionary dataDictionary, String errorPropertyName) {
    String label = getAccountLabel();

    // make sure it exists
    if (ObjectUtils.isNull(account)) {
      GlobalVariables.getMessageMap()
          .putError(errorPropertyName, KFSKeyConstants.ERROR_EXISTENCE, label);
      return false;
    }

    return true;
  }
  @Override
  protected boolean processCustomSaveDocumentBusinessRules(Document document) {
    if (!(document instanceof BudgetDocument)) {
      return false;
    }

    boolean valid = true;

    BudgetDocument budgetDocument = (BudgetDocument) document;

    GlobalVariables.getErrorMap().addToErrorPath("document");
    getDictionaryValidationService()
        .validateDocumentAndUpdatableReferencesRecursively(
            document,
            getMaxDictionaryValidationDepth(),
            VALIDATION_REQUIRED,
            CHOMP_LAST_LETTER_S_FROM_COLLECTION_NAME);
    GlobalVariables.getErrorMap().addToErrorPath("parentDocument");
    if (ObjectUtils.isNull(budgetDocument.getParentDocument())) {
      budgetDocument.refreshReferenceObject("parentDocument");
    }
    if (Boolean.valueOf(budgetDocument.getParentDocument().getProposalBudgetFlag())) {
      valid &= processBudgetVersionsBusinessRule(budgetDocument.getParentDocument(), true);
    }
    //        else {
    //            valid &= processBudgetTypeBusinessRules(budgetDocument);
    //        }
    GlobalVariables.getErrorMap().removeFromErrorPath("parentDocument");

    GlobalVariables.getErrorMap().addToErrorPath("budget");
    valid &= processBudgetPersonnelBusinessRules(budgetDocument);

    valid &= processBudgetExpenseBusinessRules(budgetDocument);

    valid &= processBudgetPersonnelBudgetBusinessRules(budgetDocument);

    valid &= processBudgetRatesBusinessRule(budgetDocument);

    valid &= processBudgetProjectIncomeBusinessRule(budgetDocument);

    GlobalVariables.getErrorMap().removeFromErrorPath("budget");
    GlobalVariables.getErrorMap().removeFromErrorPath("document");

    return valid;
  }
Beispiel #6
0
 /** @see org.kuali.ext.mm.b2b.cxml.invoice.B2bInvoice#validate() */
 @Override
 public B2bInvoiceStatus validate() {
   B2bInvoiceStatus invoiceStatus = validateCommon();
   if (!invoiceStatus.isValid()) {
     return invoiceStatus;
   }
   MMDecimal invoiceSum = MMDecimal.ZERO;
   for (B2bInvoiceDetail detail : getDetails()) {
     invoiceSum = invoiceSum.add(detail.getNetAmount());
     if (detail.getAccounts().isEmpty()) {
       return new B2bInvoiceStatus(
           false,
           "406",
           "Not Acceptable",
           "Accounting distribution is missing for item : " + detail.getSupplierPartId());
     }
     for (B2bInvoiceAccount acct : detail.getAccounts()) {
       if (ObjectUtils.isNull(acct.matchingAccount())) {
         return new B2bInvoiceStatus(
             false,
             "417",
             "Expectation failed.",
             "AccountingSegment Id: [" + acct.getId() + "] is not valid.");
       }
     }
   }
   if (!getDueAmount().equals(invoiceSum)) {
     return new B2bInvoiceStatus(
         false,
         "417",
         "Expectation failed.",
         "Sum of Invoice Detail Amount :"
             + invoiceSum
             + " didnt match total Due Amount:"
             + getDueAmount().toString());
   }
   return invoiceStatus;
 }
  /**
   * build the descriptive information of the given account. The information includes account name
   * and project director's name if any
   *
   * @param chartOfAccountsCode the given chart of accounts code
   * @param accountNumber the given account number
   * @return the descriptive information of the given account
   */
  public static String buildAccountInfo(Account account) {
    if (ObjectUtils.isNull(account)) {
      return KFSConstants.EMPTY_STRING;
    }

    String projectDirectorName = KFSConstants.EMPTY_STRING;

    try {
      ContractsAndGrantsModuleService contractsAndGrantsModuleService =
          SpringContext.getBean(ContractsAndGrantsModuleService.class);
      Person projectDirector =
          contractsAndGrantsModuleService.getProjectDirectorForAccount(account);

      projectDirectorName =
          projectDirector != null
              ? MessageFormat.format("  ({0})", projectDirector.getName())
              : KFSConstants.EMPTY_STRING;
    } catch (Exception e) {
      LOG.error("Cannot find a project director for the account:" + account);
    }

    return MessageFormat.format("{0}{1}", account.getAccountName(), projectDirectorName);
  }
 /**
  * Gets the itemType attribute.
  *
  * @return Returns the itemType.
  */
 public ItemType getItemType() {
   if (ObjectUtils.isNull(itemType)) {
     refreshReferenceObject(PurapPropertyConstants.ITEM_TYPE);
   }
   return itemType;
 }
  /**
   * Validates a definition assignment to the principal
   *
   * @param principalDefinition SecurityPrincipalDefinition to validate
   * @param errorKeyPrefix String errorPrefix to use if any errors are found
   * @return boolean true if validation was successful, false if there are errors
   */
  protected boolean validatePrincipalDefinition(
      SecurityPrincipalDefinition principalDefinition, String errorKeyPrefix) {
    boolean isValid = true;

    principalDefinition.refreshNonUpdateableReferences();

    if (ObjectUtils.isNull(principalDefinition.getSecurityDefinition())) {
      return false;
    }

    String attributeName =
        principalDefinition.getSecurityDefinition().getSecurityAttribute().getName();
    String attributeValue = principalDefinition.getAttributeValue();

    // if value is blank (which is allowed) no need to validate
    if (StringUtils.isBlank(attributeValue)) {
      return true;
    }

    // descend attributes do not allow multiple values or wildcards, and operator must be equal
    if (SecConstants.SecurityAttributeNames.CHART_DESCEND_HIERARCHY.equals(attributeName)
        || SecConstants.SecurityAttributeNames.ORGANIZATION_DESCEND_HIERARCHY.equals(
            attributeName)) {
      if (StringUtils.contains(
          attributeValue,
          SecConstants.SecurityValueSpecialCharacters.MULTI_VALUE_SEPERATION_CHARACTER)) {
        GlobalVariables.getMessageMap()
            .putError(
                errorKeyPrefix + SecPropertyConstants.ATTRIBUTE_VALUE,
                SecKeyConstants.ERROR_MODEL_DEFINITION_MULTI_ATTR_VALUE,
                attributeName);
        isValid = false;
      }

      if (StringUtils.contains(
          attributeValue, SecConstants.SecurityValueSpecialCharacters.WILDCARD_CHARACTER)) {
        GlobalVariables.getMessageMap()
            .putError(
                errorKeyPrefix + SecPropertyConstants.ATTRIBUTE_VALUE,
                SecKeyConstants.ERROR_MODEL_DEFINITION_WILDCARD_ATTR_VALUE,
                attributeName);
        isValid = false;
      }

      if (!SecConstants.SecurityDefinitionOperatorCodes.EQUAL.equals(
          principalDefinition.getOperatorCode())) {
        GlobalVariables.getMessageMap()
            .putError(
                errorKeyPrefix + SecPropertyConstants.OPERATOR_CODE,
                SecKeyConstants.ERROR_MODEL_DEFINITION_OPERATOR_CODE_NOT_EQUAL,
                attributeName);
        isValid = false;
      }
    }

    // validate attribute value for existence
    isValid =
        isValid
            && SecurityValidationUtil.validateAttributeValue(
                attributeName, attributeValue, errorKeyPrefix);

    return isValid;
  }