Search in sources :

Example 1 with LoanApplicationStateDto

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;
}
Also used : LoanApplicationStateDto(org.mifos.clientportfolio.newloan.applicationservice.LoanApplicationStateDto) LocalDate(org.joda.time.LocalDate) CreateLoanAccount(org.mifos.clientportfolio.newloan.applicationservice.CreateLoanAccount) CreateAccountPenaltyDto(org.mifos.dto.domain.CreateAccountPenaltyDto) CreateGroupLoanAccount(org.mifos.clientportfolio.newloan.applicationservice.CreateGroupLoanAccount) ArrayList(java.util.ArrayList) List(java.util.List) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto) LoanScheduleDto(org.mifos.dto.screen.LoanScheduleDto) GroupLoanScheduleDto(org.mifos.dto.screen.GroupLoanScheduleDto) BigDecimal(java.math.BigDecimal) RecurringSchedule(org.mifos.clientportfolio.loan.service.RecurringSchedule) HashMap(java.util.HashMap) Map(java.util.Map) GroupLoanScheduleDto(org.mifos.dto.screen.GroupLoanScheduleDto)

Example 2 with LoanApplicationStateDto

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());
}
Also used : LoanApplicationStateDto(org.mifos.clientportfolio.newloan.applicationservice.LoanApplicationStateDto) AccountState(org.mifos.accounts.util.helpers.AccountState)

Aggregations

LoanApplicationStateDto (org.mifos.clientportfolio.newloan.applicationservice.LoanApplicationStateDto)2 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 LocalDate (org.joda.time.LocalDate)1 AccountState (org.mifos.accounts.util.helpers.AccountState)1 RecurringSchedule (org.mifos.clientportfolio.loan.service.RecurringSchedule)1 CreateGroupLoanAccount (org.mifos.clientportfolio.newloan.applicationservice.CreateGroupLoanAccount)1 CreateLoanAccount (org.mifos.clientportfolio.newloan.applicationservice.CreateLoanAccount)1 CreateAccountFeeDto (org.mifos.dto.domain.CreateAccountFeeDto)1 CreateAccountPenaltyDto (org.mifos.dto.domain.CreateAccountPenaltyDto)1 GroupLoanScheduleDto (org.mifos.dto.screen.GroupLoanScheduleDto)1 LoanScheduleDto (org.mifos.dto.screen.LoanScheduleDto)1