/**
  * 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());
 }