fixing minor issues detected while testing cash based accounting

This commit is contained in:
Vishwas Babu AJ
2013-02-24 14:28:16 +05:30
parent 040c33d608
commit 328f294e1a
5 changed files with 36 additions and 23 deletions
+11
View File
@@ -0,0 +1,11 @@
update acc_gl_journal_entry
set acc_gl_journal_entry.entity_type=1
where acc_gl_journal_entry.entity_type='LOAN';
ALTER TABLE `acc_gl_journal_entry`
ALTER `type_enum` DROP DEFAULT;
ALTER TABLE `acc_gl_journal_entry`
CHANGE COLUMN `type_enum` `type_enum` SMALLINT(5) NOT NULL AFTER `entry_date`,
CHANGE COLUMN `entity_type` `entity_type_enum` SMALLINT(5) NULL DEFAULT NULL AFTER `description`;
@@ -43,7 +43,7 @@ public class JournalEntryData {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final Boolean manualEntry; private final Boolean manualEntry;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final String entityType; private final EnumOptionData entityType;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final Long entityId; private final Long entityId;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@@ -60,7 +60,7 @@ public class JournalEntryData {
public JournalEntryData(final Long id, final Long officeId, final String officeName, final String glAccountName, public JournalEntryData(final Long id, final Long officeId, final String officeName, final String glAccountName,
final Long glAccountId, final String glAccountCode, final EnumOptionData glAccountClassification, final Long glAccountId, final String glAccountCode, final EnumOptionData glAccountClassification,
final LocalDate transactionDate, final EnumOptionData entryType, final BigDecimal amount, final String transactionId, final LocalDate transactionDate, final EnumOptionData entryType, final BigDecimal amount, final String transactionId,
final Boolean manualEntry, final String 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) {
this.id = id; this.id = id;
this.officeId = officeId; this.officeId = officeId;
@@ -67,8 +67,8 @@ public class JournalEntry extends AbstractAuditableCustom<AppUser, Long> {
private String description; private String description;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Column(name = "entity_type", length = 50) @Column(name = "entity_type_enum", length = 50)
private String entityType; private Integer entityType;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Column(name = "entity_id") @Column(name = "entity_id")
@@ -76,7 +76,7 @@ public class JournalEntry extends AbstractAuditableCustom<AppUser, Long> {
public static JournalEntry createNew(final Office office, final GLAccount glAccount, final String transactionId, public static JournalEntry createNew(final Office office, final GLAccount glAccount, final String transactionId,
final boolean manualEntry, final Date transactionDate, final JournalEntryType journalEntryType, final BigDecimal amount, final boolean manualEntry, final Date transactionDate, final JournalEntryType journalEntryType, final BigDecimal amount,
final String description, final String entityType, final Long entityId) { final String description, final Integer entityType, final Long entityId) {
return new JournalEntry(office, glAccount, transactionId, manualEntry, transactionDate, journalEntryType.getValue(), amount, return new JournalEntry(office, glAccount, transactionId, manualEntry, transactionDate, journalEntryType.getValue(), amount,
description, entityType, entityId); description, entityType, entityId);
} }
@@ -86,7 +86,7 @@ public class JournalEntry extends AbstractAuditableCustom<AppUser, Long> {
} }
public JournalEntry(final Office office, final GLAccount glAccount, final String transactionId, final boolean manualEntry, public JournalEntry(final Office office, final GLAccount glAccount, final String transactionId, final boolean manualEntry,
final Date transactionDate, final Integer type, final BigDecimal amount, final String description, final String entityType, final Date transactionDate, final Integer type, final BigDecimal amount, final String description, final Integer entityType,
final Long entityId) { final Long entityId) {
this.office = office; this.office = office;
this.glAccount = glAccount; this.glAccount = glAccount;
@@ -98,7 +98,7 @@ public class JournalEntry extends AbstractAuditableCustom<AppUser, Long> {
this.type = type; this.type = type;
this.amount = amount; this.amount = amount;
this.description = StringUtils.defaultIfEmpty(description, null); this.description = StringUtils.defaultIfEmpty(description, null);
this.entityType = StringUtils.defaultIfEmpty(entityType, null); this.entityType = entityType;
this.entityId = entityId; this.entityId = entityId;
} }
@@ -45,7 +45,7 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
+ " journalEntry.office_id as officeId, office.name as officeName, " + " journalEntry.office_id as officeId, office.name as officeName, "
+ " journalEntry.manual_entry as manualEntry,journalEntry.entry_date as transactionDate, " + " journalEntry.manual_entry as manualEntry,journalEntry.entry_date as transactionDate, "
+ " journalEntry.type_enum as entryType,journalEntry.amount as amount, journalEntry.transaction_id as transactionId," + " journalEntry.type_enum as entryType,journalEntry.amount as amount, journalEntry.transaction_id as transactionId,"
+ " journalEntry.entity_type as entityType, journalEntry.entity_id as entityId, creatingUser.id as createdByUserId, " + " journalEntry.entity_type_enum as entityType, journalEntry.entity_id as entityId, creatingUser.id as createdByUserId, "
+ " creatingUser.username as createdByUserName, journalEntry.description as comments, " + " creatingUser.username as createdByUserName, journalEntry.description as comments, "
+ " journalEntry.created_date as createdDate, journalEntry.reversed as reversed " + " journalEntry.created_date as createdDate, journalEntry.reversed as reversed "
+ " from acc_gl_journal_entry journalEntry, acc_gl_account glAccount, m_office office, m_appuser creatingUser " + " from acc_gl_journal_entry journalEntry, acc_gl_account glAccount, m_office office, m_appuser creatingUser "
@@ -70,7 +70,12 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
final int entryTypeId = JdbcSupport.getInteger(rs, "entryType"); final int entryTypeId = JdbcSupport.getInteger(rs, "entryType");
final EnumOptionData entryType = AccountingEnumerations.journalEntryType(entryTypeId); final EnumOptionData entryType = AccountingEnumerations.journalEntryType(entryTypeId);
final String transactionId = rs.getString("transactionId"); final String transactionId = rs.getString("transactionId");
final String entityType = rs.getString("entityType"); 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 entityId = JdbcSupport.getLong(rs, "entityId");
final Long createdByUserId = rs.getLong("createdByUserId"); final Long createdByUserId = rs.getLong("createdByUserId");
final LocalDate createdDate = JdbcSupport.getLocalDate(rs, "createdDate"); final LocalDate createdDate = JdbcSupport.getLocalDate(rs, "createdDate");
@@ -79,14 +84,14 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
final Boolean reversed = rs.getBoolean("reversed"); final Boolean reversed = rs.getBoolean("reversed");
return new JournalEntryData(journalEntryId, officeId, officeName, glAccountName, glAccountId, glCode, accountType, return new JournalEntryData(journalEntryId, officeId, officeName, glAccountName, glAccountId, glCode, accountType,
transactionDate, entryType, amount, transactionId, manualEntry, entityType, entityId, createdByUserId, transactionDate, entryType, amount, transactionId, manualEntry, entityType, entityId, createdByUserId, createdDate,
createdDate, createdByUserName, comments, reversed); createdByUserName, comments, reversed);
} }
} }
@Override @Override
public List<JournalEntryData> retrieveAllGLJournalEntries(final Long officeId, final Long glAccountId, public List<JournalEntryData> retrieveAllGLJournalEntries(final Long officeId, final Long glAccountId, final Boolean onlyManualEntries,
final Boolean onlyManualEntries, final Date fromDate, final Date toDate) { final Date fromDate, final Date toDate) {
final GLJournalEntryMapper rm = new GLJournalEntryMapper(); final GLJournalEntryMapper rm = new GLJournalEntryMapper();
String sql = "select " + rm.schema(); String sql = "select " + rm.schema();
@@ -196,7 +196,6 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
final GLClosure latestGLClosure = this.glClosureRepository.getLatestGLClosureByBranch(loanDTO.getOfficeId()); final GLClosure latestGLClosure = this.glClosureRepository.getLatestGLClosureByBranch(loanDTO.getOfficeId());
final Office office = this.officeRepository.findOne(loanDTO.getOfficeId()); final Office office = this.officeRepository.findOne(loanDTO.getOfficeId());
final Long loanProductId = loanDTO.getLoanProductId(); final Long loanProductId = loanDTO.getLoanProductId();
// TODO: Check for accounting type
for (final LoanTransactionDTO loanTransactionDTO : loanDTO.getNewLoanTransactions()) { for (final LoanTransactionDTO loanTransactionDTO : loanDTO.getNewLoanTransactions()) {
final Date transactionDate = loanTransactionDTO.getTransactionDate(); final Date transactionDate = loanTransactionDTO.getTransactionDate();
final String transactionId = loanTransactionDTO.getTransactionId(); final String transactionId = loanTransactionDTO.getTransactionId();
@@ -262,10 +261,6 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
BigDecimal totalDebitAmount = new BigDecimal(0); BigDecimal totalDebitAmount = new BigDecimal(0);
if (isContraTransaction) {
transactionId = "reversal-" + transactionId;
}
if (principalAmount != null && !(principalAmount.compareTo(BigDecimal.ZERO) == 0)) { if (principalAmount != null && !(principalAmount.compareTo(BigDecimal.ZERO) == 0)) {
totalDebitAmount = totalDebitAmount.add(principalAmount); totalDebitAmount = totalDebitAmount.add(principalAmount);
@@ -328,15 +323,17 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
private void createCreditJournalEntryForLoanProduct(final Office office, final GLAccount account, final Long loanId, private void createCreditJournalEntryForLoanProduct(final Office office, final GLAccount account, final Long loanId,
final String transactionId, final Date transactionDate, final BigDecimal amount) { final String transactionId, final Date transactionDate, final BigDecimal amount) {
final JournalEntry journalEntry = JournalEntry.createNew(office, account, transactionId, true, transactionDate, final boolean manualEntry = false;
JournalEntryType.CREDIT, amount, null, PortfolioProductType.LOAN.toString(), loanId); final JournalEntry journalEntry = JournalEntry.createNew(office, account, transactionId, manualEntry, transactionDate,
JournalEntryType.CREDIT, amount, null, PortfolioProductType.LOAN.getValue(), loanId);
this.glJournalEntryRepository.saveAndFlush(journalEntry); this.glJournalEntryRepository.saveAndFlush(journalEntry);
} }
private void createDebitJournalEntryForLoanProduct(final Office office, final GLAccount account, final Long loanId, private void createDebitJournalEntryForLoanProduct(final Office office, final GLAccount account, final Long loanId,
final String transactionId, final Date transactionDate, final BigDecimal amount) { final String transactionId, final Date transactionDate, final BigDecimal amount) {
final JournalEntry journalEntry = JournalEntry.createNew(office, account, transactionId, true, transactionDate, final boolean manualEntry = false;
JournalEntryType.DEBIT, amount, null, PortfolioProductType.LOAN.toString(), loanId); final JournalEntry journalEntry = JournalEntry.createNew(office, account, transactionId, manualEntry, transactionDate,
JournalEntryType.DEBIT, amount, null, PortfolioProductType.LOAN.getValue(), loanId);
this.glJournalEntryRepository.saveAndFlush(journalEntry); this.glJournalEntryRepository.saveAndFlush(journalEntry);
} }