/**
   * Sets the encumbrance code of the line based on the balance type.
   *
   * @param sourceLine - line to set code on
   */
  protected void populateSourceAccountingLineEncumbranceCode(SourceAccountingLine sourceLine) {
    BalanceType selectedBalanceType = getSelectedBalanceType();
    if (ObjectUtils.isNotNull(selectedBalanceType)) {
      selectedBalanceType.refresh();
      sourceLine.setBalanceTyp(selectedBalanceType);
      sourceLine.setBalanceTypeCode(selectedBalanceType.getCode());

      // set the encumbrance update code appropriately
      // KFSMI-5565 remove the default encumbrance code
      // no more default encumbrance code
      //            if
      // (KFSConstants.BALANCE_TYPE_EXTERNAL_ENCUMBRANCE.equals(selectedBalanceType.getCode())) {
      //
      // sourceLine.setEncumbranceUpdateCode(KFSConstants.JOURNAL_VOUCHER_ENCUMBRANCE_UPDATE_CODE_BALANCE_TYPE_EXTERNAL_ENCUMBRANCE);
      //            }
      //            else {
      //                sourceLine.setEncumbranceUpdateCode(null);
      //            }
    } else {
      // it's the first time in, the form will be empty the first time in
      // set up default selection value
      selectedBalanceType = getPopulatedBalanceTypeInstance(KFSConstants.BALANCE_TYPE_ACTUAL);
      setSelectedBalanceType(selectedBalanceType);
      setOriginalBalanceType(selectedBalanceType.getCode());

      sourceLine.setEncumbranceUpdateCode(null);
    }
  }