/**
  * Adding the role qualifications for the processing chart and organization
  *
  * @see
  *     org.kuali.rice.kns.document.authorization.DocumentAuthorizerBase#addRoleQualification(org.kuali.rice.kns.bo.BusinessObject,
  *     java.util.Map)
  */
 @Override
 protected void addRoleQualification(Object businessObject, Map<String, String> attributes) {
   super.addRoleQualification(businessObject, attributes);
   if (businessObject != null && businessObject instanceof PaymentApplicationDocument) {
     final PaymentApplicationDocument document = (PaymentApplicationDocument) businessObject;
     final WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
     if (workflowDocument.isInitiated()
         || workflowDocument.isSaved()
         || workflowDocument
             .isCompletionRequested()) { // only add processing chart and org if we're PreRoute
       final AccountsReceivableDocumentHeader arDocumentHeader =
           document.getAccountsReceivableDocumentHeader();
       if (!ObjectUtils.isNull(arDocumentHeader)) {
         if (!StringUtils.isBlank(arDocumentHeader.getProcessingChartOfAccCodeAndOrgCode())) {
           attributes.put(
               KfsKimAttributes.CHART_OF_ACCOUNTS_CODE,
               arDocumentHeader.getProcessingChartOfAccountCode());
         }
         if (!StringUtils.isBlank(arDocumentHeader.getProcessingOrganizationCode())) {
           attributes.put(
               KfsKimAttributes.ORGANIZATION_CODE,
               arDocumentHeader.getProcessingOrganizationCode());
         }
       }
     }
   }
 }
  @Override
  protected void addRoleQualification(Object businessObject, Map<String, String> attributes) {
    super.addRoleQualification(businessObject, attributes);

    CustomerInvoiceWriteoffDocument writeoffDoc = (CustomerInvoiceWriteoffDocument) businessObject;
    String invoiceDocNumber = writeoffDoc.getFinancialDocumentReferenceInvoiceNumber();
    if (StringUtils.isBlank(invoiceDocNumber)) {
      return;
    }
    CustomerInvoiceDocumentService invoiceService =
        SpringContext.getBean(CustomerInvoiceDocumentService.class);

    Collection<CustomerInvoiceDetail> invoiceDetails =
        invoiceService.getCustomerInvoiceDetailsForCustomerInvoiceDocument(invoiceDocNumber);

    //  adds the chart/account for each account used on the original invoice that will be credited
    // by this
    for (CustomerInvoiceDetail invoiceDetail : invoiceDetails) {
      if (StringUtils.isNotBlank(invoiceDetail.getChartOfAccountsCode())
          && StringUtils.isNotBlank(invoiceDetail.getAccountNumber())) {
        attributes.put(
            KfsKimAttributes.CHART_OF_ACCOUNTS_CODE, invoiceDetail.getChartOfAccountsCode());
        attributes.put(KfsKimAttributes.ACCOUNT_NUMBER, invoiceDetail.getAccountNumber());
      }
    }
  }
 @Override
 protected void addRoleQualification(Object dataObject, Map<String, String> attributes) {
   super.addRoleQualification(dataObject, attributes);
   IWantDocument iWantDocument = (IWantDocument) dataObject;
   attributes.put(KfsKimAttributes.CHART_OF_ACCOUNTS_CODE, iWantDocument.getRoutingChart());
   attributes.put(KfsKimAttributes.ORGANIZATION_CODE, iWantDocument.getRoutingOrganization());
 }
  protected HtmlData getTransferUrl(Asset asset) {
    boolean isAuthorized = true;
    boolean assetMovable = false;
    try {
      assetMovable = getAssetService().isAssetMovableCheckByPayment(asset);
    } catch (ValidationException ve) {
      isAuthorized = false;
    }
    if (!assetMovable) {
      FinancialSystemTransactionalDocumentAuthorizerBase documentAuthorizer =
          (FinancialSystemTransactionalDocumentAuthorizerBase)
              SpringContext.getBean(DocumentDictionaryService.class)
                  .getDocumentAuthorizer(CamsConstants.DocumentTypeName.ASSET_TRANSFER);
      isAuthorized =
          documentAuthorizer.isAuthorized(
              asset,
              CamsConstants.CAM_MODULE_CODE,
              CamsConstants.PermissionNames.SEPARATE,
              GlobalVariables.getUserSession().getPerson().getPrincipalId());
    }

    if (isAuthorized) {
      Properties parameters = new Properties();
      parameters.put(KFSConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.DOC_HANDLER_METHOD);
      parameters.put(
          CamsPropertyConstants.AssetTransferDocument.CAPITAL_ASSET_NUMBER,
          asset.getCapitalAssetNumber().toString());
      parameters.put(KFSConstants.PARAMETER_COMMAND, "initiate");
      parameters.put(
          KFSConstants.DOCUMENT_TYPE_NAME, CamsConstants.DocumentTypeName.ASSET_TRANSFER);

      String href =
          UrlFactory.parameterizeUrl(
              CamsConstants.StrutsActions.ONE_UP + CamsConstants.StrutsActions.TRANSFER,
              parameters);

      return new AnchorHtmlData(
          href, KRADConstants.DOC_HANDLER_METHOD, CamsConstants.AssetActions.TRANSFER);
    } else {
      return new AnchorHtmlData("", "", "");
    }
  }