/**
   * @see
   *     org.kuali.rice.kns.maintenance.KualiMaintainableImpl#doRouteStatusChange(org.kuali.rice.kns.bo.DocumentHeader)
   */
  @Override
  public void doRouteStatusChange(DocumentHeader documentHeader) {
    if (documentHeader.getWorkflowDocument().isProcessed()) {
      AgencyStagingData agencyStaging = (AgencyStagingData) getBusinessObject();

      updateCreditCardAgency(agencyStaging);

      // All validations have passed at this point. Set error code to 'OK'.
      agencyStaging.setErrorCode(AgencyStagingDataErrorCodes.AGENCY_NO_ERROR);

      // after fixing the agency audit record, attempt to move agency data to historical table
      List<ErrorMessage> errors =
          getAgencyDataImportService()
              .processAgencyStagingExpense(
                  agencyStaging, getGeneralLedgerPendingEntrySequenceHelper());
      LOG.info(
          "Agency Data Id: "
              + agencyStaging.getId()
              + (errors.isEmpty() ? " was" : " was not")
              + " processed.");

      // add a Note if there were errors reconciling or distributing the record
      if (!errors.isEmpty()) {
        try {
          MaintenanceDocument document =
              (MaintenanceDocument)
                  getDocumentService().getByDocumentHeaderId(documentHeader.getDocumentNumber());
          addNoteAfterProcessingAgencyStagingExpense(document, errors);
        } catch (WorkflowException exception) {
          LOG.error(
              "Unable to add Note to Document Id: " + documentHeader.getDocumentNumber(),
              exception);
          LOG.error(getMessageAsString(errors));
        }
      }

      // nota bene: agency staging data object does NOT need to be saved here as the maint doc will
      // save it itself once processing completes

    }
    super.doRouteStatusChange(documentHeader);
  }