Search in sources :

Example 1 with InstallmentDetailsDto

use of org.mifos.dto.domain.InstallmentDetailsDto in project head by mifos.

the class LoanAccountServiceFacadeWebTier method getUpcomingInstallmentDetailsForGroupLoan.

private InstallmentDetailsDto getUpcomingInstallmentDetailsForGroupLoan(final List<AccountActionDateEntity> upcomingAccountActionDate, final MifosCurrency currency) {
    if (upcomingAccountActionDate != null && !upcomingAccountActionDate.isEmpty()) {
        Money subTotal = new Money(Money.getDefaultCurrency());
        Money principalDue = new Money(Money.getDefaultCurrency());
        Money interestDue = new Money(Money.getDefaultCurrency());
        Money totalFeesDueWithMiscFee = new Money(Money.getDefaultCurrency());
        Money penaltyDue = new Money(Money.getDefaultCurrency());
        for (AccountActionDateEntity accAction : upcomingAccountActionDate) {
            LoanScheduleEntity upcomingInstallment = (LoanScheduleEntity) accAction;
            principalDue = principalDue.add(upcomingInstallment.getPenaltyDue());
            interestDue = interestDue.add(upcomingInstallment.getInterestDue());
            totalFeesDueWithMiscFee = totalFeesDueWithMiscFee.add(upcomingInstallment.getTotalFeeDueWithMiscFeeDue());
            penaltyDue = penaltyDue.add(upcomingInstallment.getPenaltyDue());
            subTotal = upcomingInstallment.getPrincipalDue().add(upcomingInstallment.getInterestDue()).add(upcomingInstallment.getTotalFeesDueWithMiscFee()).add(upcomingInstallment.getPenaltyDue());
        }
        return new InstallmentDetailsDto(principalDue.toString(), interestDue.toString(), totalFeesDueWithMiscFee.toString(), penaltyDue.toString(), subTotal.toString());
    }
    String zero = new Money(currency).toString();
    return new InstallmentDetailsDto(zero, zero, zero, zero, zero);
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) OriginalLoanScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanScheduleEntity) Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) InstallmentDetailsDto(org.mifos.dto.domain.InstallmentDetailsDto) LoanInstallmentDetailsDto(org.mifos.dto.domain.LoanInstallmentDetailsDto)

Example 2 with InstallmentDetailsDto

use of org.mifos.dto.domain.InstallmentDetailsDto in project head by mifos.

the class LoanAccountServiceFacadeWebTier method retrieveInstallmentDetails.

@Override
public LoanInstallmentDetailsDto retrieveInstallmentDetails(Integer accountId) {
    MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(mifosUser);
    LoanBO loanBO = this.loanDao.findById(accountId);
    try {
        personnelDao.checkAccessPermission(userContext, loanBO.getOfficeId(), loanBO.getCustomer().getLoanOfficerId());
    } catch (AccountException e) {
        throw new MifosRuntimeException(e.getMessage(), e);
    }
    InstallmentDetailsDto viewUpcomingInstallmentDetails;
    InstallmentDetailsDto viewOverDueInstallmentDetails;
    if (loanBO.isGroupLoanAccount() && null == loanBO.getParentAccount()) {
        List<AccountActionDateEntity> memberDetailsOfNextInstallment = new ArrayList<AccountActionDateEntity>();
        List<List<AccountActionDateEntity>> memberDetailsOfInstallmentsInArrears = new ArrayList<List<AccountActionDateEntity>>();
        for (LoanBO member : loanBO.getMemberAccounts()) {
            memberDetailsOfNextInstallment.add(member.getDetailsOfNextInstallment());
            memberDetailsOfInstallmentsInArrears.add(member.getDetailsOfInstallmentsInArrears());
        }
        viewUpcomingInstallmentDetails = getUpcomingInstallmentDetailsForGroupLoan(memberDetailsOfNextInstallment, loanBO.getCurrency());
        viewOverDueInstallmentDetails = getOverDueInstallmentDetailsForGroupLoan(memberDetailsOfInstallmentsInArrears, loanBO.getCurrency());
    } else {
        viewUpcomingInstallmentDetails = getUpcomingInstallmentDetails(loanBO.getDetailsOfNextInstallment(), loanBO.getCurrency());
        viewOverDueInstallmentDetails = getOverDueInstallmentDetails(loanBO.getDetailsOfInstallmentsInArrears(), loanBO.getCurrency());
    }
    Money upcomingInstallmentSubTotal = new Money(loanBO.getCurrency(), viewUpcomingInstallmentDetails.getSubTotal());
    Money overdueInstallmentSubTotal = new Money(loanBO.getCurrency(), viewOverDueInstallmentDetails.getSubTotal());
    Money totalAmountDue = upcomingInstallmentSubTotal.add(overdueInstallmentSubTotal);
    return new LoanInstallmentDetailsDto(viewUpcomingInstallmentDetails, viewOverDueInstallmentDetails, totalAmountDue.toString(), loanBO.getNextMeetingDate());
}
Also used : InstallmentDetailsDto(org.mifos.dto.domain.InstallmentDetailsDto) LoanInstallmentDetailsDto(org.mifos.dto.domain.LoanInstallmentDetailsDto) UserContext(org.mifos.security.util.UserContext) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) Money(org.mifos.framework.util.helpers.Money) AccountException(org.mifos.accounts.exceptions.AccountException) ArrayList(java.util.ArrayList) List(java.util.List) LoanInstallmentDetailsDto(org.mifos.dto.domain.LoanInstallmentDetailsDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 3 with InstallmentDetailsDto

use of org.mifos.dto.domain.InstallmentDetailsDto in project head by mifos.

the class LoanAccountServiceFacadeWebTier method getOverDueInstallmentDetails.

private InstallmentDetailsDto getOverDueInstallmentDetails(final List<AccountActionDateEntity> overDueInstallmentList, final MifosCurrency currency) {
    Money principalDue = new Money(currency);
    Money interestDue = new Money(currency);
    Money feesDue = new Money(currency);
    Money penaltyDue = new Money(currency);
    for (AccountActionDateEntity accountActionDate : overDueInstallmentList) {
        LoanScheduleEntity installment = (LoanScheduleEntity) accountActionDate;
        principalDue = principalDue.add(installment.getPrincipalDue());
        interestDue = interestDue.add(installment.getInterestDue());
        feesDue = feesDue.add(installment.getTotalFeeDueWithMiscFeeDue());
        penaltyDue = penaltyDue.add(installment.getPenaltyDue());
    }
    Money subTotal = principalDue.add(interestDue).add(feesDue).add(penaltyDue);
    return new InstallmentDetailsDto(principalDue.toString(), interestDue.toString(), feesDue.toString(), penaltyDue.toString(), subTotal.toString());
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) OriginalLoanScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanScheduleEntity) Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) InstallmentDetailsDto(org.mifos.dto.domain.InstallmentDetailsDto) LoanInstallmentDetailsDto(org.mifos.dto.domain.LoanInstallmentDetailsDto)

Example 4 with InstallmentDetailsDto

use of org.mifos.dto.domain.InstallmentDetailsDto in project head by mifos.

the class LoanAccountActionStrutsTest method testGetInstallmentDetails.

@Test
public void testGetInstallmentDetails() throws Exception {
    setMifosUserFromContext();
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    Date startDate = new Date(System.currentTimeMillis());
    accountBO = getLoanAccount(AccountState.LOAN_APPROVED, startDate, 1);
    LoanBO loan = (LoanBO) accountBO;
    for (AccountActionDateEntity accountActionDateEntity : loan.getAccountActionDates()) {
        if (accountActionDateEntity.getInstallmentId().equals(Short.valueOf("1"))) {
            LoanBOTestUtils.setActionDate(accountActionDateEntity, offSetDate(accountActionDateEntity.getActionDate(), -14));
        } else if (accountActionDateEntity.getInstallmentId().equals(Short.valueOf("2"))) {
            LoanBOTestUtils.setActionDate(accountActionDateEntity, offSetDate(accountActionDateEntity.getActionDate(), -7));
        }
    }
    TestObjectFactory.updateObject(loan);
    loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
    setRequestPathInfo("/loanAccountAction.do");
    addRequestParameter("method", "getInstallmentDetails");
    addRequestParameter("accountId", String.valueOf(loan.getAccountId()));
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    verifyForward("viewInstmentDetails_success");
    InstallmentDetailsDto view = (InstallmentDetailsDto) SessionUtils.getAttribute(LoanConstants.VIEW_OVERDUE_INSTALLMENT_DETAILS, request);
    Assert.assertEquals("12.0", view.getInterest());
    //        Assert.assertEquals("100.0", view.getFees());
    Assert.assertEquals("0.0", view.getPenalty());
    Assert.assertEquals("100.0", view.getPrincipal());
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) InstallmentDetailsDto(org.mifos.dto.domain.InstallmentDetailsDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) Date(java.util.Date) Test(org.junit.Test)

Example 5 with InstallmentDetailsDto

use of org.mifos.dto.domain.InstallmentDetailsDto in project head by mifos.

the class LoanAccountServiceFacadeWebTier method getUpcomingInstallmentDetails.

private InstallmentDetailsDto getUpcomingInstallmentDetails(final AccountActionDateEntity upcomingAccountActionDate, final MifosCurrency currency) {
    if (upcomingAccountActionDate != null) {
        LoanScheduleEntity upcomingInstallment = (LoanScheduleEntity) upcomingAccountActionDate;
        Money subTotal = upcomingInstallment.getPrincipalDue().add(upcomingInstallment.getInterestDue()).add(upcomingInstallment.getTotalFeesDueWithMiscFee()).add(upcomingInstallment.getPenaltyDue());
        return new InstallmentDetailsDto(upcomingInstallment.getPrincipalDue().toString(), upcomingInstallment.getInterestDue().toString(), upcomingInstallment.getTotalFeeDueWithMiscFeeDue().toString(), upcomingInstallment.getPenaltyDue().toString(), subTotal.toString());
    }
    String zero = new Money(currency).toString();
    return new InstallmentDetailsDto(zero, zero, zero, zero, zero);
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) OriginalLoanScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanScheduleEntity) Money(org.mifos.framework.util.helpers.Money) InstallmentDetailsDto(org.mifos.dto.domain.InstallmentDetailsDto) LoanInstallmentDetailsDto(org.mifos.dto.domain.LoanInstallmentDetailsDto)

Aggregations

InstallmentDetailsDto (org.mifos.dto.domain.InstallmentDetailsDto)6 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)5 LoanInstallmentDetailsDto (org.mifos.dto.domain.LoanInstallmentDetailsDto)5 Money (org.mifos.framework.util.helpers.Money)5 LoanScheduleEntity (org.mifos.accounts.loan.business.LoanScheduleEntity)4 OriginalLoanScheduleEntity (org.mifos.accounts.loan.business.OriginalLoanScheduleEntity)4 LoanBO (org.mifos.accounts.loan.business.LoanBO)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 Test (org.junit.Test)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 MifosUser (org.mifos.security.MifosUser)1 UserContext (org.mifos.security.util.UserContext)1