/**
   * Sets the Milestone in the passed in section to be readonly if it has been copied to a CG
   * Invoice doc.
   *
   * @param section Milestone section to review and possibly set readonly
   * @param proposalNumber used to look for CG Invoice docs
   */
  private void prepareMilestonesTab(Section section, Long proposalNumber) {
    ContractsGrantsInvoiceDocumentService cgInvDocService =
        SpringContext.getBean(ContractsGrantsInvoiceDocumentService.class);

    for (Row row : section.getRows()) {
      for (Field field : row.getFields()) {
        if (field.getCONTAINER().equalsIgnoreCase(field.getFieldType())) {
          for (Row containerRow : field.getContainerRows()) {
            for (Field containerRowfield : containerRow.getFields()) {
              // a record is no longer editable if the bill has been copied to a CINV doc
              if (ObjectUtils.getNestedAttributePrimitive(containerRowfield.getPropertyName())
                  .matches(ArPropertyConstants.MilestoneFields.MILESTONE_IDENTIFIER)) {
                String milestoneId = containerRowfield.getPropertyValue();
                if (StringUtils.isNotEmpty(milestoneId)) {
                  if (cgInvDocService.hasMilestoneBeenCopiedToInvoice(
                      proposalNumber, milestoneId)) {
                    for (Field rowfield : row.getFields()) {
                      if (rowfield.getCONTAINER().equalsIgnoreCase(rowfield.getFieldType())) {
                        for (Row fieldContainerRow : rowfield.getContainerRows()) {
                          for (Field fieldContainerRowField : fieldContainerRow.getFields()) {
                            fieldContainerRowField.setReadOnly(true);
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
 /**
  * @see
  *     org.kuali.kfs.sys.document.web.RenderableElement#renderElement(javax.servlet.jsp.PageContext,
  *     javax.servlet.jsp.tagext.Tag,
  *     org.kuali.kfs.sys.document.web.AccountingLineRenderingContext)
  */
 public void renderElement(
     PageContext pageContext, Tag parentTag, AccountingLineRenderingContext renderingContext)
     throws JspException {
   if (!renderingContext.isFieldModifyable(debitOrCreditField.getPropertyName())) {
     debitOrCreditField.setReadOnly(true);
   }
   FieldRenderer renderer =
       SpringContext.getBean(AccountingLineRenderingService.class)
           .getFieldRendererForField(
               getDebitOrCreditField(), renderingContext.getAccountingLine());
   if (renderer != null) {
     prepareFieldForRendering(
         getDebitOrCreditField(),
         (VoucherForm) renderingContext.getForm(),
         renderingContext.getCurrentLineCount());
     renderer.setField(getDebitOrCreditField());
     renderer.render(pageContext, parentTag);
     renderer.clear();
   }
 }