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

      final Long id = rs.getLong("id");
      final String name = rs.getString("name");
      final String description = rs.getString("description");
      final Long officeId = JdbcSupport.getLong(rs, "officeId");
      final String officeName = rs.getString("officeName");
      final int productTypeEnum = rs.getInt("productTypeEnum");
      final Long productId = JdbcSupport.getLong(rs, "productId");
      final Long chargeId = JdbcSupport.getLong(rs, "chargeId");
      final Long accountingRuleId = JdbcSupport.getLong(rs, "accountingRuleId");
      final Long eventId = JdbcSupport.getLong(rs, "eventId");
      final Long eventAttributeId = JdbcSupport.getLong(rs, "eventAttributeId");
      final Long debitAccountId = JdbcSupport.getLong(rs, "debitAccountId");
      final Long creditAccountId = JdbcSupport.getLong(rs, "creditAccountId");
      final String savingProductName = rs.getString("savingProductName");
      final String loanProductName = rs.getString("loanProductName");
      final String chargeName = rs.getString("chargeName");
      final String eventName = rs.getString("eventName");
      final String eventAttributeName = rs.getString("eventAttributeName");
      final boolean chargeIsPenalty = rs.getBoolean("isPenalty");

      OfficeData officeData = null;
      if (officeId != null) {
        officeData = OfficeData.dropdown(officeId, officeName, null);
      }

      SavingsProductData savingsProductData = null;
      LoanProductData loanProductData = null;

      PortfolioProductType portfolioProductType = PortfolioProductType.fromInt(productTypeEnum);
      EnumOptionData productType =
          AccountingEnumerations.portfolioProductType(portfolioProductType);
      if (portfolioProductType.isLoanProduct() && productId != null) {
        savingsProductData = SavingsProductData.lookup(productId, savingProductName);
      } else if (portfolioProductType.isSavingProduct() && productId != null) {
        loanProductData = LoanProductData.lookup(productId, loanProductName);
      }

      ChargeData chargeData = null;
      if (chargeId != null) {
        chargeData = ChargeData.lookup(chargeId, chargeName, chargeIsPenalty);
      }

      CodeData event = CodeData.instance(eventId, eventName, true);

      CodeValueData eventAttribute = null;
      if (eventAttributeId != null) {
        eventAttribute = CodeValueData.instance(eventAttributeId, eventAttributeName);
      }

      AccountingRuleData accountingRuleData =
          new AccountingRuleData(accountingRuleId, debitAccountId, creditAccountId);

      return new AutoPostingData(
          id,
          name,
          description,
          officeData,
          productType,
          loanProductData,
          savingsProductData,
          chargeData,
          event,
          eventAttribute,
          accountingRuleData);
    }
    @Override
    public AccountTransferData mapRow(
        final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {

      final Long id = rs.getLong("id");
      final boolean reversed = rs.getBoolean("isReversed");

      final LocalDate transferDate = JdbcSupport.getLocalDate(rs, "transferDate");
      final BigDecimal transferAmount =
          JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "transferAmount");
      final String transferDescription = rs.getString("transferDescription");

      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);

      final Long fromOfficeId = JdbcSupport.getLong(rs, "fromOfficeId");
      final String fromOfficeName = rs.getString("fromOfficeName");
      final OfficeData fromOffice = OfficeData.dropdown(fromOfficeId, fromOfficeName, null);

      final Long toOfficeId = JdbcSupport.getLong(rs, "toOfficeId");
      final String toOfficeName = rs.getString("toOfficeName");
      final OfficeData toOffice = OfficeData.dropdown(toOfficeId, toOfficeName, null);

      final Long fromClientId = JdbcSupport.getLong(rs, "fromClientId");
      final String fromClientName = rs.getString("fromClientName");
      final ClientData fromClient =
          ClientData.lookup(fromClientId, fromClientName, fromOfficeId, fromOfficeName);

      final Long toClientId = JdbcSupport.getLong(rs, "toClientId");
      final String toClientName = rs.getString("toClientName");
      final ClientData toClient =
          ClientData.lookup(toClientId, toClientName, toOfficeId, toOfficeName);

      final Long fromSavingsAccountId = JdbcSupport.getLong(rs, "fromSavingsAccountId");
      final String fromSavingsAccountNo = rs.getString("fromSavingsAccountNo");
      final Long fromLoanAccountId = JdbcSupport.getLong(rs, "fromLoanAccountId");
      final String fromLoanAccountNo = rs.getString("fromLoanAccountNo");
      PortfolioAccountData fromAccount = null;
      EnumOptionData fromAccountType = null;
      if (fromSavingsAccountId != null) {
        fromAccount = PortfolioAccountData.lookup(fromSavingsAccountId, fromSavingsAccountNo);
        fromAccountType = AccountTransferEnumerations.accountType(PortfolioAccountType.SAVINGS);
      } else if (fromLoanAccountId != null) {
        fromAccount = PortfolioAccountData.lookup(fromLoanAccountId, fromLoanAccountNo);
        fromAccountType = AccountTransferEnumerations.accountType(PortfolioAccountType.LOAN);
      }

      PortfolioAccountData toAccount = null;
      EnumOptionData toAccountType = null;
      final Long toSavingsAccountId = JdbcSupport.getLong(rs, "toSavingsAccountId");
      final String toSavingsAccountNo = rs.getString("toSavingsAccountNo");
      final Long toLoanAccountId = JdbcSupport.getLong(rs, "toLoanAccountId");
      final String toLoanAccountNo = rs.getString("toLoanAccountNo");

      if (toSavingsAccountId != null) {
        toAccount = PortfolioAccountData.lookup(toSavingsAccountId, toSavingsAccountNo);
        toAccountType = AccountTransferEnumerations.accountType(PortfolioAccountType.SAVINGS);
      } else if (toLoanAccountId != null) {
        toAccount = PortfolioAccountData.lookup(toLoanAccountId, toLoanAccountNo);
        toAccountType = AccountTransferEnumerations.accountType(PortfolioAccountType.LOAN);
      }

      return AccountTransferData.instance(
          id,
          reversed,
          transferDate,
          currency,
          transferAmount,
          transferDescription,
          fromOffice,
          toOffice,
          fromClient,
          toClient,
          fromAccountType,
          fromAccount,
          toAccountType,
          toAccount);
    }