Merge pull request #963 from lingalamadhukar/MIFOSX-1349
MIFOSX-1351,MIFOSX-1349
This commit is contained in:
+7
@@ -2,6 +2,7 @@ package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
@@ -392,6 +393,12 @@ public class ClientSavingsIntegrationTest {
|
||||
this.savingsAccountHelper.waiveCharge((Integer) savingsChargeForWaive.get("id"), savingsId);
|
||||
HashMap waiveCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForWaive.get("id"));
|
||||
assertEquals(savingsChargeForWaive.get("amount"), waiveCharge.get("amountWaived"));
|
||||
|
||||
this.savingsAccountHelper.waiveCharge((Integer) savingsChargeForWaive.get("id"), savingsId);
|
||||
waiveCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForWaive.get("id"));
|
||||
BigDecimal totalWaiveAmount = BigDecimal.valueOf(Double.valueOf((Float) savingsChargeForWaive.get("amount")));
|
||||
totalWaiveAmount = totalWaiveAmount.add(totalWaiveAmount);
|
||||
assertEquals(totalWaiveAmount.floatValue(), waiveCharge.get("amountWaived"));
|
||||
}
|
||||
|
||||
private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
|
||||
+7
@@ -2,6 +2,7 @@ package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
@@ -431,6 +432,12 @@ public class GroupSavingsIntegrationTest {
|
||||
this.savingsAccountHelper.waiveCharge((Integer) savingsChargeForWaive.get("id"), savingsId);
|
||||
HashMap waiveCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForWaive.get("id"));
|
||||
assertEquals(savingsChargeForWaive.get("amount"), waiveCharge.get("amountWaived"));
|
||||
|
||||
this.savingsAccountHelper.waiveCharge((Integer) savingsChargeForWaive.get("id"), savingsId);
|
||||
waiveCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForWaive.get("id"));
|
||||
BigDecimal totalWaiveAmount = BigDecimal.valueOf(Double.valueOf((Float) savingsChargeForWaive.get("amount")));
|
||||
totalWaiveAmount = totalWaiveAmount.add(totalWaiveAmount);
|
||||
assertEquals(totalWaiveAmount.floatValue(), waiveCharge.get("amountWaived"));
|
||||
}
|
||||
|
||||
public static Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
|
||||
+4
-2
@@ -288,14 +288,16 @@ public class SavingsAccountCharge extends AbstractPersistable<Long> {
|
||||
}
|
||||
|
||||
public Money waive(final MonetaryCurrency currency) {
|
||||
this.amountWaived = this.amountOutstanding;
|
||||
Money amountWaivedToDate = Money.of(currency, this.amountWaived);
|
||||
Money amountOutstanding = Money.of(currency, this.amountOutstanding);
|
||||
this.amountWaived = amountWaivedToDate.plus(amountOutstanding).getAmount();
|
||||
this.amountOutstanding = BigDecimal.ZERO;
|
||||
this.waived = true;
|
||||
|
||||
recalculateAmountOutstanding();
|
||||
updateToNextDueDate();
|
||||
|
||||
return getAmountWaived(currency);
|
||||
return amountOutstanding;
|
||||
}
|
||||
|
||||
public void undoWaiver(final MonetaryCurrency currency, final Money transactionAmount) {
|
||||
|
||||
+3
@@ -6,6 +6,7 @@
|
||||
package org.mifosplatform.portfolio.savings.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Set;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
@@ -19,4 +20,6 @@ public interface SavingsAccountDomainService {
|
||||
|
||||
SavingsAccountTransaction handleDeposit(SavingsAccount account, DateTimeFormatter fmt, LocalDate transactionDate,
|
||||
BigDecimal transactionAmount, PaymentDetail paymentDetail, boolean isAccountTransfer, boolean isRegularTransaction);
|
||||
|
||||
void postJournalEntries(SavingsAccount savingsAccount, Set<Long> existingTransactionIds, Set<Long> existingReversedTransactionIds);
|
||||
}
|
||||
+9
@@ -133,4 +133,13 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi
|
||||
existingTransactionIds, existingReversedTransactionIds, isAccountTransfer);
|
||||
this.journalEntryWritePlatformService.createJournalEntriesForSavings(accountingBridgeData);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void postJournalEntries(final SavingsAccount account, final Set<Long> existingTransactionIds,
|
||||
final Set<Long> existingReversedTransactionIds) {
|
||||
|
||||
final boolean isAccountTransfer = false;
|
||||
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer);
|
||||
}
|
||||
}
|
||||
+16
-1
@@ -8,6 +8,7 @@ package org.mifosplatform.portfolio.savings.service;
|
||||
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -452,7 +453,11 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
||||
savingsAccountDataDTO.getAppliedBy());
|
||||
account.approveAndActivateApplication(savingsAccountDataDTO.getApplicationDate().toDate(), savingsAccountDataDTO.getAppliedBy());
|
||||
Money amountForDeposit = account.activateWithBalance();
|
||||
boolean isAccountTransfer = false;
|
||||
|
||||
final Set<Long> existingTransactionIds = new HashSet<Long>();
|
||||
final Set<Long> existingReversedTransactionIds = new HashSet<Long>();
|
||||
final boolean isAccountTransfer = false;
|
||||
|
||||
if (amountForDeposit.isGreaterThanZero()) {
|
||||
// save account entity before performing deposit transaction, as
|
||||
// accountId is required for persist transaction entity.
|
||||
@@ -460,6 +465,7 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
||||
boolean isRegularTransaction = false;
|
||||
this.savingsAccountDomainService.handleDeposit(account, savingsAccountDataDTO.getFmt(), account.getActivationLocalDate(),
|
||||
amountForDeposit.getAmount(), null, isAccountTransfer, isRegularTransaction);
|
||||
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
|
||||
}
|
||||
account.processAccountUponActivation();
|
||||
account.validateAccountBalanceDoesNotBecomeNegative(SavingsAccountTransactionType.PAY_CHARGE.name());
|
||||
@@ -471,9 +477,18 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
||||
account.updateAccountNo(accountNoGenerator.generate());
|
||||
this.savingAccountRepository.save(account);
|
||||
}
|
||||
//post journal entries for activation charges
|
||||
this.savingsAccountDomainService.postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
|
||||
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withSavingsId(account.getId()) //
|
||||
.setRollbackTransaction(rollbackTransaction)//
|
||||
.build();
|
||||
}
|
||||
|
||||
private void updateExistingTransactionsDetails(SavingsAccount account, Set<Long> existingTransactionIds,
|
||||
Set<Long> existingReversedTransactionIds) {
|
||||
existingTransactionIds.addAll(account.findExistingTransactionIds());
|
||||
existingReversedTransactionIds.addAll(account.findExistingReversedTransactionIds());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user