use of org.mifos.accounts.loan.business.LoanSummaryEntity in project head by mifos.
the class RepayLoanActionStrutsTest method testMakeRepaymentForCurrentDateSameAsInstallmentDate.
@Test
public void testMakeRepaymentForCurrentDateSameAsInstallmentDate() throws Exception {
setMifosUserFromContext();
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, accountBO, request);
Money amount = ((LoanBO) accountBO).getEarlyRepayAmount();
SessionUtils.setAttribute(LoanConstants.WAIVED_REPAYMENT_AMOUNT, Money.zero(), request);
SessionUtils.setAttribute(LoanConstants.TOTAL_REPAYMENT_AMOUNT, amount, request);
setRequestPathInfo("/repayLoanAction");
addRequestParameter("method", "makeRepayment");
addRequestParameter("globalAccountNum", accountBO.getGlobalAccountNum());
addRequestParameter("paymentTypeId", "1");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
RepayLoanActionForm repayLoanActionForm = new RepayLoanActionForm();
repayLoanActionForm.setAmount(amount.toString());
repayLoanActionForm.setWaiverInterest(false);
repayLoanActionForm.setDateOfPayment("23/12/2010");
setActionForm(repayLoanActionForm);
actionPerform();
verifyForward(Constants.UPDATE_SUCCESS);
Assert.assertEquals(accountBO.getAccountState().getId(), Short.valueOf(AccountStates.LOANACC_OBLIGATIONSMET));
LoanSummaryEntity loanSummaryEntity = ((LoanBO) accountBO).getLoanSummary();
Assert.assertEquals(amount, loanSummaryEntity.getPrincipalPaid().add(loanSummaryEntity.getFeesPaid()).add(loanSummaryEntity.getInterestPaid()).add(loanSummaryEntity.getPenaltyPaid()));
}
use of org.mifos.accounts.loan.business.LoanSummaryEntity in project head by mifos.
the class RepayLoanActionStrutsTest method testMakeRepaymentForCurrentDateSameAsInstallmentDateWithInterestWaiver.
@Test
public void testMakeRepaymentForCurrentDateSameAsInstallmentDateWithInterestWaiver() throws Exception {
setMifosUserFromContext();
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, accountBO, request);
Money amount = ((LoanBO) accountBO).getEarlyRepayAmount();
Money waivedAmount = amount.subtract(((LoanBO) accountBO).waiverAmount());
SessionUtils.setAttribute(LoanConstants.WAIVED_REPAYMENT_AMOUNT, waivedAmount, request);
SessionUtils.setAttribute(LoanConstants.TOTAL_REPAYMENT_AMOUNT, amount, request);
setRequestPathInfo("/repayLoanAction");
addRequestParameter("method", "makeRepayment");
addRequestParameter("globalAccountNum", accountBO.getGlobalAccountNum());
addRequestParameter("paymentTypeId", "1");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
RepayLoanActionForm repayLoanActionForm = new RepayLoanActionForm();
repayLoanActionForm.setAmount(amount.toString());
repayLoanActionForm.setWaiverInterest(true);
repayLoanActionForm.setDateOfPayment("23/12/2010");
setActionForm(repayLoanActionForm);
actionPerform();
verifyForward(Constants.UPDATE_SUCCESS);
Assert.assertEquals(accountBO.getAccountState().getId(), Short.valueOf(AccountStates.LOANACC_OBLIGATIONSMET));
LoanSummaryEntity loanSummaryEntity = ((LoanBO) accountBO).getLoanSummary();
Assert.assertEquals(waivedAmount, loanSummaryEntity.getPrincipalPaid().add(loanSummaryEntity.getFeesPaid()).add(loanSummaryEntity.getInterestPaid()).add(loanSummaryEntity.getPenaltyPaid()));
}
use of org.mifos.accounts.loan.business.LoanSummaryEntity in project head by mifos.
the class RepayLoanActionStrutsTest method testMakeRepaymentForCurrentDateLiesBetweenInstallmentDates.
@Test
public void testMakeRepaymentForCurrentDateLiesBetweenInstallmentDates() throws Exception {
setMifosUserFromContext();
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
accountBO.changeFirstInstallmentDateBy(-1);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, accountBO, request);
Money amount = ((LoanBO) accountBO).getEarlyRepayAmount();
SessionUtils.setAttribute(LoanConstants.WAIVED_REPAYMENT_AMOUNT, Money.zero(), request);
SessionUtils.setAttribute(LoanConstants.TOTAL_REPAYMENT_AMOUNT, amount, request);
setRequestPathInfo("/repayLoanAction");
addRequestParameter("method", "makeRepayment");
addRequestParameter("globalAccountNum", accountBO.getGlobalAccountNum());
addRequestParameter("paymentTypeId", "1");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
RepayLoanActionForm repayLoanActionForm = new RepayLoanActionForm();
repayLoanActionForm.setAmount(amount.toString());
repayLoanActionForm.setWaiverInterest(false);
repayLoanActionForm.setDateOfPayment("23/12/2010");
setActionForm(repayLoanActionForm);
actionPerform();
verifyForward(Constants.UPDATE_SUCCESS);
Assert.assertEquals(accountBO.getAccountState().getId(), Short.valueOf(AccountStates.LOANACC_OBLIGATIONSMET));
LoanSummaryEntity loanSummaryEntity = ((LoanBO) accountBO).getLoanSummary();
Assert.assertEquals(amount, loanSummaryEntity.getPrincipalPaid().add(loanSummaryEntity.getFeesPaid()).add(loanSummaryEntity.getInterestPaid()).add(loanSummaryEntity.getPenaltyPaid()));
}
use of org.mifos.accounts.loan.business.LoanSummaryEntity in project head by mifos.
the class GroupLoanAccountServiceFacadeWebTier method generateGroupLoanSummaryDto.
private LoanSummaryDto generateGroupLoanSummaryDto(ArrayList<LoanBO> memberAccounts) {
List<LoanSummaryEntity> memberSummarys = new ArrayList<LoanSummaryEntity>();
for (LoanBO member : memberAccounts) {
memberSummarys.add(member.getLoanSummary());
}
Money originalPrincipal = new Money(Money.getDefaultCurrency(), 0.0), principalPaid = new Money(Money.getDefaultCurrency(), 0.0), principalDue = new Money(Money.getDefaultCurrency(), 0.0), originalInterest = new Money(Money.getDefaultCurrency(), 0.0), interestPaid = new Money(Money.getDefaultCurrency(), 0.0), interestDue = new Money(Money.getDefaultCurrency(), 0.0), originalFees = new Money(Money.getDefaultCurrency(), 0.0), feesDue = new Money(Money.getDefaultCurrency(), 0.0), originalPenalty = new Money(Money.getDefaultCurrency(), 0.0), feesPaid = new Money(Money.getDefaultCurrency(), 0.0), penaltyPaid = new Money(Money.getDefaultCurrency(), 0.0), penaltyDue = new Money(Money.getDefaultCurrency(), 0.0), totalAmt = new Money(Money.getDefaultCurrency(), 0.0), totalAmtPaid = new Money(Money.getDefaultCurrency(), 0.0), totalAmtDue = new Money(Money.getDefaultCurrency(), 0.0);
for (LoanSummaryEntity entity : memberSummarys) {
originalPrincipal = originalPrincipal.add(entity.getOriginalPrincipal());
principalPaid = principalPaid.add(entity.getPrincipalPaid());
principalDue = principalDue.add(entity.getPrincipalDue());
originalInterest = originalInterest.add(entity.getOriginalInterest());
interestPaid = interestPaid.add(entity.getInterestPaid());
interestDue = interestDue.add(entity.getInterestDue());
originalFees = originalFees.add(entity.getOriginalFees());
feesPaid = feesPaid.add(entity.getFeesPaid());
feesDue = feesDue.add(entity.getFeesDue());
originalPenalty = originalPenalty.add(entity.getOriginalPenalty());
penaltyPaid = penaltyPaid.add(entity.getPenaltyPaid());
penaltyDue = penaltyDue.add(entity.getPenaltyDue());
totalAmt = totalAmt.add(entity.getTotalLoanAmnt());
totalAmtPaid = totalAmtPaid.add(entity.getTotalAmntPaid());
totalAmtDue = totalAmtDue.add(entity.getTotalAmntDue());
}
return new LoanSummaryDto(originalPrincipal.toString(), principalPaid.toString(), principalDue.toString(), originalInterest.toString(), interestPaid.toString(), interestDue.toString(), originalFees.toString(), feesPaid.toString(), feesDue.toString(), originalPenalty.toString(), penaltyPaid.toString(), penaltyDue.toString(), totalAmt.toString(), totalAmtPaid.toString(), totalAmtDue.toString());
}
use of org.mifos.accounts.loan.business.LoanSummaryEntity in project head by mifos.
the class LoanTrxnDetailEntityIntegrationTest method testSuccessSetRunningBalance.
@Test
public void testSuccessSetRunningBalance() throws Exception {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = TestObjectFactory.createWeeklyFeeCenter("Center_Active", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
Date sampleDate = new Date(System.currentTimeMillis());
LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(sampleDate, meeting);
account = TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, sampleDate, loanOffering);
StaticHibernateUtil.flushSession();
account = legacyAccountDao.getAccount(account.getAccountId());
Assert.assertEquals(((LoanBO) account).getLoanOffering().getPrdOfferingName(), "Loan");
List<AccountActionDateEntity> accountActionsToBeUpdated = new ArrayList<AccountActionDateEntity>();
accountActionsToBeUpdated.add(account.getAccountActionDates().iterator().next());
PaymentData paymentData = TestObjectFactory.getLoanAccountPaymentData(accountActionsToBeUpdated, TestUtils.createMoney("700.0"), null, account.getPersonnel(), "423423", Short.valueOf("1"), sampleDate, sampleDate);
IntegrationTestObjectMother.applyAccountPayment(account, paymentData);
Assert.assertEquals(1, account.getAccountPayments().size());
// AccountPaymentEntity payment = account.getAccountPayments().iterator().next();
// Assert.assertEquals(4, payment.getAccountTrxns().size());
// Should we assert something about each of those transactions?
LoanSummaryEntity loanSummaryEntity = ((LoanBO) account).getLoanSummary();
Assert.assertEquals(loanSummaryEntity.getOriginalPrincipal().subtract(loanSummaryEntity.getPrincipalPaid()), ((LoanBO) account).getLoanActivityDetails().iterator().next().getPrincipalOutstanding());
}
Aggregations