Search in sources :

Example 61 with AccountFeesEntity

use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.

the class GroupLoanAccountServiceFacadeWebTier method getGroupLoanScheduleDto.

@Override
public GroupLoanScheduleDto getGroupLoanScheduleDto(CreateGroupLoanAccount loanAccountInfo, List<CreateLoanAccount> memberDetails) {
    DateTime creationDate = new DateTime();
    // 0. verify member details for GLIM group accounts
    for (CreateLoanAccount groupMemberAccount : memberDetails) {
        ClientBO member = this.customerDao.findClientById(groupMemberAccount.getCustomerId());
        if (creationDate.isBefore(new DateTime(member.getCreatedDate()))) {
            throw new BusinessRuleException("errors.cannotCreateLoan.because.clientsAreCreatedInFuture");
        }
    }
    // 1. assemble loan details
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    OfficeBO userOffice = this.officeDao.findOfficeById(user.getBranchId());
    PersonnelBO createdBy = this.personnelDao.findPersonnelById(userContext.getId());
    CustomerBO customer = this.customerDao.findCustomerById(loanAccountInfo.getGroupLoanAccountDetails().getCustomerId());
    if (customer.isGroup()) {
        customer = this.customerDao.findGroupBySystemId(customer.getGlobalCustNum());
    }
    // assemble
    LoanAccountDetail loanAccountDetail = assembleLoanAccountDetail(loanAccountInfo);
    List<AccountFeesEntity> accountFeeEntities = assembleAccountFees(loanAccountInfo.getGroupLoanAccountDetails().getAccountFees());
    List<AccountPenaltiesEntity> accountPenaltyEntities = assembleAccountPenalties(loanAccountInfo.getGroupLoanAccountDetails().getAccountPenalties());
    LoanProductOverridenDetail overridenDetail = new LoanProductOverridenDetail(loanAccountDetail.getLoanAmount(), loanAccountInfo.getGroupLoanAccountDetails().getDisbursementDate(), loanAccountInfo.getGroupLoanAccountDetails().getInterestRate(), loanAccountInfo.getGroupLoanAccountDetails().getNumberOfInstallments(), loanAccountInfo.getGroupLoanAccountDetails().getGraceDuration(), accountFeeEntities, accountPenaltyEntities);
    Integer interestDays = Integer.valueOf(AccountingRules.getNumberOfInterestDays().intValue());
    boolean loanScheduleIndependentOfCustomerMeetingEnabled = loanAccountInfo.getGroupLoanAccountDetails().isRepaymentScheduleIndependentOfCustomerMeeting();
    LoanScheduleConfiguration configuration = new LoanScheduleConfiguration(loanScheduleIndependentOfCustomerMeetingEnabled, interestDays);
    MeetingBO repaymentDayMeeting = null;
    if (loanScheduleIndependentOfCustomerMeetingEnabled) {
        repaymentDayMeeting = this.createNewMeetingForRepaymentDay(loanAccountInfo.getGroupLoanAccountDetails().getDisbursementDate(), loanAccountInfo.getGroupLoanAccountDetails(), loanAccountDetail.getCustomer());
    } else {
        MeetingDto customerMeetingDto = customer.getCustomerMeetingValue().toDto();
        repaymentDayMeeting = new MeetingFactory().create(customerMeetingDto);
        Short recurAfter = loanAccountDetail.getLoanProduct().getLoanOfferingMeeting().getMeeting().getRecurAfter();
        repaymentDayMeeting.getMeetingDetails().setRecurAfter(recurAfter);
    }
    List<DateTime> loanScheduleDates = new ArrayList<DateTime>();
    LoanSchedule loanSchedule = assembleLoanSchedule(loanAccountDetail.getCustomer(), loanAccountDetail.getLoanProduct(), overridenDetail, configuration, repaymentDayMeeting, userOffice, loanScheduleDates, loanAccountInfo.getGroupLoanAccountDetails().getDisbursementDate(), new ArrayList<Number>());
    // 2. create loan
    InstallmentRange installmentRange = new MaxMinNoOfInstall(loanAccountInfo.getGroupLoanAccountDetails().getMinAllowedNumberOfInstallments().shortValue(), loanAccountInfo.getGroupLoanAccountDetails().getMaxAllowedNumberOfInstallments().shortValue(), null);
    AmountRange amountRange = new MaxMinLoanAmount(loanAccountInfo.getGroupLoanAccountDetails().getMaxAllowedLoanAmount().doubleValue(), loanAccountInfo.getGroupLoanAccountDetails().getMinAllowedLoanAmount().doubleValue(), null);
    creationDate = loanAccountInfo.getGroupLoanAccountDetails().getDisbursementDate().toDateMidnight().toDateTime();
    CreationDetail creationDetail = new CreationDetail(creationDate, Integer.valueOf(user.getUserId()));
    LoanBO loan = LoanBO.openGroupLoanAccount(loanAccountDetail.getLoanProduct(), loanAccountDetail.getCustomer(), repaymentDayMeeting, loanSchedule, loanAccountDetail.getAccountState(), loanAccountDetail.getFund(), overridenDetail, configuration, installmentRange, amountRange, creationDetail, createdBy);
    loan.setBusinessActivityId(loanAccountInfo.getGroupLoanAccountDetails().getLoanPurposeId());
    loan.setExternalId(loanAccountInfo.getGroupLoanAccountDetails().getExternalId());
    loan.setCollateralNote(loanAccountInfo.getGroupLoanAccountDetails().getCollateralNotes());
    loan.setCollateralTypeId(loanAccountInfo.getGroupLoanAccountDetails().getCollateralTypeId());
    loan.markAsCreatedWithBackdatedPayments();
    //set up predefined loan account for importing loans
    if (loanAccountInfo.getGroupLoanAccountDetails().getPredefinedAccountNumber() != null) {
        loan.setGlobalAccountNum(loanAccountInfo.getGroupLoanAccountDetails().getPredefinedAccountNumber());
    }
    // for GLIM loans only
    List<CreateLoanAccount> individualMembersOfGroupLoan = new ArrayList<CreateLoanAccount>();
    List<BigDecimal> radio = new ArrayList<BigDecimal>(loan.getNoOfInstallments());
    List<LoanProductOverridenDetail> memberOverridenDetails = new ArrayList<LoanProductOverridenDetail>();
    List<LoanSchedule> memberLoanSchedules = new ArrayList<LoanSchedule>();
    List<ClientBO> clients = new ArrayList<ClientBO>();
    for (CreateLoanAccount groupMemberAccount : memberDetails) {
        ClientBO member = this.customerDao.findClientById(groupMemberAccount.getCustomerId());
        Money loanAmount = new Money(loanAccountDetail.getLoanProduct().getCurrency(), groupMemberAccount.getLoanAmount());
        List<CreateAccountPenaltyDto> defaultAccountPenalties = new ArrayList<CreateAccountPenaltyDto>();
        radio.add(loanAmount.divide(loan.getLoanAmount()));
        int memberCount = memberDetails.size();
        for (CreateAccountPenaltyDto createAccountPenaltyDto : loanAccountInfo.getGroupLoanAccountDetails().getAccountPenalties()) {
            Integer penaltyId = createAccountPenaltyDto.getPenaltyId();
            String amount = createAccountPenaltyDto.getAmount();
            PenaltyBO penaltyBO = this.penaltyDao.findPenaltyById(penaltyId.shortValue());
            if (penaltyBO instanceof AmountPenaltyBO) {
                amount = String.valueOf(Double.valueOf(createAccountPenaltyDto.getAmount()) / memberCount);
            }
            defaultAccountPenalties.add(new CreateAccountPenaltyDto(penaltyId, amount));
        }
        List<AccountFeesEntity> feeEntities = assembleAccountFees(groupMemberAccount.getAccountFees());
        List<AccountPenaltiesEntity> penaltyEntities = assembleAccountPenalties(defaultAccountPenalties);
        LoanProductOverridenDetail memberOverridenDetail = new LoanProductOverridenDetail(loanAmount, feeEntities, overridenDetail, penaltyEntities);
        LoanSchedule memberSchedule = assembleLoanSchedule(member, loanAccountDetail.getLoanProduct(), memberOverridenDetail, configuration, repaymentDayMeeting, userOffice, new ArrayList<DateTime>(), loanAccountInfo.getGroupLoanAccountDetails().getDisbursementDate(), new ArrayList<Number>());
        memberOverridenDetails.add(memberOverridenDetail);
        memberLoanSchedules.add(memberSchedule);
        clients.add(member);
        individualMembersOfGroupLoan.add(groupMemberAccount);
    }
    //for original schedule persisting
    List<LoanBO> memberLoans = new ArrayList<LoanBO>();
    int index = 0;
    for (CreateLoanAccount groupMemberAccount : individualMembersOfGroupLoan) {
        LoanBO memberLoan = LoanBO.openGroupLoanForAccount(loan, loanAccountDetail.getLoanProduct(), clients.get(index), repaymentDayMeeting, memberLoanSchedules.get(index), memberOverridenDetails.get(index), configuration, installmentRange, amountRange, creationDetail, createdBy, Boolean.TRUE);
        if (groupMemberAccount.getLoanPurposeId() > 0) {
            memberLoan.setBusinessActivityId(groupMemberAccount.getLoanPurposeId());
        }
        memberLoan.markAsCreatedWithBackdatedPayments();
        memberLoans.add(memberLoan);
        index++;
    }
    // update loan schedule for Group Loan Account
    loanSchedule = this.loanScheduleService.generateGroupLoanSchedule(loanAccountDetail.getLoanProduct(), repaymentDayMeeting, loanSchedule, memberLoanSchedules, loanAccountInfo.getGroupLoanAccountDetails().getDisbursementDate(), overridenDetail, configuration, userOffice.getOfficeId(), loanAccountDetail.getCustomer(), accountFeeEntities);
    fixMemberAndParentInstallmentDetails(loan, memberLoans);
    // translate schedules to dto form
    Map<Integer, LoanScheduleEntity> parentScheduleEntities = loan.getLoanScheduleEntityMap();
    List<LoanCreationInstallmentDto> parentInstallments = new ArrayList<LoanCreationInstallmentDto>();
    Map<Integer, List<LoanCreationInstallmentDto>> memberInstallments = new HashMap<Integer, List<LoanCreationInstallmentDto>>();
    for (CreateLoanAccount member : memberDetails) {
        memberInstallments.put(member.getCustomerId(), new ArrayList<LoanCreationInstallmentDto>());
    }
    Short digitsAfterDecimal = AccountingRules.getDigitsAfterDecimal();
    for (Integer installmentId : parentScheduleEntities.keySet()) {
        LoanScheduleEntity loanScheduleEntity = parentScheduleEntities.get(installmentId);
        parentInstallments.add(loanScheduleEntity.toLoanCreationInstallmentDto(digitsAfterDecimal));
        for (LoanBO memberLoan : memberLoans) {
            LoanScheduleEntity memberLoanScheduleEntity = memberLoan.getLoanScheduleEntityMap().get(installmentId);
            memberInstallments.get(memberLoan.getCustomer().getCustomerId()).add(memberLoanScheduleEntity.toLoanCreationInstallmentDto(digitsAfterDecimal));
        }
    }
    GroupLoanScheduleDto groupScheduleDto = new GroupLoanScheduleDto(customer.getDisplayName(), Double.valueOf(loan.getLoanAmount().getAmountDoubleValue()), loanAccountInfo.getGroupLoanAccountDetails().getDisbursementDate(), loan.getGraceType().getValue().intValue(), parentInstallments);
    groupScheduleDto.setMemberSchedules(new HashMap<Integer, LoanScheduleDto>());
    for (LoanBO memberLoan : memberLoans) {
        Integer id = memberLoan.getCustomer().getCustomerId();
        LoanScheduleDto memberScheduleDto = new LoanScheduleDto(memberLoan.getCustomer().getDisplayName(), Double.valueOf(memberLoan.getLoanAmount().getAmountDoubleValue()), loanAccountInfo.getGroupLoanAccountDetails().getDisbursementDate(), loan.getGraceType().getValue().intValue(), memberInstallments.get(id));
        groupScheduleDto.getMemberSchedules().put(id, memberScheduleDto);
    }
    return groupScheduleDto;
}
Also used : HashMap(java.util.HashMap) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ClientBO(org.mifos.customers.client.business.ClientBO) ArrayList(java.util.ArrayList) MeetingFactory(org.mifos.application.meeting.business.MeetingFactory) DateTime(org.joda.time.DateTime) CreateLoanAccount(org.mifos.clientportfolio.newloan.applicationservice.CreateLoanAccount) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ArrayList(java.util.ArrayList) List(java.util.List) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) PenaltyBO(org.mifos.accounts.penalties.business.PenaltyBO) AmountPenaltyBO(org.mifos.accounts.penalties.business.AmountPenaltyBO) LoanSchedule(org.mifos.clientportfolio.newloan.domain.LoanSchedule) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanScheduleDto(org.mifos.dto.screen.LoanScheduleDto) GroupLoanScheduleDto(org.mifos.dto.screen.GroupLoanScheduleDto) LoanAccountDetail(org.mifos.clientportfolio.newloan.domain.LoanAccountDetail) MaxMinLoanAmount(org.mifos.accounts.loan.business.MaxMinLoanAmount) LoanProductOverridenDetail(org.mifos.clientportfolio.newloan.domain.LoanProductOverridenDetail) LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) AccountPenaltiesEntity(org.mifos.accounts.business.AccountPenaltiesEntity) LoanScheduleConfiguration(org.mifos.clientportfolio.newloan.domain.LoanScheduleConfiguration) Money(org.mifos.framework.util.helpers.Money) BusinessRuleException(org.mifos.service.BusinessRuleException) CreateAccountPenaltyDto(org.mifos.dto.domain.CreateAccountPenaltyDto) InstallmentRange(org.mifos.accounts.productdefinition.business.InstallmentRange) AmountRange(org.mifos.accounts.productdefinition.business.AmountRange) CustomerBO(org.mifos.customers.business.CustomerBO) UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser) CreationDetail(org.mifos.clientportfolio.newloan.domain.CreationDetail) LoanCreationInstallmentDto(org.mifos.dto.domain.LoanCreationInstallmentDto) BigDecimal(java.math.BigDecimal) MeetingDto(org.mifos.dto.domain.MeetingDto) MaxMinNoOfInstall(org.mifos.accounts.loan.business.MaxMinNoOfInstall) AmountPenaltyBO(org.mifos.accounts.penalties.business.AmountPenaltyBO) GroupLoanScheduleDto(org.mifos.dto.screen.GroupLoanScheduleDto)

Example 62 with AccountFeesEntity

use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.

the class GroupLoanAccountServiceFacadeWebTier method assembleAccountFees.

private List<AccountFeesEntity> assembleAccountFees(List<CreateAccountFeeDto> defaultAccountFees) {
    List<AccountFeesEntity> accountFeeEntities = new ArrayList<AccountFeesEntity>();
    for (CreateAccountFeeDto defaultFee : defaultAccountFees) {
        FeeBO fee = this.feeDao.findById(defaultFee.getFeeId().shortValue());
        AccountFeesEntity deafultAccountFeeEntity = new AccountFeesEntity(null, fee, Double.valueOf(defaultFee.getAmount()));
        accountFeeEntities.add(deafultAccountFeeEntity);
    }
    return accountFeeEntities;
}
Also used : ArrayList(java.util.ArrayList) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity)

Example 63 with AccountFeesEntity

use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.

the class GroupServiceFacadeWebTier method convertFeeViewsToAccountFeeEntities.

private List<AccountFeesEntity> convertFeeViewsToAccountFeeEntities(List<ApplicableAccountFeeDto> feesToApply) {
    List<AccountFeesEntity> feesForCustomerAccount = new ArrayList<AccountFeesEntity>();
    for (ApplicableAccountFeeDto feeDto : feesToApply) {
        FeeBO fee = feeDao.findById(feeDto.getFeeId().shortValue());
        Double feeAmount = new LocalizationConverter().getDoubleValueForCurrentLocale(feeDto.getAmount());
        AccountBO nullReferenceForNow = null;
        AccountFeesEntity accountFee = new AccountFeesEntity(nullReferenceForNow, fee, feeAmount);
        feesForCustomerAccount.add(accountFee);
    }
    return feesForCustomerAccount;
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) LocalizationConverter(org.mifos.framework.util.LocalizationConverter) ArrayList(java.util.ArrayList) FeeBO(org.mifos.accounts.fees.business.FeeBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto)

Example 64 with AccountFeesEntity

use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.

the class ClientServiceFacadeWebTier method convertFeeViewsToAccountFeeEntities.

private List<AccountFeesEntity> convertFeeViewsToAccountFeeEntities(List<ApplicableAccountFeeDto> feesToApply) {
    List<AccountFeesEntity> feesForCustomerAccount = new ArrayList<AccountFeesEntity>();
    for (ApplicableAccountFeeDto feeDto : feesToApply) {
        FeeBO fee = this.feeDao.findById(feeDto.getFeeId().shortValue());
        Double feeAmount = new LocalizationConverter().getDoubleValueForCurrentLocale(feeDto.getAmount());
        AccountBO nullReferenceForNow = null;
        AccountFeesEntity accountFee = new AccountFeesEntity(nullReferenceForNow, fee, feeAmount);
        feesForCustomerAccount.add(accountFee);
    }
    return feesForCustomerAccount;
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) LocalizationConverter(org.mifos.framework.util.LocalizationConverter) ArrayList(java.util.ArrayList) FeeBO(org.mifos.accounts.fees.business.FeeBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto)

Example 65 with AccountFeesEntity

use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.

the class ClientServiceFacadeWebTier method createNewClient.

@Override
public CustomerDetailsDto createNewClient(ClientCreationDetail clientCreationDetail, MeetingDto meetingDto, List<SavingsDetailDto> allowedSavingProducts) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    OfficeBO userOffice = this.officeDao.findOfficeById(userContext.getBranchId());
    userContext.setBranchGlobalNum(userOffice.getGlobalOfficeNum());
    try {
        ClientBO client = null;
        List<AccountFeesEntity> feesForCustomerAccount = convertFeeViewsToAccountFeeEntities(clientCreationDetail.getFeesToApply());
        List<SavingsOfferingBO> selectedOfferings = new ArrayList<SavingsOfferingBO>();
        for (Short productId : clientCreationDetail.getSelectedSavingProducts()) {
            if (productId != null) {
                for (SavingsDetailDto savingsOffering : allowedSavingProducts) {
                    if (productId.equals(savingsOffering.getPrdOfferingId())) {
                        SavingsOfferingBO savingsProduct = savingsProductDao.findById(productId.intValue());
                        selectedOfferings.add(savingsProduct);
                    }
                }
            }
        }
        List<ClientInitialSavingsOfferingEntity> offeringsAssociatedInCreate = new ArrayList<ClientInitialSavingsOfferingEntity>();
        for (SavingsOfferingBO offering : selectedOfferings) {
            offeringsAssociatedInCreate.add(new ClientInitialSavingsOfferingEntity(null, offering));
        }
        Short personnelId = null;
        Short officeId = null;
        ClientNameDetailDto spouseNameDetailView = null;
        if (ClientRules.isFamilyDetailsRequired()) {
        //                actionForm.setFamilyDateOfBirth();
        //                actionForm.constructFamilyDetails();
        } else {
            spouseNameDetailView = clientCreationDetail.getSpouseFatherName();
        }
        String secondMiddleName = null;
        ClientNameDetailEntity clientNameDetailEntity = new ClientNameDetailEntity(null, secondMiddleName, clientCreationDetail.getClientNameDetailDto());
        ClientNameDetailEntity spouseFatherNameDetailEntity = null;
        if (spouseNameDetailView != null) {
            spouseFatherNameDetailEntity = new ClientNameDetailEntity(null, secondMiddleName, spouseNameDetailView);
        }
        ClientDetailEntity clientDetailEntity = new ClientDetailEntity();
        clientDetailEntity.updateClientDetails(clientCreationDetail.getClientPersonalDetailDto());
        DateTime dob = new DateTime(clientCreationDetail.getDateOfBirth());
        boolean trainedBool = clientCreationDetail.isTrained();
        DateTime trainedDateTime = null;
        if (clientCreationDetail.getTrainedDate() != null) {
            trainedDateTime = new DateTime(clientCreationDetail.getTrainedDate());
        }
        String clientFirstName = clientCreationDetail.getClientNameDetailDto().getFirstName();
        String clientLastName = clientCreationDetail.getClientNameDetailDto().getLastName();
        String secondLastName = clientCreationDetail.getClientNameDetailDto().getSecondLastName();
        CustomerStatus clientStatus = CustomerStatus.fromInt(clientCreationDetail.getClientStatus());
        PersonnelBO formedBy = this.personnelDao.findPersonnelById(clientCreationDetail.getFormedBy());
        Address address = null;
        if (clientCreationDetail.getAddress() != null) {
            AddressDto dto = clientCreationDetail.getAddress();
            address = new Address(dto.getLine1(), dto.getLine2(), dto.getLine3(), dto.getCity(), dto.getState(), dto.getCountry(), dto.getZip(), dto.getPhoneNumber());
        }
        if (YesNoFlag.YES.getValue().equals(clientCreationDetail.getGroupFlag())) {
            Integer parentGroupId = Integer.parseInt(clientCreationDetail.getParentGroupId());
            CustomerBO group = this.customerDao.findCustomerById(parentGroupId);
            if (group.getPersonnel() != null) {
                personnelId = group.getPersonnel().getPersonnelId();
            }
            officeId = group.getOffice().getOfficeId();
            client = ClientBO.createNewInGroupHierarchy(userContext, clientCreationDetail.getClientName(), clientStatus, new DateTime(clientCreationDetail.getMfiJoiningDate()), group, formedBy, clientNameDetailEntity, dob, clientCreationDetail.getGovernmentId(), trainedBool, trainedDateTime, clientCreationDetail.getGroupFlag(), clientFirstName, clientLastName, secondLastName, spouseFatherNameDetailEntity, clientDetailEntity, offeringsAssociatedInCreate, clientCreationDetail.getExternalId(), address, clientCreationDetail.getActivationDate());
            if (ClientRules.isFamilyDetailsRequired()) {
                client.setFamilyAndNameDetailSets(clientCreationDetail.getFamilyNames(), clientCreationDetail.getFamilyDetails());
            }
            this.customerService.createClient(client, client.getCustomerMeetingValue(), feesForCustomerAccount, selectedOfferings);
        } else {
            personnelId = clientCreationDetail.getLoanOfficerId();
            officeId = clientCreationDetail.getOfficeId();
            PersonnelBO loanOfficer = this.personnelDao.findPersonnelById(personnelId);
            OfficeBO office = this.officeDao.findOfficeById(officeId);
            int lastSearchIdCustomerValue = customerDao.retrieveLastSearchIdValueForNonParentCustomersInOffice(officeId);
            MeetingBO clientMeeting = null;
            if (meetingDto != null) {
                clientMeeting = new MeetingFactory().create(meetingDto);
                clientMeeting.setUserContext(userContext);
            }
            client = ClientBO.createNewOutOfGroupHierarchy(userContext, clientCreationDetail.getClientName(), clientStatus, new DateTime(clientCreationDetail.getMfiJoiningDate()), office, loanOfficer, clientMeeting, formedBy, clientNameDetailEntity, dob, clientCreationDetail.getGovernmentId(), trainedBool, trainedDateTime, clientCreationDetail.getGroupFlag(), clientFirstName, clientLastName, secondLastName, spouseFatherNameDetailEntity, clientDetailEntity, offeringsAssociatedInCreate, clientCreationDetail.getExternalId(), address, lastSearchIdCustomerValue);
            if (ClientRules.isFamilyDetailsRequired()) {
                client.setFamilyAndNameDetailSets(clientCreationDetail.getFamilyNames(), clientCreationDetail.getFamilyDetails());
            }
            try {
                personnelDao.checkAccessPermission(userContext, client.getOfficeId(), client.getLoanOfficerId());
            } catch (AccountException e) {
                throw new MifosRuntimeException("Access denied!", e);
            }
            this.customerService.createClient(client, clientMeeting, feesForCustomerAccount, selectedOfferings);
        }
        clientPhotoService.create(client.getCustomerId().longValue(), clientCreationDetail.getPicture());
        return new CustomerDetailsDto(client.getCustomerId(), client.getGlobalCustNum());
    } catch (CustomerException e) {
        throw new BusinessRuleException(e.getKey(), e.getValues(), e);
    }
}
Also used : Address(org.mifos.framework.business.util.Address) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ClientBO(org.mifos.customers.client.business.ClientBO) ArrayList(java.util.ArrayList) ClientInitialSavingsOfferingEntity(org.mifos.customers.client.business.ClientInitialSavingsOfferingEntity) MeetingFactory(org.mifos.application.meeting.business.MeetingFactory) DateTime(org.joda.time.DateTime) BusinessRuleException(org.mifos.service.BusinessRuleException) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientNameDetailEntity(org.mifos.customers.client.business.ClientNameDetailEntity) ClientDetailEntity(org.mifos.customers.client.business.ClientDetailEntity) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) CustomerException(org.mifos.customers.exceptions.CustomerException) UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser) CustomerAddressDto(org.mifos.dto.domain.CustomerAddressDto) AddressDto(org.mifos.dto.domain.AddressDto) AccountException(org.mifos.accounts.exceptions.AccountException) CustomerStatus(org.mifos.customers.util.helpers.CustomerStatus) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)118 ArrayList (java.util.ArrayList)78 Test (org.junit.Test)65 CenterBuilder (org.mifos.domain.builders.CenterBuilder)46 DateTime (org.joda.time.DateTime)42 MeetingBO (org.mifos.application.meeting.business.MeetingBO)42 CenterBO (org.mifos.customers.center.business.CenterBO)39 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)38 FeeBO (org.mifos.accounts.fees.business.FeeBO)25 Money (org.mifos.framework.util.helpers.Money)25 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)24 UserContext (org.mifos.security.util.UserContext)22 LocalDate (org.joda.time.LocalDate)21 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)21 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)18 FeeInstallment (org.mifos.accounts.util.helpers.FeeInstallment)17 OfficeBO (org.mifos.customers.office.business.OfficeBO)17 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)17 MifosUser (org.mifos.security.MifosUser)16 AccountException (org.mifos.accounts.exceptions.AccountException)14