Search in sources :

Example 1 with LoanPrdPersistence

use of org.mifos.accounts.productdefinition.persistence.LoanPrdPersistence in project head by mifos.

the class LoanBO method getTotalPrincipalAmountInArrearsAndOutsideLateness.

public Money getTotalPrincipalAmountInArrearsAndOutsideLateness() throws PersistenceException {
    Money amount = new Money(getCurrency());
    loanPrdPersistence = new LoanPrdPersistence();
    Date currentDate = DateUtils.getCurrentDateWithoutTimeStamp();
    List<AccountActionDateEntity> actionDateList = getDetailsOfInstallmentsInArrears();
    for (AccountActionDateEntity accountActionDateEntity : actionDateList) {
        if (accountActionDateEntity.isNotPaid() && currentDate.getTime() - accountActionDateEntity.getActionDate().getTime() > loanPrdPersistence.retrieveLatenessForPrd().intValue() * 24 * 60 * 60 * 1000) {
            amount = amount.add(((LoanScheduleEntity) accountActionDateEntity).getPrincipalDue());
        }
    }
    return amount;
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) LoanPrdPersistence(org.mifos.accounts.productdefinition.persistence.LoanPrdPersistence) Date(java.util.Date) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) LocalDate(org.joda.time.LocalDate)

Example 2 with LoanPrdPersistence

use of org.mifos.accounts.productdefinition.persistence.LoanPrdPersistence in project head by mifos.

the class LoanBO method getTotalInterestAmountInArrearsAndOutsideLateness.

public Money getTotalInterestAmountInArrearsAndOutsideLateness() throws PersistenceException {
    Money amount = new Money(getCurrency());
    loanPrdPersistence = new LoanPrdPersistence();
    Date currentDate = DateUtils.getCurrentDateWithoutTimeStamp();
    List<AccountActionDateEntity> actionDateList = getDetailsOfInstallmentsInArrears();
    for (AccountActionDateEntity accountActionDateEntity : actionDateList) {
        if (currentDate.getTime() - accountActionDateEntity.getActionDate().getTime() > loanPrdPersistence.retrieveLatenessForPrd().intValue() * 24 * 60 * 60 * 1000) {
            amount = amount.add(((LoanScheduleEntity) accountActionDateEntity).getInterest());
        }
    }
    return amount;
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) LoanPrdPersistence(org.mifos.accounts.productdefinition.persistence.LoanPrdPersistence) Date(java.util.Date) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) LocalDate(org.joda.time.LocalDate)

Example 3 with LoanPrdPersistence

use of org.mifos.accounts.productdefinition.persistence.LoanPrdPersistence in project head by mifos.

the class LoanBO method getDaysWithoutPayment.

public int getDaysWithoutPayment() throws PersistenceException {
    int daysWithoutPayment = 0;
    loanPrdPersistence = new LoanPrdPersistence();
    if (getDaysInArrears() > loanPrdPersistence.retrieveLatenessForPrd()) {
        daysWithoutPayment = getDaysInArrears().intValue();
    }
    return daysWithoutPayment;
}
Also used : LoanPrdPersistence(org.mifos.accounts.productdefinition.persistence.LoanPrdPersistence)

Example 4 with LoanPrdPersistence

use of org.mifos.accounts.productdefinition.persistence.LoanPrdPersistence in project head by mifos.

the class LoanOfferingBO method update.

public void update(final Short userId, final String prdOfferingName, final String prdOfferingShortName, final ProductCategoryBO prdCategory, final PrdApplicableMasterEntity prdApplicableMaster, final Date startDate, final Date endDate, final String description, final PrdStatus status, final GracePeriodTypeEntity gracePeriodType, final InterestTypesEntity interestTypes, final Short gracePeriodDuration, final Double maxInterestRate, final Double minInterestRate, final Double defInterestRate, final boolean loanCounter, final boolean intDedDisbursement, final boolean prinDueLastInst, final List<FundBO> funds, final List<FeeBO> fees, final List<PenaltyBO> penalties, final Short recurAfter, final RecurrenceType recurrenceType, final LoanPrdActionForm loanPrdActionForm, boolean waiverInterest, Set<QuestionGroupReference> questionGroups) throws ProductDefinitionException {
    logger.debug("Updating loan Offering :" + prdOfferingName);
    super.update(userId, prdOfferingName, prdOfferingShortName, prdCategory, prdApplicableMaster, startDate, endDate, description, status);
    validateForUpdate(gracePeriodType, gracePeriodDuration, interestTypes, maxInterestRate, minInterestRate, defInterestRate, loanCounter, intDedDisbursement, prinDueLastInst, funds, fees, recurAfter);
    setUpdateDetails(userId);
    setGracePeriodTypeAndDuration(intDedDisbursement, gracePeriodType, gracePeriodDuration);
    this.interestTypes = interestTypes;
    this.maxInterestRate = maxInterestRate;
    this.minInterestRate = minInterestRate;
    this.defInterestRate = defInterestRate;
    setLoanCounter(loanCounter);
    setWaiverInterest(waiverInterest);
    setIntDedDisbursement(intDedDisbursement);
    setPrinDueLastInst(prinDueLastInst);
    populateLoanAmountAndInstall(loanPrdActionForm);
    setMeetingDetails(startDate, recurAfter, recurrenceType);
    setFunds(funds);
    setFees(fees);
    setPenalties(penalties);
    mergeQuestionGroups(questionGroups);
    try {
        new LoanPrdPersistence().createOrUpdate(this);
    } catch (PersistenceException e) {
        throw new ProductDefinitionException(e);
    }
    logger.debug("Loan Offering updated:" + prdOfferingName);
}
Also used : LoanPrdPersistence(org.mifos.accounts.productdefinition.persistence.LoanPrdPersistence) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Example 5 with LoanPrdPersistence

use of org.mifos.accounts.productdefinition.persistence.LoanPrdPersistence in project head by mifos.

the class LoanProductService method getDefaultAndAdditionalFees.

/*
     * For a given loan product, return the default fees associated with the
     * loan product and any additional fees that could be applied to it.
     *
     * @param loanProductId the loan product id
     *
     * @param userContext the user context to use when constructing FeeViews
     *
     * @param defaultFees the default fees list to populate
     *
     * @param additionalFees the additional fees list to populate
     *
     * @return the default and additional fees
     *
     * @throws ServiceException the service exception
     */
public void getDefaultAndAdditionalFees(Short loanProductId, UserContext userContext, List<FeeDto> defaultFees, List<FeeDto> additionalFees) throws ServiceException, PersistenceException {
    LoanOfferingBO loanOffering = new LoanPrdPersistence().getLoanOffering(loanProductId);
    List<FeeBO> fees = ApplicationContextProvider.getBean(FeeDao.class).getAllAppllicableFeeForLoanCreation();
    for (FeeBO fee : fees) {
        if (!fee.isPeriodic() || (MeetingBO.isMeetingMatched(fee.getFeeFrequency().getFeeMeetingFrequency(), loanOffering.getLoanOfferingMeeting().getMeeting()))) {
            FeeDto feeDto = new FeeDto(userContext, fee);
            if (loanOffering.isFeePresent(fee)) {
                defaultFees.add(feeDto);
            } else {
                additionalFees.add(feeDto);
            }
        }
    }
}
Also used : LoanPrdPersistence(org.mifos.accounts.productdefinition.persistence.LoanPrdPersistence) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) FeeDto(org.mifos.accounts.fees.business.FeeDto) FeeBO(org.mifos.accounts.fees.business.FeeBO) FeeDao(org.mifos.accounts.fees.persistence.FeeDao)

Aggregations

LoanPrdPersistence (org.mifos.accounts.productdefinition.persistence.LoanPrdPersistence)7 Date (java.util.Date)2 LocalDate (org.joda.time.LocalDate)2 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)2 InstallmentDate (org.mifos.accounts.util.helpers.InstallmentDate)2 Money (org.mifos.framework.util.helpers.Money)2 ArrayList (java.util.ArrayList)1 FeeBO (org.mifos.accounts.fees.business.FeeBO)1 FeeDto (org.mifos.accounts.fees.business.FeeDto)1 FeeDao (org.mifos.accounts.fees.persistence.FeeDao)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 LegacyAccountDao (org.mifos.accounts.persistence.LegacyAccountDao)1 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)1 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)1 Key (org.mifos.config.cache.Key)1 BatchJobException (org.mifos.framework.components.batchjobs.exceptions.BatchJobException)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1 DateTimeService (org.mifos.framework.util.DateTimeService)1