Ejemplo n.º 1
0
 /* @Override
 public Set<String> getUnviewableBlocks(AccountingDocument accountingDocument, AccountingLine accountingLine, boolean newLine, Person currentUser) {
     Set<String> unviewableBlocks = super.getUnviewableBlocks(accountingDocument, accountingLine, newLine, currentUser);
     if (showAmountOnly(accountingDocument)) {
         unviewableBlocks.add(OLEPropertyConstants.PERCENT);
     }
     else {
         unviewableBlocks.add(OLEPropertyConstants.AMOUNT);
     }
     return unviewableBlocks;
 }*/
 private boolean showAmountOnly(AccountingDocument accountingDocument) {
   PurapService purapService = SpringContext.getBean(PurapService.class);
   if (accountingDocument instanceof PurchasingAccountsPayableDocument)
     if (purapService.isFullDocumentEntryCompleted(
         (PurchasingAccountsPayableDocument) accountingDocument)) {
       return true;
     }
   return false;
 }
  /**
   * Validates that the given accounting line is accessible for editing by the current user.
   * <strong>This method expects a document as the first parameter and an accounting line as the
   * second</strong>
   *
   * @see org.kuali.ole.sys.document.validation.Validation#validate(java.lang.Object[])
   */
  @Override
  public boolean validate(AttributedDocumentEvent event) {

    if (purapService.isDocumentStoppedInRouteNode(
        (PurchasingAccountsPayableDocument) event.getDocument(), "New Unordered Items")) {
      // DO NOTHING: do not check that user owns acct lines; at this level, they can edit all
      // accounts on PO amendment
      return true;

    } else if (SpringContext.getBean(FinancialSystemWorkflowHelperService.class)
        .isAdhocApprovalRequestedForPrincipal(
            event.getDocument().getDocumentHeader().getWorkflowDocument(),
            GlobalVariables.getUserSession().getPrincipalId())) {
      return true;
    } else {
      boolean result = false;
      boolean setDummyAccountIdentifier = false;

      if (needsDummyAccountIdentifier()) {
        ((PurApAccountingLine) getAccountingLineForValidation())
            .setAccountIdentifier(
                Integer.MAX_VALUE); // avoid conflicts with any accouting identifier on any other
        // accounting lines in the doc because, you know, you never know...
        setDummyAccountIdentifier = true;
      }

      result = super.validate(event);

      if (setDummyAccountIdentifier) {
        ((PurApAccountingLine) getAccountingLineForValidation()).setAccountIdentifier(null);
      }

      return result;
    }
  }