Search in sources :

Example 16 with CreateAccountFeeDto

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

the class ImportLoansSavingsFacadeWebTier method saveLoans.

@Override
public ParsedLoansDto saveLoans(ParsedLoansDto parsedLoansDto) {
    List<CreateAccountFeeDto> defaultAccountFees = new ArrayList<CreateAccountFeeDto>();
    List<QuestionGroupDetail> questionGroupDetails = new ArrayList<QuestionGroupDetail>();
    List<CreateAccountPenaltyDto> defaultPenalties = new ArrayList<CreateAccountPenaltyDto>();
    for (ImportedLoanDetail detail : parsedLoansDto.getSuccessfullyParsedRows()) {
        LoanCreationLoanDetailsDto lcldd = loanAccountServiceFacade.retrieveLoanDetailsForLoanAccountCreation(detail.getCustomerId(), detail.getPrdOfferingId(), false);
        RecurringSchedule recurringSchedule = null;
        MeetingDto meetingDto = lcldd.getCustomerMeetingDetail();
        int meetingEvery = (lcldd.isRepaymentIndependentOfMeetingEnabled()) ? lcldd.getLoanOfferingMeetingDetail().getMeetingDetailsDto().getEvery() : meetingDto.getMeetingDetailsDto().getEvery();
        int loanRecurrenceTypeId = (lcldd.isRepaymentIndependentOfMeetingEnabled()) ? lcldd.getLoanOfferingMeetingDetail().getMeetingDetailsDto().getRecurrenceTypeId() : meetingDto.getMeetingDetailsDto().getRecurrenceTypeId();
        if (loanRecurrenceTypeId == 1) {
            recurringSchedule = new WeeklySchedule(meetingEvery, meetingDto.getMeetingDetailsDto().getRecurrenceDetails().getDayOfWeek());
        } else if (loanRecurrenceTypeId == 2) {
            if (meetingDto.getMeetingDetailsDto().getRecurrenceDetails().getWeekOfMonth().equals(0)) {
                recurringSchedule = new MonthlyOnDayOfMonthSchedule(meetingEvery, meetingDto.getMeetingDetailsDto().getRecurrenceDetails().getDayNumber());
            } else {
                recurringSchedule = new MonthlyOnWeekOfMonthSchedule(meetingEvery, meetingDto.getMeetingDetailsDto().getRecurrenceDetails().getWeekOfMonth(), meetingDto.getMeetingDetailsDto().getRecurrenceDetails().getDayOfWeek());
            }
        } else if (loanRecurrenceTypeId == 3) {
            recurringSchedule = new DailySchedule(meetingEvery);
        }
        CreateLoanAccount cla = new CreateLoanAccount(detail.getCustomerId(), new Integer(detail.getPrdOfferingId()), new Integer(detail.getStatus()), detail.getLoanAmount(), lcldd.getMinLoanAmount(), lcldd.getMaxLoanAmount(), detail.getInterestRate().doubleValue(), new LocalDate(detail.getDisbursalDate().getTime()), null, detail.getNumberOfInstallments(), lcldd.getMinNumberOfInstallments(), lcldd.getMaxNumberOfInstallments(), detail.getGracePeriod(), detail.getSourceOfFundId(), detail.getLoanPurposeId(), detail.getCollateralTypeId(), detail.getCollateralNotes(), detail.getExternalId(), lcldd.isRepaymentIndependentOfMeetingEnabled(), recurringSchedule, defaultAccountFees, defaultPenalties);
        cla.setPredefinedAccountNumber(detail.getAccountNumber());
        cla.setFlagId(detail.getFlag());
        this.loanAccountServiceFacade.createLoan(cla, questionGroupDetails, null);
    }
    return null;
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) ArrayList(java.util.ArrayList) WeeklySchedule(org.mifos.clientportfolio.loan.service.WeeklySchedule) LocalDate(org.joda.time.LocalDate) MeetingDto(org.mifos.dto.domain.MeetingDto) DailySchedule(org.mifos.clientportfolio.loan.service.DailySchedule) RecurringSchedule(org.mifos.clientportfolio.loan.service.RecurringSchedule) CreateLoanAccount(org.mifos.clientportfolio.newloan.applicationservice.CreateLoanAccount) CreateAccountPenaltyDto(org.mifos.dto.domain.CreateAccountPenaltyDto) MonthlyOnDayOfMonthSchedule(org.mifos.clientportfolio.loan.service.MonthlyOnDayOfMonthSchedule) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto) LoanCreationLoanDetailsDto(org.mifos.dto.screen.LoanCreationLoanDetailsDto) MonthlyOnWeekOfMonthSchedule(org.mifos.clientportfolio.loan.service.MonthlyOnWeekOfMonthSchedule) ImportedLoanDetail(org.mifos.dto.domain.ImportedLoanDetail)

Example 17 with CreateAccountFeeDto

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

the class CenterServiceFacadeWebTier method createAccountFeeEntities.

private List<AccountFeesEntity> createAccountFeeEntities(List<CreateAccountFeeDto> feesToApply) {
    List<AccountFeesEntity> feesForCustomerAccount = new ArrayList<AccountFeesEntity>();
    for (CreateAccountFeeDto 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) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) LocalizationConverter(org.mifos.framework.util.LocalizationConverter) ArrayList(java.util.ArrayList) FeeBO(org.mifos.accounts.fees.business.FeeBO) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity)

Example 18 with CreateAccountFeeDto

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

the class TestSaveCollectionSheetUtils method createSampleCenterHierarchy.

/**
     * By default generates 1 center, 1 group and 1 client with 1 loan to be disbursed and 1
     * weekly account collection fee. Can be configured to add in other invalid entries.
     */
public void createSampleCenterHierarchy(Date date) throws Exception {
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
    center = new CenterBuilder().withNumberOfExistingCustomersInOffice(3).with(weeklyMeeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
    IntegrationTestObjectMother.createCenter(center, weeklyMeeting);
    group = new GroupBuilder().withMeeting(weeklyMeeting).withName("Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
    IntegrationTestObjectMother.createGroup(group, weeklyMeeting);
    AmountFeeBO weeklyPeriodicFeeForFirstClients = new FeeBuilder().appliesToClientsOnly().withFeeAmount("87.0").withName("First Client Weekly Periodic Fee").withSameRecurrenceAs(weeklyMeeting).with(sampleBranchOffice()).build();
    IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForFirstClients);
    client = new ClientBuilder().withMeeting(weeklyMeeting).withName("Client 1").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(client, weeklyMeeting);
    MeetingBO loanMeeting = TestObjectFactory.createLoanMeeting(client.getCustomerMeeting().getMeeting());
    LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering("Loan", ApplicableTo.CLIENTS, date, PrdStatus.LOAN_ACTIVE, 1200.0, 1.2, 12, InterestType.FLAT, loanMeeting);
    SecurityContext securityContext = new SecurityContextImpl();
    MifosUser principal = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
    Authentication authentication = new TestingAuthenticationToken(principal, principal);
    securityContext.setAuthentication(authentication);
    SecurityContextHolder.setContext(securityContext);
    BigDecimal loanAmount = BigDecimal.valueOf(Double.valueOf("1200.0"));
    BigDecimal minAllowedLoanAmount = loanAmount;
    BigDecimal maxAllowedLoanAmount = loanAmount;
    Double interestRate = Double.valueOf("10.0");
    LocalDate disbursementDate = new LocalDate(date);
    int numberOfInstallments = 12;
    int minAllowedNumberOfInstallments = loanOffering.getEligibleInstallmentSameForAllLoan().getMaxNoOfInstall();
    int maxAllowedNumberOfInstallments = loanOffering.getEligibleInstallmentSameForAllLoan().getMaxNoOfInstall();
    int graceDuration = 0;
    Integer sourceOfFundId = null;
    Integer loanPurposeId = null;
    Integer collateralTypeId = null;
    String collateralNotes = null;
    String externalId = null;
    boolean repaymentScheduleIndependentOfCustomerMeeting = false;
    RecurringSchedule recurringSchedule = null;
    List<CreateAccountFeeDto> accountFees = new ArrayList<CreateAccountFeeDto>();
    CreateLoanAccount createLoanAccount = new CreateLoanAccount(client.getCustomerId(), loanOffering.getPrdOfferingId().intValue(), AccountState.LOAN_APPROVED.getValue().intValue(), loanAmount, minAllowedLoanAmount, maxAllowedLoanAmount, interestRate, disbursementDate, null, numberOfInstallments, minAllowedNumberOfInstallments, maxAllowedNumberOfInstallments, graceDuration, sourceOfFundId, loanPurposeId, collateralTypeId, collateralNotes, externalId, repaymentScheduleIndependentOfCustomerMeeting, recurringSchedule, accountFees, new ArrayList<CreateAccountPenaltyDto>());
    loan = IntegrationTestObjectMother.createClientLoan(createLoanAccount);
    loan.updateDetails(TestUtils.makeUser());
}
Also used : SecurityContextImpl(org.springframework.security.core.context.SecurityContextImpl) MeetingBO(org.mifos.application.meeting.business.MeetingBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ArrayList(java.util.ArrayList) CenterBuilder(org.mifos.domain.builders.CenterBuilder) LocalDate(org.joda.time.LocalDate) CreateLoanAccount(org.mifos.clientportfolio.newloan.applicationservice.CreateLoanAccount) CreateAccountPenaltyDto(org.mifos.dto.domain.CreateAccountPenaltyDto) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto) ClientBuilder(org.mifos.domain.builders.ClientBuilder) MifosUser(org.mifos.security.MifosUser) MifosUserBuilder(org.mifos.builders.MifosUserBuilder) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) BigDecimal(java.math.BigDecimal) FeeBuilder(org.mifos.domain.builders.FeeBuilder) RecurringSchedule(org.mifos.clientportfolio.loan.service.RecurringSchedule) Authentication(org.springframework.security.core.Authentication) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) SecurityContext(org.springframework.security.core.context.SecurityContext) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder)

Example 19 with CreateAccountFeeDto

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

the class GroupLoanAccountController method submitLoanWithBackdatedPaymentsApplication.

private LoanCreationResultDto submitLoanWithBackdatedPaymentsApplication(Integer accountState, LoanAccountFormBean formBean, LoanAccountQuestionGroupFormBean loanAccountQuestionGroupFormBean, LoanAccountCashFlow loanAccountCashFlow, CashFlowSummaryFormBean cashFlowSummaryFormBean, LoanScheduleFormBean loanScheduleFormBean) {
    LocalDate disbursementDate = LoanCreationHelper.translateDisbursementDateToLocalDate(formBean);
    RecurringSchedule recurringSchedule = LoanCreationHelper.determineRecurringSchedule(formBean);
    List<CreateAccountFeeDto> accountFees = LoanCreationHelper.translateToAccountFeeDtos(formBean);
    List<CreateAccountPenaltyDto> accountPenalties = LoanCreationHelper.translateToAccountPenaltyDtos(formBean);
    List<CreateAccountFeeDto> additionalAccountFees = LoanCreationHelper.translateToAdditionalAccountFeeDtos(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());
    Map<Integer, List<LoanPaymentDto>> backdatedMemberLoanPayments = new HashMap<Integer, List<LoanPaymentDto>>();
    List<Integer> memberIds = loanControllerHelper.getSelectedMemberIdsFromFormBean(formBean);
    for (Integer memberId : memberIds) {
        String memberIdString = memberId.toString();
        List<Number> actualPaymentAmountDetails = loanScheduleFormBean.getMemberSchedules().get(memberIdString).getActualPaymentAmounts();
        List<LoanPaymentDto> backdatedLoanPayments = new ArrayList<LoanPaymentDto>();
        List<DateTime> actualPaymentDates = loanScheduleFormBean.getMemberSchedules().get(memberIdString).getActualPaymentDates();
        List<Short> actualPaymentTypes = loanScheduleFormBean.getMemberSchedules().get(memberIdString).getActualPaymentTypes();
        for (int i = 0; i < actualPaymentAmountDetails.size(); ++i) {
            Number actualPaymentAmount = actualPaymentAmountDetails.get(i);
            if (actualPaymentAmount.doubleValue() > 0) {
                LocalDate transactionDate = new LocalDate(actualPaymentDates.get(i));
                backdatedLoanPayments.add(new LoanPaymentDto(actualPaymentAmount.toString(), transactionDate, actualPaymentTypes.get(i), null));
            }
        }
        backdatedMemberLoanPayments.put(memberId, backdatedLoanPayments);
    }
    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);
    return groupLoanAccountServiceFacade.createBackdatedGroupLoan(createGroupLoanAccount, backdatedMemberLoanPayments, loanAccountQuestionGroupFormBean.getQuestionGroups(), loanAccountCashFlow);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) CreateLoanAccount(org.mifos.clientportfolio.newloan.applicationservice.CreateLoanAccount) CreateAccountPenaltyDto(org.mifos.dto.domain.CreateAccountPenaltyDto) CreateGroupLoanAccount(org.mifos.clientportfolio.newloan.applicationservice.CreateGroupLoanAccount) LoanPaymentDto(org.mifos.dto.domain.LoanPaymentDto) ArrayList(java.util.ArrayList) List(java.util.List) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto) BigDecimal(java.math.BigDecimal) RecurringSchedule(org.mifos.clientportfolio.loan.service.RecurringSchedule) HashMap(java.util.HashMap) Map(java.util.Map)

Example 20 with CreateAccountFeeDto

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

the class LoanCreationHelper method translateToAccountFeeDtos.

public static List<CreateAccountFeeDto> translateToAccountFeeDtos(LoanAccountFormBean formBean) {
    List<CreateAccountFeeDto> accountFees = new ArrayList<CreateAccountFeeDto>();
    Number[] defaultFeeIds = formBean.getDefaultFeeId();
    if (defaultFeeIds != null) {
        int feeIndex = 0;
        CreateAccountFeeDto accountFee = null;
        for (Number feeId : defaultFeeIds) {
            Boolean removeDefaultFeeSelected = formBean.getDefaultFeeSelected()[feeIndex];
            if (removeDefaultFeeSelected == null || !removeDefaultFeeSelected) {
                String amount = formBean.getDefaultFeeAmountOrRate()[feeIndex].toString();
                accountFee = new CreateAccountFeeDto(feeId.intValue(), amount);
                accountFees.add(accountFee);
            }
            feeIndex++;
        }
    }
    return accountFees;
}
Also used : ArrayList(java.util.ArrayList) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto)

Aggregations

CreateAccountFeeDto (org.mifos.dto.domain.CreateAccountFeeDto)23 ArrayList (java.util.ArrayList)21 LocalDate (org.joda.time.LocalDate)15 RecurringSchedule (org.mifos.clientportfolio.loan.service.RecurringSchedule)13 CreateAccountPenaltyDto (org.mifos.dto.domain.CreateAccountPenaltyDto)13 BigDecimal (java.math.BigDecimal)12 CreateLoanAccount (org.mifos.clientportfolio.newloan.applicationservice.CreateLoanAccount)12 MeetingBO (org.mifos.application.meeting.business.MeetingBO)9 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)8 List (java.util.List)6 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)6 HashMap (java.util.HashMap)5 FeeBO (org.mifos.accounts.fees.business.FeeBO)5 LoanCreationResultDto (org.mifos.dto.screen.LoanCreationResultDto)5 MifosUser (org.mifos.security.MifosUser)5 Date (java.util.Date)4 DateTime (org.joda.time.DateTime)4 Map (java.util.Map)3 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)3 CreateGroupLoanAccount (org.mifos.clientportfolio.newloan.applicationservice.CreateGroupLoanAccount)3