MIFOSX-866 changes for returing transaction type associated with a journal entry
This commit is contained in:
+3
-2
@@ -15,7 +15,7 @@ public class TransactionDetailData {
|
||||
private final NoteData noteData;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final String transactionType;
|
||||
private final TransactionTypeEnumData transactionType;
|
||||
|
||||
public TransactionDetailData(final Long transactionId, final PaymentDetailData paymentDetails, final NoteData noteData) {
|
||||
this.transactionId = transactionId;
|
||||
@@ -25,7 +25,8 @@ public class TransactionDetailData {
|
||||
|
||||
}
|
||||
|
||||
public TransactionDetailData(final Long transactionId, final PaymentDetailData paymentDetails, final NoteData noteData,final String transactionType) {
|
||||
public TransactionDetailData(final Long transactionId, final PaymentDetailData paymentDetails, final NoteData noteData,
|
||||
final TransactionTypeEnumData transactionType) {
|
||||
this.transactionId = transactionId;
|
||||
this.paymentDetails = paymentDetails;
|
||||
this.noteData = noteData;
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.accounting.journalentry.data;
|
||||
|
||||
/**
|
||||
* Immutable data object represent loan and Savings status enumerations.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class TransactionTypeEnumData {
|
||||
|
||||
private final Long id;
|
||||
private final String code;
|
||||
private final String value;
|
||||
|
||||
public TransactionTypeEnumData(final Long id, final String code, final String value) {
|
||||
this.id = id;
|
||||
this.code = code;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Long id() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
}
|
||||
+29
-33
@@ -5,7 +5,6 @@
|
||||
*/
|
||||
package org.mifosplatform.accounting.journalentry.service;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -20,6 +19,7 @@ import org.mifosplatform.accounting.common.AccountingEnumerations;
|
||||
import org.mifosplatform.accounting.journalentry.data.JournalEntryAssociationParametersData;
|
||||
import org.mifosplatform.accounting.journalentry.data.JournalEntryData;
|
||||
import org.mifosplatform.accounting.journalentry.data.TransactionDetailData;
|
||||
import org.mifosplatform.accounting.journalentry.data.TransactionTypeEnumData;
|
||||
import org.mifosplatform.accounting.journalentry.exception.JournalEntriesNotFoundException;
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
@@ -29,8 +29,12 @@ import org.mifosplatform.infrastructure.core.service.PaginationHelper;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.mifosplatform.portfolio.group.service.SearchParameters;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanTransactionEnumData;
|
||||
import org.mifosplatform.portfolio.loanproduct.service.LoanEnumerations;
|
||||
import org.mifosplatform.portfolio.note.data.NoteData;
|
||||
import org.mifosplatform.portfolio.paymentdetail.data.PaymentDetailData;
|
||||
import org.mifosplatform.portfolio.savings.data.SavingsAccountTransactionEnumData;
|
||||
import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
|
||||
import org.mifosplatform.portfolio.account.PortfolioAccountType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
@@ -52,7 +56,6 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
|
||||
|
||||
private static final class GLJournalEntryMapper implements RowMapper<JournalEntryData> {
|
||||
|
||||
|
||||
private final JournalEntryAssociationParametersData associationParametersData;
|
||||
|
||||
public GLJournalEntryMapper(final JournalEntryAssociationParametersData associationParametersData) {
|
||||
@@ -82,17 +85,12 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
|
||||
.append(" journalEntry.organization_running_balance as organizationRunningBalance ");
|
||||
}
|
||||
if (associationParametersData.isTransactionDetailsRequired()) {
|
||||
sb.append(" ,pd.receipt_number as receiptNumber, ")
|
||||
.append(" pd.check_number as checkNumber, ")
|
||||
.append(" pd.account_number as accountNumber, ")
|
||||
.append(" cdv.code_value as paymentTypeName, ")
|
||||
.append(" pd.payment_type_cv_id as paymentTypeId,")
|
||||
.append(" pd.bank_number as bankNumber, ")
|
||||
.append(" pd.routing_code as routingCode, ")
|
||||
.append(" note.id as noteId, ")
|
||||
.append(" note.note as transactionNote, ")
|
||||
.append(" lte.enum_value as loanTransactionType, ")
|
||||
.append(" ste.enum_value as savingTransactionType ");
|
||||
sb.append(" ,pd.receipt_number as receiptNumber, ").append(" pd.check_number as checkNumber, ")
|
||||
.append(" pd.account_number as accountNumber, ").append(" cdv.code_value as paymentTypeName, ")
|
||||
.append(" pd.payment_type_cv_id as paymentTypeId,").append(" pd.bank_number as bankNumber, ")
|
||||
.append(" pd.routing_code as routingCode, ").append(" note.id as noteId, ")
|
||||
.append(" note.note as transactionNote, ").append(" lt.transaction_type_enum as loanTransactionType, ")
|
||||
.append(" st.transaction_type_enum as savingsTransactionType ");
|
||||
}
|
||||
sb.append(" from acc_gl_journal_entry as journalEntry ")
|
||||
.append(" left join acc_gl_account as glAccount on glAccount.id = journalEntry.account_id")
|
||||
@@ -101,9 +99,7 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
|
||||
.append(" join m_currency curr on curr.code = journalEntry.currency_code ");
|
||||
if (associationParametersData.isTransactionDetailsRequired()) {
|
||||
sb.append(" left join m_loan_transaction as lt on journalEntry.loan_transaction_id = lt.id ")
|
||||
.append(" left join r_enum_value as lte on ( lt.transaction_type_enum = lte.enum_id and lte.enum_name = 'transaction_type_enum' )")
|
||||
.append(" left join m_savings_account_transaction as st on journalEntry.savings_transaction_id = st.id ")
|
||||
.append(" left join r_enum_value as ste on (st.transaction_type_enum = ste.enum_id and ste.enum_name = 'transaction_type_enum' )")
|
||||
.append(" left join m_payment_detail as pd on lt.payment_detail_id = pd.id or st.payment_detail_id = pd.id")
|
||||
.append(" left join m_code_value as cdv on cdv.id = pd.payment_type_cv_id ")
|
||||
.append(" left join m_note as note on lt.id = note.loan_transaction_id or st.id = note.savings_account_transaction_id ");
|
||||
@@ -188,24 +184,26 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
|
||||
transaction = Long.parseLong(transactionId.substring(1).trim());
|
||||
}
|
||||
|
||||
String transactionType = null;
|
||||
TransactionTypeEnumData transactionTypeEnumData = null;
|
||||
|
||||
|
||||
|
||||
if(PortfolioAccountType.fromInt(entityTypeId).isLoanAccount())
|
||||
{
|
||||
transactionType = rs.getString("loanTransactionType");
|
||||
}
|
||||
else if(PortfolioAccountType.fromInt(entityTypeId).isSavingsAccount()){
|
||||
|
||||
transactionType = rs.getString("savingTransactionType");
|
||||
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,transactionType);
|
||||
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);
|
||||
comments, reversed, referenceNumber, officeRunningBalance, organizationRunningBalance, runningBalanceComputed,
|
||||
transactionDetailData, currency);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,9 +301,7 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
|
||||
if (searchParameters.isSortOrderProvided()) {
|
||||
sqlBuilder.append(' ').append(searchParameters.getSortOrder());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sqlBuilder.append(" order by journalEntry.entry_date, journalEntry.id");
|
||||
}
|
||||
|
||||
@@ -318,12 +314,12 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
|
||||
|
||||
final Object[] finalObjectArray = Arrays.copyOf(objectArray, arrayPos);
|
||||
final String sqlCountRows = "SELECT FOUND_ROWS()";
|
||||
return this.paginationHelper.fetchPage(this.jdbcTemplate, sqlCountRows, sqlBuilder.toString(), finalObjectArray,
|
||||
rm);
|
||||
return this.paginationHelper.fetchPage(this.jdbcTemplate, sqlCountRows, sqlBuilder.toString(), finalObjectArray, rm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JournalEntryData retrieveGLJournalEntryById(final long glJournalEntryId, JournalEntryAssociationParametersData associationParametersData) {
|
||||
public JournalEntryData retrieveGLJournalEntryById(final long glJournalEntryId,
|
||||
JournalEntryAssociationParametersData associationParametersData) {
|
||||
try {
|
||||
|
||||
final GLJournalEntryMapper rm = new GLJournalEntryMapper(associationParametersData);
|
||||
|
||||
+8
@@ -58,6 +58,14 @@ public class LoanTransactionEnumData {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the transaction involves either a payment (disbursement)
|
||||
* or a receipt (repayments, repayments during disbursement etc)
|
||||
|
||||
+12
-1
@@ -11,7 +11,6 @@ import org.mifosplatform.portfolio.savings.SavingsAccountTransactionType;
|
||||
* Immutable data object represent savings account transaction type
|
||||
* enumerations.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class SavingsAccountTransactionEnumData {
|
||||
|
||||
private final Long id;
|
||||
@@ -43,6 +42,18 @@ public class SavingsAccountTransactionEnumData {
|
||||
this.rejectTransfer = Long.valueOf(SavingsAccountTransactionType.REJECT_TRANSFER.getValue()).equals(this.id);
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public boolean isDeposit() {
|
||||
return this.deposit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user