use of org.mifos.clientportfolio.newloan.applicationservice.LoanApplicationStateDto in project head by mifos.
the class GroupLoanAccountController method retrieveLoanSchedule.
public LoanScheduleDto retrieveLoanSchedule(int customerId, int productId, LoanAccountFormBean formBean, LoanScheduleFormBean loanScheduleFormBean, boolean resetRedoLoanAccountDetails) {
LoanApplicationStateDto applicationState = loanAccountServiceFacade.retrieveLoanApplicationState();
Integer accountState = applicationState.getConfiguredApplicationId();
LocalDate disbursementDate = LoanCreationHelper.translateDisbursementDateToLocalDate(formBean);
RecurringSchedule recurringSchedule = LoanCreationHelper.determineRecurringSchedule(formBean);
List<CreateAccountFeeDto> accountFees = LoanCreationHelper.translateToAccountFeeDtos(formBean);
List<CreateAccountFeeDto> additionalAccountFees = LoanCreationHelper.translateToAdditionalAccountFeeDtos(formBean);
List<CreateAccountPenaltyDto> accountPenalties = LoanCreationHelper.translateToAccountPenaltyDtos(formBean);
accountFees.addAll(additionalAccountFees);
Map<String, List<CreateAccountFeeDto>> memberAccountsFees = LoanCreationHelper.translateToMemberAccountsFeeDtos(formBean);
Map<String, List<CreateAccountFeeDto>> memberAccountsAdditionalFees = LoanCreationHelper.translateToMemberAccountsAdditionalFeeDtos(formBean);
for (Map.Entry<String, List<CreateAccountFeeDto>> memberAccountEntry : memberAccountsAdditionalFees.entrySet()) {
memberAccountsFees.get(memberAccountEntry.getKey()).addAll(memberAccountsAdditionalFees.get(memberAccountEntry.getKey()));
}
BigDecimal loanAmount = BigDecimal.valueOf(formBean.getAmount().doubleValue());
BigDecimal minAllowedLoanAmount = BigDecimal.valueOf(formBean.getMinAllowedAmount().doubleValue());
BigDecimal maxAllowedLoanAmount = BigDecimal.valueOf(formBean.getMaxAllowedAmount().doubleValue());
CreateLoanAccount loanAccountDetails = prepareLoanAccount(accountState, formBean, disbursementDate, recurringSchedule, accountFees, accountPenalties, loanAmount, minAllowedLoanAmount, maxAllowedLoanAmount);
List<CreateLoanAccount> memberAccounts = createGroupLoanMembers(accountState, formBean, disbursementDate, recurringSchedule, memberAccountsFees, accountPenalties, loanAmount, minAllowedLoanAmount, maxAllowedLoanAmount);
BigDecimal totalLoanAmount = BigDecimal.valueOf(formBean.getAmount().doubleValue());
CreateGroupLoanAccount createGroupLoanAccount = new CreateGroupLoanAccount(memberAccounts, totalLoanAmount, loanAccountDetails);
GroupLoanScheduleDto groupLoanScheduleDto = groupLoanAccountServiceFacade.getGroupLoanScheduleDto(createGroupLoanAccount, memberAccounts);
List<String> globalMemberIds = loanControllerHelper.getSelectedMemberGlobalIds(formBean);
List<Integer> memberIds = loanControllerHelper.getSelectedMemberIdsFromFormBean(formBean);
List<BigDecimal> memberAmounts = loanControllerHelper.getSelectedMemberAmounts(formBean);
loanScheduleFormBean.setVariableInstallments(groupLoanScheduleDto.getInstallments());
for (int i = 0; i < memberIds.size(); ++i) {
Integer memberId = memberIds.get(i);
String memberIdString = memberId.toString();
LoanScheduleFormBean memberScheduleBean = loanScheduleFormBean.getMemberSchedules().get(memberIdString);
if (memberScheduleBean == null) {
memberScheduleBean = new LoanScheduleFormBean();
}
memberScheduleBean.setGlobalCustomerId(globalMemberIds.get(i));
loanScheduleFormBean.getMemberSchedules().put(memberIdString, memberScheduleBean);
LoanScheduleDto memberLoanSchedule = groupLoanScheduleDto.getMemberSchedules().get(memberId);
loanControllerHelper.populateFormBeanFromDto(memberId, productId, formBean, memberScheduleBean, disbursementDate, memberLoanSchedule, resetRedoLoanAccountDetails);
memberScheduleBean.setLoanPrincipal(memberAmounts.get(i));
loanScheduleFormBean.setInstallments(memberScheduleBean.getInstallments());
}
loanScheduleFormBean.setActualPaymentAmounts(new ArrayList<Number>());
return groupLoanScheduleDto;
}
use of org.mifos.clientportfolio.newloan.applicationservice.LoanApplicationStateDto in project head by mifos.
the class LoanAccountServiceFacadeWebTier method retrieveLoanApplicationState.
@Override
public LoanApplicationStateDto retrieveLoanApplicationState() {
AccountState applicationState = AccountState.LOAN_APPROVED;
boolean loanPendingApprovalEnabled = ProcessFlowRules.isLoanPendingApprovalStateEnabled();
if (loanPendingApprovalEnabled) {
applicationState = AccountState.LOAN_PENDING_APPROVAL;
}
return new LoanApplicationStateDto(AccountState.LOAN_PARTIAL_APPLICATION.getValue().intValue(), applicationState.getValue().intValue());
}
Aggregations