@Override
    public JournalEntryData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum)
        throws SQLException {

      final Long id = rs.getLong("id");
      final Long officeId = rs.getLong("officeId");
      final String officeName = rs.getString("officeName");
      final String glCode = rs.getString("glAccountCode");
      final String glAccountName = rs.getString("glAccountName");
      final Long glAccountId = rs.getLong("glAccountId");
      final int accountTypeId = JdbcSupport.getInteger(rs, "classification");
      final EnumOptionData accountType = AccountingEnumerations.gLAccountType(accountTypeId);
      final LocalDate transactionDate = JdbcSupport.getLocalDate(rs, "transactionDate");
      final Boolean manualEntry = rs.getBoolean("manualEntry");
      final BigDecimal amount = rs.getBigDecimal("amount");
      final int entryTypeId = JdbcSupport.getInteger(rs, "entryType");
      final EnumOptionData entryType = AccountingEnumerations.journalEntryType(entryTypeId);
      final String transactionId = rs.getString("transactionId");
      final Integer entityTypeId = JdbcSupport.getInteger(rs, "entityType");
      EnumOptionData entityType = null;
      if (entityTypeId != null) {
        entityType = AccountingEnumerations.portfolioProductType(entityTypeId);
      }

      final Long entityId = JdbcSupport.getLong(rs, "entityId");
      final Long createdByUserId = rs.getLong("createdByUserId");
      final LocalDate createdDate = JdbcSupport.getLocalDate(rs, "createdDate");
      final String createdByUserName = rs.getString("createdByUserName");
      final String comments = rs.getString("comments");
      final Boolean reversed = rs.getBoolean("reversed");
      final String referenceNumber = rs.getString("referenceNumber");
      BigDecimal officeRunningBalance = null;
      BigDecimal organizationRunningBalance = null;
      Boolean runningBalanceComputed = null;

      final String currencyCode = rs.getString("currencyCode");
      final String currencyName = rs.getString("currencyName");
      final String currencyNameCode = rs.getString("currencyNameCode");
      final String currencyDisplaySymbol = rs.getString("currencyDisplaySymbol");
      final Integer currencyDigits = JdbcSupport.getInteger(rs, "currencyDigits");
      final Integer inMultiplesOf = JdbcSupport.getInteger(rs, "inMultiplesOf");
      final CurrencyData currency =
          new CurrencyData(
              currencyCode,
              currencyName,
              currencyDigits,
              inMultiplesOf,
              currencyDisplaySymbol,
              currencyNameCode);

      if (associationParametersData.isRunningBalanceRequired()) {
        officeRunningBalance = rs.getBigDecimal("officeRunningBalance");
        organizationRunningBalance = rs.getBigDecimal("organizationRunningBalance");
        runningBalanceComputed = rs.getBoolean("runningBalanceComputed");
      }
      TransactionDetailData transactionDetailData = null;

      if (associationParametersData.isTransactionDetailsRequired()) {
        PaymentDetailData paymentDetailData = null;
        final Long paymentTypeId = JdbcSupport.getLong(rs, "paymentTypeId");
        if (paymentTypeId != null) {
          final String typeName = rs.getString("paymentTypeName");
          final PaymentTypeData paymentType = PaymentTypeData.instance(paymentTypeId, typeName);
          final String accountNumber = rs.getString("accountNumber");
          final String checkNumber = rs.getString("checkNumber");
          final String routingCode = rs.getString("routingCode");
          final String receiptNumber = rs.getString("receiptNumber");
          final String bankNumber = rs.getString("bankNumber");
          paymentDetailData =
              new PaymentDetailData(
                  id,
                  paymentType,
                  accountNumber,
                  checkNumber,
                  routingCode,
                  receiptNumber,
                  bankNumber);
        }
        NoteData noteData = null;
        final Long noteId = JdbcSupport.getLong(rs, "noteId");
        if (noteId != null) {
          final String note = rs.getString("transactionNote");
          noteData =
              new NoteData(
                  noteId, null, null, null, null, null, null, null, note, null, null, null, null,
                  null, null);
        }
        Long transaction = null;
        if (entityType != null) {
          transaction = Long.parseLong(transactionId.substring(1).trim());
        }

        TransactionTypeEnumData transactionTypeEnumData = null;

        if (PortfolioAccountType.fromInt(entityTypeId).isLoanAccount()) {
          final LoanTransactionEnumData loanTransactionType =
              LoanEnumerations.transactionType(JdbcSupport.getInteger(rs, "loanTransactionType"));
          transactionTypeEnumData =
              new TransactionTypeEnumData(
                  loanTransactionType.id(),
                  loanTransactionType.getCode(),
                  loanTransactionType.getValue());
        } else if (PortfolioAccountType.fromInt(entityTypeId).isSavingsAccount()) {
          final SavingsAccountTransactionEnumData savingsTransactionType =
              SavingsEnumerations.transactionType(
                  JdbcSupport.getInteger(rs, "savingsTransactionType"));
          transactionTypeEnumData =
              new TransactionTypeEnumData(
                  savingsTransactionType.getId(),
                  savingsTransactionType.getCode(),
                  savingsTransactionType.getValue());
        }

        transactionDetailData =
            new TransactionDetailData(
                transaction, paymentDetailData, noteData, transactionTypeEnumData);
      }
      return new JournalEntryData(
          id,
          officeId,
          officeName,
          glAccountName,
          glAccountId,
          glCode,
          accountType,
          transactionDate,
          entryType,
          amount,
          transactionId,
          manualEntry,
          entityType,
          entityId,
          createdByUserId,
          createdDate,
          createdByUserName,
          comments,
          reversed,
          referenceNumber,
          officeRunningBalance,
          organizationRunningBalance,
          runningBalanceComputed,
          transactionDetailData,
          currency);
    }
  private void updateEnumerations(
      Map<String, Object> commandAsJsonMap, JsonObject auditObject, String entityName) {

    if (entityName.equalsIgnoreCase("LOAN") || entityName.equalsIgnoreCase("LOANPRODUCT")) {

      final String[] enumTypes = {
        "loanTermFrequencyType",
        "termFrequencyType",
        "repaymentFrequencyType",
        "amortizationType",
        "interestType",
        "interestCalculationPeriodType",
        "interestRateFrequencyType",
        "accountingRule"
      };

      for (final String typeName : enumTypes) {
        if (commandAsJsonMap.containsKey(typeName)) {
          commandAsJsonMap.remove(typeName);

          final Integer enumTypeId = auditObject.get(typeName).getAsInt();
          final String code = LoanEnumerations.loanEnumueration(typeName, enumTypeId).getValue();
          if (code != null) {
            commandAsJsonMap.put(typeName, code);
          }
        }
      }

    } else if (entityName.equalsIgnoreCase("SAVINGSPRODUCT")
        || entityName.equalsIgnoreCase("SAVINGSACCOUNT")
        || entityName.equalsIgnoreCase("RECURRINGDEPOSITPRODUCT")
        || entityName.equalsIgnoreCase("RECURRINGDEPOSITACCOUNT")
        || entityName.equalsIgnoreCase("FIXEDDEPOSITPRODUCT")
        || entityName.equalsIgnoreCase("FIXEDDEPOSITACCOUNT")) {

      final String[] enumTypes = {
        "interestCompoundingPeriodType",
        "interestPostingPeriodType",
        "interestCalculationType",
        "lockinPeriodFrequencyType",
        "minDepositTermTypeId",
        "maxDepositTermTypeId",
        "inMultiplesOfDepositTermTypeId",
        "depositPeriodFrequencyId",
        "accountingRule",
        "interestCalculationDaysInYearType",
        "preClosurePenalInterestOnTypeId",
        "recurringFrequencyType"
      };

      for (final String typeName : enumTypes) {
        if (commandAsJsonMap.containsKey(typeName)) {
          commandAsJsonMap.remove(typeName);

          final Integer enumTypeId = auditObject.get(typeName).getAsInt();
          final String code =
              SavingsEnumerations.savingEnumueration(typeName, enumTypeId).getValue();
          if (code != null) {
            commandAsJsonMap.put(typeName, code);
          }
        }
      }
    }
  }