Example usage for org.joda.time LocalDate toDate

List of usage examples for org.joda.time LocalDate toDate

Introduction

In this page you can find the example usage for org.joda.time LocalDate toDate.

Prototype

@SuppressWarnings("deprecation")
public Date toDate() 

Source Link

Document

Get the date time as a java.util.Date.

Usage

From source file:org.apache.fineract.portfolio.loanaccount.domain.PaymentInventoryPdc.java

License:Apache License

public PaymentInventoryPdc(final PaymentInventory payment, final Integer period, final LocalDate date,
        final BigDecimal amount, final LocalDate chequeDate, final Long chequeno, final String nameOfBank,
        final String ifscCode, final PdcPresentationEnumOption status, final boolean makePresentation) {
    this.paymentInventory = payment;
    this.period = period;
    this.date = date.toDate();
    this.amount = amount;
    this.chequeDate = chequeDate.toDate();
    this.chequeno = chequeno;
    this.nameOfBank = nameOfBank;
    this.ifscCode = ifscCode;
    this.presentationStatus = status.getValue();
    this.makePresentation = makePresentation;
}

From source file:org.apache.fineract.portfolio.loanaccount.loanschedule.service.LoanScheduleAssembler.java

License:Apache License

public LoanScheduleModel assembleLoanScheduleFrom(final JsonElement element) {
    // This method is getting called from calculate loan schedule.
    final LoanApplicationTerms loanApplicationTerms = assembleLoanTerms(element);
    // Get holiday details
    final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();

    final Long clientId = this.fromApiJsonHelper.extractLongNamed("clientId", element);
    final Long groupId = this.fromApiJsonHelper.extractLongNamed("groupId", element);

    Client client = null;//from   w ww. ja  v a 2s.co m
    Group group = null;
    Long officeId = null;
    if (clientId != null) {
        client = this.clientRepository.findOneWithNotFoundDetection(clientId);
        officeId = client.getOffice().getId();
    } else if (groupId != null) {
        group = this.groupRepository.findOneWithNotFoundDetection(groupId);
        officeId = group.getOffice().getId();
    }

    final LocalDate expectedDisbursementDate = this.fromApiJsonHelper
            .extractLocalDateNamed("expectedDisbursementDate", element);
    final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(officeId,
            expectedDisbursementDate.toDate(), HolidayStatusType.ACTIVE.getValue());
    final WorkingDays workingDays = this.workingDaysRepository.findOne();

    validateDisbursementDateIsOnNonWorkingDay(loanApplicationTerms.getExpectedDisbursementDate(), workingDays);
    validateDisbursementDateIsOnHoliday(loanApplicationTerms.getExpectedDisbursementDate(), isHolidayEnabled,
            holidays);

    return assembleLoanScheduleFrom(loanApplicationTerms, isHolidayEnabled, holidays, workingDays, element,
            null);
}

From source file:org.apache.fineract.portfolio.loanaccount.rescheduleloan.service.LoanRescheduleRequestWritePlatformServiceImpl.java

License:Apache License

/**
 * create a new instance of the LoanRescheduleRequest object from the
 * JsonCommand object and persist//from   ww w  . j  a  va 2  s.c o  m
 * 
 * @return CommandProcessingResult object
 **/
@Override
@Transactional
public CommandProcessingResult create(JsonCommand jsonCommand) {

    try {
        // get the loan id from the JsonCommand object
        final Long loanId = jsonCommand.longValueOfParameterNamed(RescheduleLoansApiConstants.loanIdParamName);

        // use the loan id to get a Loan entity object
        final Loan loan = this.loanRepositoryWrapper.findOneWithNotFoundDetection(loanId);

        // validate the request in the JsonCommand object passed as
        // parameter
        this.loanRescheduleRequestDataValidator.validateForCreateAction(jsonCommand, loan);

        // get the reschedule reason code value id from the JsonCommand
        // object
        final Long rescheduleReasonId = jsonCommand
                .longValueOfParameterNamed(RescheduleLoansApiConstants.rescheduleReasonIdParamName);

        // use the reschedule reason code value id to get a CodeValue entity
        // object
        final CodeValue rescheduleReasonCodeValue = this.codeValueRepositoryWrapper
                .findOneWithNotFoundDetection(rescheduleReasonId);

        // get the grace on principal integer value from the JsonCommand
        // object
        final Integer graceOnPrincipal = jsonCommand
                .integerValueOfParameterNamed(RescheduleLoansApiConstants.graceOnPrincipalParamName);

        // get the grace on interest integer value from the JsonCommand
        // object
        final Integer graceOnInterest = jsonCommand
                .integerValueOfParameterNamed(RescheduleLoansApiConstants.graceOnInterestParamName);

        // get the extra terms to be added at the end of the new schedule
        // from the JsonCommand object
        final Integer extraTerms = jsonCommand
                .integerValueOfParameterNamed(RescheduleLoansApiConstants.extraTermsParamName);

        // get the new interest rate that would be applied to the new loan
        // schedule
        final BigDecimal interestRate = jsonCommand
                .bigDecimalValueOfParameterNamed(RescheduleLoansApiConstants.newInterestRateParamName);

        // get the reschedule reason comment text from the JsonCommand
        // object
        final String rescheduleReasonComment = jsonCommand
                .stringValueOfParameterNamed(RescheduleLoansApiConstants.rescheduleReasonCommentParamName);

        // get the recalculate interest option
        final Boolean recalculateInterest = jsonCommand
                .booleanObjectValueOfParameterNamed(RescheduleLoansApiConstants.recalculateInterestParamName);

        // initialize set the value to null
        Date submittedOnDate = null;

        // check if the parameter is in the JsonCommand object
        if (jsonCommand.hasParameter(RescheduleLoansApiConstants.submittedOnDateParamName)) {
            // create a LocalDate object from the "submittedOnDate" Date
            // string
            LocalDate localDate = jsonCommand
                    .localDateValueOfParameterNamed(RescheduleLoansApiConstants.submittedOnDateParamName);

            if (localDate != null) {
                // update the value of the "submittedOnDate" variable
                submittedOnDate = localDate.toDate();
            }
        }

        // initially set the value to null
        Date rescheduleFromDate = null;

        // start point of the rescheduling exercise
        Integer rescheduleFromInstallment = null;

        // initially set the value to null
        Date adjustedDueDate = null;

        // check if the parameter is in the JsonCommand object
        if (jsonCommand.hasParameter(RescheduleLoansApiConstants.rescheduleFromDateParamName)) {
            // create a LocalDate object from the "rescheduleFromDate" Date
            // string
            LocalDate localDate = jsonCommand
                    .localDateValueOfParameterNamed(RescheduleLoansApiConstants.rescheduleFromDateParamName);

            if (localDate != null) {
                // get installment by due date
                LoanRepaymentScheduleInstallment installment = loan.getRepaymentScheduleInstallment(localDate);
                rescheduleFromInstallment = installment.getInstallmentNumber();

                // update the value of the "rescheduleFromDate" variable
                rescheduleFromDate = localDate.toDate();
            }
        }

        if (jsonCommand.hasParameter(RescheduleLoansApiConstants.adjustedDueDateParamName)) {
            // create a LocalDate object from the "adjustedDueDate" Date
            // string
            LocalDate localDate = jsonCommand
                    .localDateValueOfParameterNamed(RescheduleLoansApiConstants.adjustedDueDateParamName);

            if (localDate != null) {
                // update the value of the "adjustedDueDate"variable
                adjustedDueDate = localDate.toDate();
            }
        }

        final LoanRescheduleRequest loanRescheduleRequest = LoanRescheduleRequest.instance(loan,
                LoanStatus.SUBMITTED_AND_PENDING_APPROVAL.getValue(), rescheduleFromInstallment,
                graceOnPrincipal, graceOnInterest, rescheduleFromDate, adjustedDueDate, extraTerms,
                recalculateInterest, interestRate, rescheduleReasonCodeValue, rescheduleReasonComment,
                submittedOnDate, this.platformSecurityContext.authenticatedUser(), null, null, null, null);

        // create a new entry in the m_loan_reschedule_request table
        this.loanRescheduleRequestRepository.save(loanRescheduleRequest);

        return new CommandProcessingResultBuilder().withCommandId(jsonCommand.commandId())
                .withEntityId(loanRescheduleRequest.getId()).withLoanId(loan.getId()).build();
    }

    catch (final DataIntegrityViolationException dve) {
        // handle the data integrity violation
        handleDataIntegrityViolation(dve);

        // return an empty command processing result object
        return CommandProcessingResult.empty();
    }
}

From source file:org.apache.fineract.portfolio.loanaccount.service.LoanAssembler.java

License:Apache License

public Set<LoanDisbursementDetails> fetchDisbursementData(final JsonObject command) {
    final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(command);
    final String dateFormat = this.fromApiJsonHelper.extractDateFormatParameter(command);
    Set<LoanDisbursementDetails> disbursementDatas = new HashSet<>();
    if (command.has(LoanApiConstants.disbursementDataParameterName)) {
        final JsonArray disbursementDataArray = command
                .getAsJsonArray(LoanApiConstants.disbursementDataParameterName);
        if (disbursementDataArray != null && disbursementDataArray.size() > 0) {
            int i = 0;
            do {/*from   ww w. ja v a 2 s  .c o  m*/
                final JsonObject jsonObject = disbursementDataArray.get(i).getAsJsonObject();
                Date expectedDisbursementDate = null;
                Date actualDisbursementDate = null;
                BigDecimal principal = null;

                if (jsonObject.has(LoanApiConstants.disbursementDateParameterName)) {
                    LocalDate date = this.fromApiJsonHelper.extractLocalDateNamed(
                            LoanApiConstants.disbursementDateParameterName, jsonObject, dateFormat, locale);
                    if (date != null) {
                        expectedDisbursementDate = date.toDate();
                    }
                }
                if (jsonObject.has(LoanApiConstants.disbursementPrincipalParameterName)
                        && jsonObject.get(LoanApiConstants.disbursementPrincipalParameterName).isJsonPrimitive()
                        && StringUtils.isNotBlank((jsonObject
                                .get(LoanApiConstants.disbursementPrincipalParameterName).getAsString()))) {
                    principal = jsonObject
                            .getAsJsonPrimitive(LoanApiConstants.disbursementPrincipalParameterName)
                            .getAsBigDecimal();
                }

                disbursementDatas.add(new LoanDisbursementDetails(expectedDisbursementDate,
                        actualDisbursementDate, principal));
                i++;
            } while (i < disbursementDataArray.size());
        }
    }
    return disbursementDatas;
}

From source file:org.apache.fineract.portfolio.loanaccount.service.LoanWritePlatformServiceJpaRepositoryImpl.java

License:Apache License

private void updateLoanCounters(final Loan loan, final LocalDate actualDisbursementDate) {

    if (loan.isGroupLoan()) {
        final List<Loan> loansToUpdateForLoanCounter = this.loanRepository.getGroupLoansDisbursedAfter(
                actualDisbursementDate.toDate(), loan.getGroupId(), AccountType.GROUP.getValue());
        final Integer newLoanCounter = getNewGroupLoanCounter(loan);
        final Integer newLoanProductCounter = getNewGroupLoanProductCounter(loan);
        updateLoanCounter(loan, loansToUpdateForLoanCounter, newLoanCounter, newLoanProductCounter);
    } else {//from  w w  w. j a v  a2  s . c om
        final List<Loan> loansToUpdateForLoanCounter = this.loanRepository
                .getClientOrJLGLoansDisbursedAfter(actualDisbursementDate.toDate(), loan.getClientId());
        final Integer newLoanCounter = getNewClientOrJLGLoanCounter(loan);
        final Integer newLoanProductCounter = getNewClientOrJLGLoanProductCounter(loan);
        updateLoanCounter(loan, loansToUpdateForLoanCounter, newLoanCounter, newLoanProductCounter);
    }
}

From source file:org.apache.fineract.portfolio.loanproduct.domain.LoanProduct.java

License:Apache License

public LoanProduct(final Fund fund, final LoanTransactionProcessingStrategy transactionProcessingStrategy,
        final String name, final String shortName, final String description, final MonetaryCurrency currency,
        final BigDecimal defaultPrincipal, final BigDecimal defaultMinPrincipal,
        final BigDecimal defaultMaxPrincipal, final BigDecimal defaultNominalInterestRatePerPeriod,
        final BigDecimal defaultMinNominalInterestRatePerPeriod,
        final BigDecimal defaultMaxNominalInterestRatePerPeriod,
        final PeriodFrequencyType interestPeriodFrequencyType,
        final BigDecimal defaultAnnualNominalInterestRate, final InterestMethod interestMethod,
        final InterestCalculationPeriodMethod interestCalculationPeriodMethod,
        final boolean considerPartialPeriodInterest, final Integer repayEvery,
        final PeriodFrequencyType repaymentFrequencyType, final Integer defaultNumberOfInstallments,
        final Integer defaultMinNumberOfInstallments, final Integer defaultMaxNumberOfInstallments,
        final Integer graceOnPrincipalPayment, final Integer graceOnInterestPayment,
        final Integer graceOnInterestCharged, final AmortizationMethod amortizationMethod,
        final BigDecimal inArrearsTolerance, final List<Charge> charges,
        final AccountingRuleType accountingRuleType, final boolean includeInBorrowerCycle,
        final LocalDate startDate, final LocalDate closeDate, final String externalId,
        final boolean useBorrowerCycle,
        final Set<LoanProductBorrowerCycleVariations> loanProductBorrowerCycleVariations,
        final boolean multiDisburseLoan, final Integer maxTrancheCount, final BigDecimal outstandingLoanBalance,
        final Integer graceOnArrearsAgeing, final Integer overdueDaysForNPA,
        final DaysInMonthType daysInMonthType, final DaysInYearType daysInYearType,
        final boolean isInterestRecalculationEnabled,
        final LoanProductInterestRecalculationDetails productInterestRecalculationDetails,
        final Integer minimumDaysBetweenDisbursalAndFirstRepayment, final boolean holdGuarantorFunds,
        final LoanProductGuaranteeDetails loanProductGuaranteeDetails,
        final BigDecimal principalThresholdForLastInstallment,
        final boolean accountMovesOutOfNPAOnlyOnArrearsCompletion, final boolean canDefineEmiAmount,
        final Integer installmentAmountInMultiplesOf,
        final LoanProductConfigurableAttributes loanProductConfigurableAttributes,
        Boolean isLinkedToFloatingInterestRates, FloatingRate floatingRate, BigDecimal interestRateDifferential,
        BigDecimal minDifferentialLendingRate, BigDecimal maxDifferentialLendingRate,
        BigDecimal defaultDifferentialLendingRate, Boolean isFloatingInterestRateCalculationAllowed,
        final Boolean isVariableInstallmentsAllowed, final Integer minimumGapBetweenInstallments,
        final Integer maximumGapBetweenInstallments) {
    this.fund = fund;
    this.transactionProcessingStrategy = transactionProcessingStrategy;
    this.name = name.trim();
    this.shortName = shortName.trim();
    if (StringUtils.isNotBlank(description)) {
        this.description = description.trim();
    } else {//from  w w  w .ja va 2 s  .  c  o  m
        this.description = null;
    }

    if (charges != null) {
        this.charges = charges;
    }

    this.isLinkedToFloatingInterestRate = isLinkedToFloatingInterestRates == null ? false
            : isLinkedToFloatingInterestRates;
    if (isLinkedToFloatingInterestRate) {
        this.floatingRates = new LoanProductFloatingRates(floatingRate, this, interestRateDifferential,
                minDifferentialLendingRate, maxDifferentialLendingRate, defaultDifferentialLendingRate,
                isFloatingInterestRateCalculationAllowed);
    }

    this.allowVariabeInstallments = isVariableInstallmentsAllowed == null ? false
            : isVariableInstallmentsAllowed;

    if (allowVariabeInstallments) {
        this.variableInstallmentConfig = new LoanProductVariableInstallmentConfig(this,
                minimumGapBetweenInstallments, maximumGapBetweenInstallments);
    }

    this.loanProductRelatedDetail = new LoanProductRelatedDetail(currency, defaultPrincipal,
            defaultNominalInterestRatePerPeriod, interestPeriodFrequencyType, defaultAnnualNominalInterestRate,
            interestMethod, interestCalculationPeriodMethod, considerPartialPeriodInterest, repayEvery,
            repaymentFrequencyType, defaultNumberOfInstallments, graceOnPrincipalPayment,
            graceOnInterestPayment, graceOnInterestCharged, amortizationMethod, inArrearsTolerance,
            graceOnArrearsAgeing, daysInMonthType.getValue(), daysInYearType.getValue(),
            isInterestRecalculationEnabled);

    this.loanProductRelatedDetail.validateRepaymentPeriodWithGraceSettings();

    this.loanProductMinMaxConstraints = new LoanProductMinMaxConstraints(defaultMinPrincipal,
            defaultMaxPrincipal, defaultMinNominalInterestRatePerPeriod, defaultMaxNominalInterestRatePerPeriod,
            defaultMinNumberOfInstallments, defaultMaxNumberOfInstallments);

    if (accountingRuleType != null) {
        this.accountingRule = accountingRuleType.getValue();
    }
    this.includeInBorrowerCycle = includeInBorrowerCycle;
    this.useBorrowerCycle = useBorrowerCycle;

    if (startDate != null) {
        this.startDate = startDate.toDateTimeAtStartOfDay().toDate();
    }

    if (closeDate != null) {
        this.closeDate = closeDate.toDateTimeAtStartOfDay().toDate();
    }

    this.externalId = externalId;
    this.borrowerCycleVariations = loanProductBorrowerCycleVariations;
    for (LoanProductBorrowerCycleVariations borrowerCycleVariations : this.borrowerCycleVariations) {
        borrowerCycleVariations.updateLoanProduct(this);
    }
    if (loanProductConfigurableAttributes != null) {
        this.loanConfigurableAttributes = loanProductConfigurableAttributes;
        loanConfigurableAttributes.updateLoanProduct(this);
    }

    this.loanProducTrancheDetails = new LoanProductTrancheDetails(multiDisburseLoan, maxTrancheCount,
            outstandingLoanBalance);
    this.overdueDaysForNPA = overdueDaysForNPA;
    this.productInterestRecalculationDetails = productInterestRecalculationDetails;
    this.minimumDaysBetweenDisbursalAndFirstRepayment = minimumDaysBetweenDisbursalAndFirstRepayment;
    this.holdGuaranteeFunds = holdGuarantorFunds;
    this.loanProductGuaranteeDetails = loanProductGuaranteeDetails;
    this.principalThresholdForLastInstallment = principalThresholdForLastInstallment;
    this.accountMovesOutOfNPAOnlyOnArrearsCompletion = accountMovesOutOfNPAOnlyOnArrearsCompletion;
    this.canDefineInstallmentAmount = canDefineEmiAmount;
    this.installmentAmountInMultiplesOf = installmentAmountInMultiplesOf;
}

From source file:org.apache.fineract.portfolio.loanproduct.domain.LoanProductInterestRecalculationDetails.java

License:Apache License

public static LoanProductInterestRecalculationDetails createFrom(final JsonCommand command) {

    final Integer interestRecalculationCompoundingMethod = InterestRecalculationCompoundingMethod
            .fromInt(command.integerValueOfParameterNamed(
                    LoanProductConstants.interestRecalculationCompoundingMethodParameterName))
            .getValue();//from  ww w  .  j a  va2 s.com

    final Integer loanRescheduleStrategyMethod = LoanRescheduleStrategyMethod
            .fromInt(command
                    .integerValueOfParameterNamed(LoanProductConstants.rescheduleStrategyMethodParameterName))
            .getValue();

    final Integer recurrenceFrequency = command
            .integerValueOfParameterNamed(LoanProductConstants.recalculationRestFrequencyTypeParameterName);
    final LocalDate recurrenceOnLocalDate = command
            .localDateValueOfParameterNamed(LoanProductConstants.recalculationRestFrequencyDateParamName);
    Integer recurrenceInterval = command
            .integerValueOfParameterNamed(LoanProductConstants.recalculationRestFrequencyIntervalParameterName);
    final boolean isArrearsBasedOnOriginalSchedule = command.booleanPrimitiveValueOfParameterNamed(
            LoanProductConstants.isArrearsBasedOnOriginalScheduleParamName);
    RecalculationFrequencyType frequencyType = RecalculationFrequencyType.fromInt(recurrenceFrequency);
    Date recurrenceOnDate = null;
    if (recurrenceOnLocalDate != null) {
        if (!frequencyType.isSameAsRepayment()) {
            recurrenceOnDate = recurrenceOnLocalDate.toDate();
        }
    }
    if (frequencyType.isSameAsRepayment()) {
        recurrenceInterval = 0;
    }

    InterestRecalculationCompoundingMethod compoundingMethod = InterestRecalculationCompoundingMethod
            .fromInt(interestRecalculationCompoundingMethod);
    Integer compoundingRecurrenceFrequency = null;
    Integer compoundingInterval = null;
    Date recurrenceOnCompoundingDate = null;
    if (compoundingMethod.isCompoundingEnabled()) {
        compoundingRecurrenceFrequency = command.integerValueOfParameterNamed(
                LoanProductConstants.recalculationCompoundingFrequencyTypeParameterName);
        compoundingInterval = command.integerValueOfParameterNamed(
                LoanProductConstants.recalculationCompoundingFrequencyIntervalParameterName);
        RecalculationFrequencyType compoundingFrequencyType = RecalculationFrequencyType
                .fromInt(compoundingRecurrenceFrequency);
        if (compoundingFrequencyType.isSameAsRepayment()) {
            recurrenceInterval = 0;
        }
        final LocalDate compoundingRecurrenceOnLocalDate = command.localDateValueOfParameterNamed(
                LoanProductConstants.recalculationCompoundingFrequencyDateParamName);

        if (compoundingRecurrenceOnLocalDate != null) {
            if (!compoundingFrequencyType.isSameAsRepayment()) {
                recurrenceOnCompoundingDate = compoundingRecurrenceOnLocalDate.toDate();
            }
        }
    }

    Integer preCloseInterestCalculationStrategy = command
            .integerValueOfParameterNamed(LoanProductConstants.preClosureInterestCalculationStrategyParamName);
    if (preCloseInterestCalculationStrategy == null) {
        preCloseInterestCalculationStrategy = LoanPreClosureInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE
                .getValue();
    }

    return new LoanProductInterestRecalculationDetails(interestRecalculationCompoundingMethod,
            loanRescheduleStrategyMethod, recurrenceFrequency, recurrenceInterval, recurrenceOnDate,
            compoundingRecurrenceFrequency, compoundingInterval, recurrenceOnCompoundingDate,
            isArrearsBasedOnOriginalSchedule, preCloseInterestCalculationStrategy);
}

From source file:org.apache.fineract.portfolio.meeting.domain.Meeting.java

License:Apache License

public Map<String, Object> update(final JsonCommand command) {
    final Map<String, Object> actualChanges = new LinkedHashMap<>(9);
    final String dateFormatAsInput = command.dateFormat();
    final String localeAsInput = command.locale();

    if (command.isChangeInLocalDateParameterNamed(meetingDateParamName, getMeetingDateLocalDate())) {
        final String valueAsInput = command.stringValueOfParameterNamed(meetingDateParamName);
        final LocalDate newValue = command.localDateValueOfParameterNamed(meetingDateParamName);
        actualChanges.put(meetingDateParamName, valueAsInput);
        actualChanges.put("dateFormat", dateFormatAsInput);
        actualChanges.put("locale", localeAsInput);
        this.meetingDate = newValue.toDate();

        if (!isValidMeetingDate(this.calendarInstance, this.meetingDate)) {
            throw new NotValidRecurringDateException("meeting", "Not a valid meeting date", this.meetingDate);
        }/*from   w  w w.  j ava2s . c  o m*/

    }

    return actualChanges;
}

From source file:org.apache.fineract.portfolio.savings.domain.RecurringDepositAccount.java

License:Apache License

public void generateSchedule(final PeriodFrequencyType frequency, final Integer recurringEvery,
        final Calendar calendar) {
    final List<RecurringDepositScheduleInstallment> depositScheduleInstallments = depositScheduleInstallments();
    depositScheduleInstallments.clear();
    LocalDate installmentDate = null;
    if (this.isCalendarInherited()) {
        installmentDate = CalendarUtils.getNextScheduleDate(calendar, accountSubmittedOrActivationDate());
    } else {/*from ww  w  .  j a v a  2s  .  c o  m*/
        installmentDate = depositStartDate();
    }

    int installmentNumber = 1;
    final LocalDate maturityDate = calcualteScheduleTillDate(frequency, recurringEvery);
    final BigDecimal depositAmount = this.recurringDetail.mandatoryRecommendedDepositAmount();
    while (maturityDate.isAfter(installmentDate)) {
        final RecurringDepositScheduleInstallment installment = RecurringDepositScheduleInstallment
                .installment(this, installmentNumber, installmentDate.toDate(), depositAmount);
        depositScheduleInstallments.add(installment);
        installmentDate = DepositAccountUtils.calculateNextDepositDate(installmentDate, frequency,
                recurringEvery);
        installmentNumber += 1;
    }
}

From source file:org.apache.fineract.portfolio.savings.domain.SavingsAccount.java

License:Apache License

protected SavingsAccount(final Client client, final Group group, final SavingsProduct product,
        final Staff savingsOfficer, final String accountNo, final String externalId,
        final SavingsAccountStatusType status, final AccountType accountType, final LocalDate submittedOnDate,
        final AppUser submittedBy, final BigDecimal nominalAnnualInterestRate,
        final SavingsCompoundingInterestPeriodType interestCompoundingPeriodType,
        final SavingsPostingInterestPeriodType interestPostingPeriodType,
        final SavingsInterestCalculationType interestCalculationType,
        final SavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType,
        final BigDecimal minRequiredOpeningBalance, final Integer lockinPeriodFrequency,
        final SavingsPeriodFrequencyType lockinPeriodFrequencyType,
        final boolean withdrawalFeeApplicableForTransfer, final Set<SavingsAccountCharge> savingsAccountCharges,
        final boolean allowOverdraft, final BigDecimal overdraftLimit, final boolean enforceMinRequiredBalance,
        final BigDecimal minRequiredBalance, final BigDecimal nominalAnnualInterestRateOverdraft,
        final BigDecimal minOverdraftForInterestCalculation) {
    this.client = client;
    this.group = group;
    this.product = product;
    this.savingsOfficer = savingsOfficer;
    if (StringUtils.isBlank(accountNo)) {
        this.accountNumber = new RandomPasswordGenerator(19).generate();
        this.accountNumberRequiresAutoGeneration = true;
    } else {/*from  ww  w.ja va 2s  .c  om*/
        this.accountNumber = accountNo;
    }

    this.currency = product.currency();
    this.externalId = externalId;
    this.status = status.getValue();
    this.accountType = accountType.getValue();
    this.submittedOnDate = submittedOnDate.toDate();
    this.submittedBy = submittedBy;
    this.nominalAnnualInterestRate = nominalAnnualInterestRate;
    this.interestCompoundingPeriodType = interestCompoundingPeriodType.getValue();
    this.interestPostingPeriodType = interestPostingPeriodType.getValue();
    this.interestCalculationType = interestCalculationType.getValue();
    this.interestCalculationDaysInYearType = interestCalculationDaysInYearType.getValue();
    this.minRequiredOpeningBalance = minRequiredOpeningBalance;
    this.lockinPeriodFrequency = lockinPeriodFrequency;
    if (lockinPeriodFrequencyType != null) {
        this.lockinPeriodFrequencyType = lockinPeriodFrequencyType.getValue();
    }
    this.withdrawalFeeApplicableForTransfer = withdrawalFeeApplicableForTransfer;

    if (!CollectionUtils.isEmpty(savingsAccountCharges)) {
        this.charges = associateChargesWithThisSavingsAccount(savingsAccountCharges);
    }

    this.summary = new SavingsAccountSummary();
    this.allowOverdraft = allowOverdraft;
    this.overdraftLimit = overdraftLimit;
    this.nominalAnnualInterestRateOverdraft = nominalAnnualInterestRateOverdraft;
    this.minOverdraftForInterestCalculation = minOverdraftForInterestCalculation;
    esnureOverdraftLimitsSetForOverdraftAccounts();

    this.enforceMinRequiredBalance = enforceMinRequiredBalance;
    this.minRequiredBalance = minRequiredBalance;
    this.minBalanceForInterestCalculation = product.minBalanceForInterestCalculation();
    this.savingsOfficerHistory = null;
}