Search in sources :

Example 1 with LoanSummaryEntity

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()));
}
Also used : Money(org.mifos.framework.util.helpers.Money) LoanBO(org.mifos.accounts.loan.business.LoanBO) RepayLoanActionForm(org.mifos.accounts.loan.struts.actionforms.RepayLoanActionForm) LoanSummaryEntity(org.mifos.accounts.loan.business.LoanSummaryEntity) Test(org.junit.Test)

Example 2 with LoanSummaryEntity

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()));
}
Also used : Money(org.mifos.framework.util.helpers.Money) LoanBO(org.mifos.accounts.loan.business.LoanBO) RepayLoanActionForm(org.mifos.accounts.loan.struts.actionforms.RepayLoanActionForm) LoanSummaryEntity(org.mifos.accounts.loan.business.LoanSummaryEntity) Test(org.junit.Test)

Example 3 with LoanSummaryEntity

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()));
}
Also used : Money(org.mifos.framework.util.helpers.Money) LoanBO(org.mifos.accounts.loan.business.LoanBO) RepayLoanActionForm(org.mifos.accounts.loan.struts.actionforms.RepayLoanActionForm) LoanSummaryEntity(org.mifos.accounts.loan.business.LoanSummaryEntity) Test(org.junit.Test)

Example 4 with LoanSummaryEntity

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());
}
Also used : Money(org.mifos.framework.util.helpers.Money) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanSummaryDto(org.mifos.dto.screen.LoanSummaryDto) ArrayList(java.util.ArrayList) LoanSummaryEntity(org.mifos.accounts.loan.business.LoanSummaryEntity)

Example 5 with LoanSummaryEntity

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());
}
Also used : PaymentData(org.mifos.accounts.util.helpers.PaymentData) MeetingBO(org.mifos.application.meeting.business.MeetingBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) ArrayList(java.util.ArrayList) Date(java.util.Date) LoanSummaryEntity(org.mifos.accounts.loan.business.LoanSummaryEntity) Test(org.junit.Test)

Aggregations

LoanBO (org.mifos.accounts.loan.business.LoanBO)6 LoanSummaryEntity (org.mifos.accounts.loan.business.LoanSummaryEntity)6 Test (org.junit.Test)5 Money (org.mifos.framework.util.helpers.Money)5 RepayLoanActionForm (org.mifos.accounts.loan.struts.actionforms.RepayLoanActionForm)4 ArrayList (java.util.ArrayList)2 Date (java.util.Date)1 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)1 PaymentData (org.mifos.accounts.util.helpers.PaymentData)1 MeetingBO (org.mifos.application.meeting.business.MeetingBO)1 LoanSummaryDto (org.mifos.dto.screen.LoanSummaryDto)1