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);
}
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());
}
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());
}
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());
}
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);
}
Aggregations