Merge pull request #829 from lingalamadhukar/MIFOSX-1008

MIFOSX-998,MIFOSX-1008 Interest posting issue
This commit is contained in:
Vishwas Babu A J
2014-04-01 20:44:53 -07:00
3 changed files with 26 additions and 15 deletions
@@ -160,6 +160,11 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
} }
} }
if (!newGroup.isCenter() && newGroup.hasActiveClients()) {
final CommandWrapper commandWrapper = new CommandWrapperBuilder().associateClientsToGroup(newGroup.getId()).build();
rollbackTransaction = this.commandProcessingService.validateCommand(commandWrapper, currentUser);
}
// pre-save to generate id for use in group hierarchy // pre-save to generate id for use in group hierarchy
this.groupRepository.save(newGroup); this.groupRepository.save(newGroup);
@@ -1164,6 +1164,10 @@ public class SavingsAccount extends AbstractPersistable<Long> {
return this.client; return this.client;
} }
public BigDecimal getNominalAnnualInterestRate() {
return this.nominalAnnualInterestRate;
}
public Map<String, Object> approveApplication(final AppUser currentUser, final JsonCommand command, final LocalDate tenantsTodayDate) { public Map<String, Object> approveApplication(final AppUser currentUser, final JsonCommand command, final LocalDate tenantsTodayDate) {
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(); final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>();
@@ -309,25 +309,27 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
@Transactional @Transactional
private void postInterest(final SavingsAccount account) { private void postInterest(final SavingsAccount account) {
final Set<Long> existingTransactionIds = new HashSet<Long>(); if (account.getNominalAnnualInterestRate().compareTo(BigDecimal.ZERO) == 1) {
final Set<Long> existingReversedTransactionIds = new HashSet<Long>(); final Set<Long> existingTransactionIds = new HashSet<Long>();
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds); final Set<Long> existingReversedTransactionIds = new HashSet<Long>();
final LocalDate today = DateUtils.getLocalDateOfTenant(); updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
final MathContext mc = new MathContext(10, RoundingMode.HALF_EVEN); final LocalDate today = DateUtils.getLocalDateOfTenant();
final MathContext mc = new MathContext(10, RoundingMode.HALF_EVEN);
account.postInterest(mc, today); account.postInterest(mc, today);
// for generating transaction id's // for generating transaction id's
List<SavingsAccountTransaction> transactions = account.getTransactions(); List<SavingsAccountTransaction> transactions = account.getTransactions();
for (SavingsAccountTransaction accountTransaction : transactions) { for (SavingsAccountTransaction accountTransaction : transactions) {
if (accountTransaction.getId() == null) { if (accountTransaction.getId() == null) {
this.savingsAccountTransactionRepository.save(accountTransaction); this.savingsAccountTransactionRepository.save(accountTransaction);
}
} }
this.savingAccountRepository.save(account);
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
} }
this.savingAccountRepository.save(account);
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
} }
@CronTarget(jobName = JobName.POST_INTEREST_FOR_SAVINGS) @CronTarget(jobName = JobName.POST_INTEREST_FOR_SAVINGS)