@Override
  public void recalculateCustomerCreditMemoDocument(
      CustomerCreditMemoDocument customerCreditMemoDocument,
      boolean blanketApproveDocumentEventFlag) {
    KualiDecimal customerCreditMemoDetailItemAmount;
    BigDecimal itemQuantity;

    String invDocumentNumber =
        customerCreditMemoDocument.getFinancialDocumentReferenceInvoiceNumber();
    List<CustomerCreditMemoDetail> customerCreditMemoDetails =
        customerCreditMemoDocument.getCreditMemoDetails();

    if (!blanketApproveDocumentEventFlag) {
      customerCreditMemoDocument.resetTotals();
    }

    for (CustomerCreditMemoDetail customerCreditMemoDetail : customerCreditMemoDetails) {
      // no data entered for the current credit memo detail -> no processing needed
      itemQuantity = customerCreditMemoDetail.getCreditMemoItemQuantity();
      customerCreditMemoDetailItemAmount = customerCreditMemoDetail.getCreditMemoItemTotalAmount();
      if (ObjectUtils.isNull(itemQuantity)
          && ObjectUtils.isNull(customerCreditMemoDetailItemAmount)) {
        if (!blanketApproveDocumentEventFlag) {
          customerCreditMemoDetail.setDuplicateCreditMemoItemTotalAmount(null);
        }
        continue;
      }

      // if item amount was entered, it takes precedence, if not, use the item quantity to re-calc
      // amount
      if (ObjectUtils.isNotNull(customerCreditMemoDetailItemAmount)) {
        customerCreditMemoDetail.recalculateBasedOnEnteredItemAmount(customerCreditMemoDocument);
      } // if item quantity was entered
      else {
        customerCreditMemoDetail.recalculateBasedOnEnteredItemQty(customerCreditMemoDocument);
        if (!blanketApproveDocumentEventFlag) {
          customerCreditMemoDetailItemAmount =
              customerCreditMemoDetail.getCreditMemoItemTotalAmount();
        }
      }

      if (!blanketApproveDocumentEventFlag) {
        customerCreditMemoDetail.setDuplicateCreditMemoItemTotalAmount(
            customerCreditMemoDetailItemAmount);
        boolean isCustomerInvoiceDetailTaxable =
            accountsReceivableTaxService.isCustomerInvoiceDetailTaxable(
                customerCreditMemoDocument.getInvoice(),
                customerCreditMemoDetail.getCustomerInvoiceDetail());
        customerCreditMemoDocument.recalculateTotals(
            customerCreditMemoDetailItemAmount, isCustomerInvoiceDetailTaxable);
      }
    }

    //  force the docHeader docTotal
    customerCreditMemoDocument
        .getFinancialSystemDocumentHeader()
        .setFinancialDocumentTotalAmount(customerCreditMemoDocument.getCrmTotalAmount());
  }
  @Override
  public boolean isThereNoDataToSubmit(CustomerCreditMemoDocument customerCreditMemoDocument) {
    boolean isSuccess = true;
    KualiDecimal customerCreditMemoDetailItemAmount;
    BigDecimal itemQuantity;
    List<CustomerCreditMemoDetail> customerCreditMemoDetails =
        customerCreditMemoDocument.getCreditMemoDetails();

    for (CustomerCreditMemoDetail customerCreditMemoDetail : customerCreditMemoDetails) {
      // no data entered for the current credit memo detail -> no processing needed
      itemQuantity = customerCreditMemoDetail.getCreditMemoItemQuantity();
      customerCreditMemoDetailItemAmount = customerCreditMemoDetail.getCreditMemoItemTotalAmount();
      if (ObjectUtils.isNotNull(itemQuantity)
          || ObjectUtils.isNotNull(customerCreditMemoDetailItemAmount)) {
        isSuccess = false;
        break;
      }
    }
    return isSuccess;
  }