/** * @param loanProductId * @param paymentTypeToGLAccountMappers * @return */ private List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappings( final PortfolioProductType portfolioProductType, final Long loanProductId) { final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper(); final String sql = "select " + rm.schema() + " and product_id = ? and payment_type is not null"; final List<Map<String, Object>> paymentTypeToFundSourceMappingsList = this.jdbcTemplate.query( sql, rm, new Object[] {portfolioProductType.getValue(), loanProductId}); List<PaymentTypeToGLAccountMapper> paymentTypeToGLAccountMappers = null; for (final Map<String, Object> productToGLAccountMap : paymentTypeToFundSourceMappingsList) { if (paymentTypeToGLAccountMappers == null) { paymentTypeToGLAccountMappers = new ArrayList<>(); } final Long paymentTypeId = (Long) productToGLAccountMap.get("paymentTypeId"); final String paymentTypeValue = (String) productToGLAccountMap.get("paymentTypeValue"); final CodeValueData codeValueData = CodeValueData.instance(paymentTypeId, paymentTypeValue); final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId"); final String glAccountName = (String) productToGLAccountMap.get("glAccountName"); final String glCode = (String) productToGLAccountMap.get("glCode"); final GLAccountData gLAccountData = new GLAccountData(glAccountId, glAccountName, glCode); final PaymentTypeToGLAccountMapper paymentTypeToGLAccountMapper = new PaymentTypeToGLAccountMapper(codeValueData, gLAccountData); paymentTypeToGLAccountMappers.add(paymentTypeToGLAccountMapper); } return paymentTypeToGLAccountMappers; }
@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 @SuppressWarnings("unused") public LoanRescheduleRequestData mapRow(final ResultSet rs, final int rowNum) throws SQLException { final Long id = rs.getLong("id"); final Long loanId = rs.getLong("loanId"); final Integer statusEnumId = JdbcSupport.getInteger(rs, "statusEnum"); final LoanRescheduleRequestStatusEnumData statusEnum = LoanRescheduleRequestEnumerations.status(statusEnumId); final String clientName = rs.getString("clientName"); final String loanAccountNumber = rs.getString("loanAccountNumber"); final Long clientId = rs.getLong("clientId"); final Integer rescheduleFromInstallment = JdbcSupport.getInteger(rs, "rescheduleFromInstallment"); final Integer graceOnPrincipal = JdbcSupport.getInteger(rs, "graceOnPrincipal"); final Integer graceOnInterest = JdbcSupport.getInteger(rs, "graceOnInterest"); final LocalDate rescheduleFromDate = JdbcSupport.getLocalDate(rs, "rescheduleFromDate"); final LocalDate adjustedDueDate = JdbcSupport.getLocalDate(rs, "adjustedDueDate"); final Integer extraTerms = JdbcSupport.getInteger(rs, "extraTerms"); final BigDecimal interestRate = rs.getBigDecimal("interestRate"); final Long rescheduleReasonCvId = JdbcSupport.getLong(rs, "rescheduleReasonCvId"); final String rescheduleReasonCvValue = rs.getString("rescheduleReasonCvValue"); final CodeValueData rescheduleReasonCodeValue = CodeValueData.instance(rescheduleReasonCvId, rescheduleReasonCvValue); final String rescheduleReasonComment = rs.getString("rescheduleReasonComment"); final Boolean recalculateInterest = rs.getBoolean("recalculateInterest"); final LocalDate submittedOnDate = JdbcSupport.getLocalDate(rs, "submittedOnDate"); final String submittedByUsername = rs.getString("submittedByUsername"); final String submittedByFirstname = rs.getString("submittedByFirstname"); final String submittedByLastname = rs.getString("submittedByLastname"); final LocalDate approvedOnDate = JdbcSupport.getLocalDate(rs, "approvedOnDate"); final String approvedByUsername = rs.getString("approvedByUsername"); final String approvedByFirstname = rs.getString("approvedByFirstname"); final String approvedByLastname = rs.getString("approvedByLastname"); final LocalDate rejectedOnDate = JdbcSupport.getLocalDate(rs, "rejectedOnDate"); final String rejectedByUsername = rs.getString("rejectedByUsername"); final String rejectedByFirstname = rs.getString("rejectedByFirstname"); final String rejectedByLastname = rs.getString("rejectedByLastname"); final LoanRescheduleRequestTimelineData timeline = new LoanRescheduleRequestTimelineData( submittedOnDate, submittedByUsername, submittedByFirstname, submittedByLastname, approvedOnDate, approvedByUsername, approvedByFirstname, approvedByLastname, rejectedOnDate, rejectedByUsername, rejectedByFirstname, rejectedByLastname); return LoanRescheduleRequestData.instance( id, loanId, statusEnum, rescheduleFromInstallment, graceOnPrincipal, graceOnInterest, rescheduleFromDate, adjustedDueDate, extraTerms, interestRate, rescheduleReasonCodeValue, rescheduleReasonComment, timeline, clientName, loanAccountNumber, clientId, recalculateInterest); }