Merge pull request #698 from ashok-conflux/MIFOSX-812

add currency details to journal entries api
This commit is contained in:
Vishwas Babu A J
2013-12-17 06:54:09 -08:00
4 changed files with 24 additions and 6 deletions
@@ -48,7 +48,7 @@ public class JournalEntriesApiResource {
private static final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "officeId", "officeName", private static final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "officeId", "officeName",
"glAccountName", "glAccountId", "glAccountCode", "glAccountType", "transactionDate", "entryType", "amount", "transactionId", "glAccountName", "glAccountId", "glAccountCode", "glAccountType", "transactionDate", "entryType", "amount", "transactionId",
"manualEntry", "entityType", "entityId", "createdByUserId", "createdDate", "createdByUserName", "comments", "reversed", "manualEntry", "entityType", "entityId", "createdByUserId", "createdDate", "createdByUserName", "comments", "reversed",
"referenceNumber")); "referenceNumber", "currency"));
private final String resourceNameForPermission = "JOURNALENTRY"; private final String resourceNameForPermission = "JOURNALENTRY";
@@ -9,6 +9,7 @@ import java.math.BigDecimal;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.infrastructure.core.data.EnumOptionData;
import org.mifosplatform.organisation.monetary.data.CurrencyData;
/** /**
* Immutable object representing a General Ledger Account * Immutable object representing a General Ledger Account
@@ -33,6 +34,8 @@ public class JournalEntryData {
private final EnumOptionData entryType; private final EnumOptionData entryType;
private final BigDecimal amount; private final BigDecimal amount;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final CurrencyData currency;
@SuppressWarnings("unused")
private final String transactionId; private final String transactionId;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final Boolean manualEntry; private final Boolean manualEntry;
@@ -68,7 +71,7 @@ public class JournalEntryData {
final Boolean manualEntry, final EnumOptionData entityType, final Long entityId, final Long createdByUserId, final Boolean manualEntry, final EnumOptionData entityType, final Long entityId, final Long createdByUserId,
final LocalDate createdDate, final String createdByUserName, final String comments, final Boolean reversed, final LocalDate createdDate, final String createdByUserName, final String comments, final Boolean reversed,
final String referenceNumber, final BigDecimal officeRunningBalance, final BigDecimal organizationRunningBalance, final String referenceNumber, final BigDecimal officeRunningBalance, final BigDecimal organizationRunningBalance,
final Boolean runningBalanceComputed,final TransactionDetailData transactionDetailData) { final Boolean runningBalanceComputed,final TransactionDetailData transactionDetailData, final CurrencyData currency) {
this.id = id; this.id = id;
this.officeId = officeId; this.officeId = officeId;
this.officeName = officeName; this.officeName = officeName;
@@ -93,6 +96,7 @@ public class JournalEntryData {
this.organizationRunningBalance = organizationRunningBalance; this.organizationRunningBalance = organizationRunningBalance;
this.runningBalanceComputed = runningBalanceComputed; this.runningBalanceComputed = runningBalanceComputed;
this.transactionDetails = transactionDetailData; this.transactionDetails = transactionDetailData;
this.currency = currency;
} }
public Long getId() { public Long getId() {
@@ -27,6 +27,7 @@ import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
import org.mifosplatform.infrastructure.core.service.Page; import org.mifosplatform.infrastructure.core.service.Page;
import org.mifosplatform.infrastructure.core.service.PaginationHelper; import org.mifosplatform.infrastructure.core.service.PaginationHelper;
import org.mifosplatform.infrastructure.core.service.RoutingDataSource; 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.group.service.SearchParameters;
import org.mifosplatform.portfolio.note.data.NoteData; import org.mifosplatform.portfolio.note.data.NoteData;
import org.mifosplatform.portfolio.paymentdetail.data.PaymentDetailData; import org.mifosplatform.portfolio.paymentdetail.data.PaymentDetailData;
@@ -71,7 +72,9 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
.append(" journalEntry.type_enum as entryType,journalEntry.amount as amount, journalEntry.transaction_id as transactionId,") .append(" journalEntry.type_enum as entryType,journalEntry.amount as amount, journalEntry.transaction_id as transactionId,")
.append(" journalEntry.entity_type_enum as entityType, journalEntry.entity_id as entityId, creatingUser.id as createdByUserId, ") .append(" journalEntry.entity_type_enum as entityType, journalEntry.entity_id as entityId, creatingUser.id as createdByUserId, ")
.append(" creatingUser.username as createdByUserName, journalEntry.description as comments, ") .append(" creatingUser.username as createdByUserName, journalEntry.description as comments, ")
.append(" journalEntry.created_date as createdDate, journalEntry.reversed as reversed "); .append(" journalEntry.created_date as createdDate, journalEntry.reversed as reversed, ")
.append(" journalEntry.currency_code as currencyCode, curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, ")
.append(" curr.display_symbol as currencyDisplaySymbol, curr.decimal_places as currencyDigits, curr.currency_multiplesof as inMultiplesOf ");
if(associationParametersData.isRunningBalanceRequired()){ if(associationParametersData.isRunningBalanceRequired()){
sb.append(" ,journalEntry.is_running_balance_caculated as runningBalanceComputed, ") sb.append(" ,journalEntry.is_running_balance_caculated as runningBalanceComputed, ")
.append(" journalEntry.office_running_balance as officeRunningBalance, ") .append(" journalEntry.office_running_balance as officeRunningBalance, ")
@@ -91,7 +94,8 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
sb.append(" from acc_gl_journal_entry as journalEntry ") sb.append(" from acc_gl_journal_entry as journalEntry ")
.append(" left join acc_gl_account as glAccount on glAccount.id = journalEntry.account_id") .append(" left join acc_gl_account as glAccount on glAccount.id = journalEntry.account_id")
.append(" left join m_office as office on office.id = journalEntry.office_id") .append(" left join m_office as office on office.id = journalEntry.office_id")
.append(" left join m_appuser as creatingUser on creatingUser.id = journalEntry.createdby_id "); .append(" left join m_appuser as creatingUser on creatingUser.id = journalEntry.createdby_id ")
.append(" join m_currency curr on curr.code = journalEntry.currency_code ");
if(associationParametersData.isTransactionDetailsRequired()){ if(associationParametersData.isTransactionDetailsRequired()){
sb.append(" left join m_loan_transaction as lt on journalEntry.loan_transaction_id = lt.id ") sb.append(" left join m_loan_transaction as lt on journalEntry.loan_transaction_id = lt.id ")
.append(" left join m_savings_account_transaction as st on journalEntry.savings_transaction_id = st.id ") .append(" left join m_savings_account_transaction as st on journalEntry.savings_transaction_id = st.id ")
@@ -136,6 +140,16 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
BigDecimal officeRunningBalance = null; BigDecimal officeRunningBalance = null;
BigDecimal organizationRunningBalance =null; BigDecimal organizationRunningBalance =null;
Boolean runningBalanceComputed =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()){ if(associationParametersData.isRunningBalanceRequired()){
officeRunningBalance = rs.getBigDecimal("officeRunningBalance"); officeRunningBalance = rs.getBigDecimal("officeRunningBalance");
organizationRunningBalance = rs.getBigDecimal("organizationRunningBalance"); organizationRunningBalance = rs.getBigDecimal("organizationRunningBalance");
@@ -171,7 +185,7 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
} }
return new JournalEntryData(id, officeId, officeName, glAccountName, glAccountId, glCode, accountType, transactionDate, return new JournalEntryData(id, officeId, officeName, glAccountName, glAccountId, glCode, accountType, transactionDate,
entryType, amount, transactionId, manualEntry, entityType, entityId, createdByUserId, createdDate, createdByUserName, entryType, amount, transactionId, manualEntry, entityType, entityId, createdByUserId, createdDate, createdByUserName,
comments, reversed, referenceNumber,officeRunningBalance,organizationRunningBalance,runningBalanceComputed,transactionDetailData); comments, reversed, referenceNumber,officeRunningBalance,organizationRunningBalance,runningBalanceComputed,transactionDetailData, currency);
} }
} }
@@ -268,7 +268,7 @@ public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntry
final EnumOptionData entryType = AccountingEnumerations.journalEntryType(entryTypeId); final EnumOptionData entryType = AccountingEnumerations.journalEntryType(entryTypeId);
return new JournalEntryData(id, officeId, null, null, glAccountId, null, accountType, null, entryType, amount, null, null, return new JournalEntryData(id, officeId, null, null, glAccountId, null, accountType, null, entryType, amount, null, null,
null, null, null, null, null, null, null, null, null, null, null,null); null, null, null, null, null, null, null, null, null, null, null,null, null);
} }
} }