Search in sources :

Example 1 with PrdOfferingMeetingEntity

use of org.mifos.accounts.productdefinition.business.PrdOfferingMeetingEntity in project head by mifos.

the class TestObjectFactory method deleteSpecificAccount.

private static void deleteSpecificAccount(final AccountBO account, final Session session) {
    if (account instanceof LoanBO) {
        LoanBO loan = (LoanBO) account;
        if (null != loan.getLoanSummary()) {
            session.delete(loan.getLoanSummary());
        }
        session.delete(account);
        loan.getLoanOffering().getLoanOfferingMeeting().setMeeting(null);
        session.delete(loan.getLoanOffering().getLoanOfferingMeeting());
        session.delete(loan.getLoanOffering());
    }
    if (account instanceof SavingsBO) {
        SavingsBO savings = (SavingsBO) account;
        session.delete(account);
        // FIXME - no longer create a meeting to track intereswt calculation for each savings account, instead we always use value from savigns product.
        //            session.delete(savings.getTimePerForInstcalc());
        PrdOfferingMeetingEntity prdOfferingMeeting1 = savings.getSavingsOffering().getTimePerForInstcalc();
        prdOfferingMeeting1.setMeeting(null);
        session.delete(prdOfferingMeeting1);
        PrdOfferingMeetingEntity prdOfferingMeeting2 = savings.getSavingsOffering().getFreqOfPostIntcalc();
        prdOfferingMeeting2.setMeeting(null);
        session.delete(prdOfferingMeeting2);
        session.delete(savings.getSavingsOffering());
    } else {
        session.delete(account);
    }
}
Also used : PrdOfferingMeetingEntity(org.mifos.accounts.productdefinition.business.PrdOfferingMeetingEntity) LoanBO(org.mifos.accounts.loan.business.LoanBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO)

Example 2 with PrdOfferingMeetingEntity

use of org.mifos.accounts.productdefinition.business.PrdOfferingMeetingEntity in project head by mifos.

the class AdminServiceFacadeWebTier method updateLoanProduct.

@Override
public PrdOfferingDto updateLoanProduct(LoanProductRequest loanProductRequest) {
    LoanOfferingBO loanProductForUpdate = this.loanProductDao.findById(loanProductRequest.getProductDetails().getId());
    // enforced by integrity constraints on table also.
    if (loanProductForUpdate.isDifferentName(loanProductRequest.getProductDetails().getName())) {
        this.savingsProductDao.validateProductWithSameNameDoesNotExist(loanProductRequest.getProductDetails().getName());
    }
    if (loanProductForUpdate.isDifferentShortName(loanProductRequest.getProductDetails().getShortName())) {
        this.savingsProductDao.validateProductWithSameShortNameDoesNotExist(loanProductRequest.getProductDetails().getShortName());
    }
    // domain rule validation - put on domain entity
    if (loanProductForUpdate.isDifferentStartDate(loanProductRequest.getProductDetails().getStartDate())) {
        validateStartDateIsNotBeforeToday(loanProductRequest.getProductDetails().getStartDate());
        validateStartDateIsNotOverOneYearFromToday(loanProductRequest.getProductDetails().getStartDate());
        validateEndDateIsPastStartDate(loanProductRequest.getProductDetails().getStartDate(), loanProductRequest.getProductDetails().getEndDate());
    }
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(user);
    LoanOfferingBO newLoanProductDetails = this.loanProductAssembler.fromDto(user, loanProductRequest);
    loanProductForUpdate.updateDetails(userContext);
    HibernateTransactionHelper transactionHelper = new HibernateTransactionHelperForStaticHibernateUtil();
    try {
        transactionHelper.startTransaction();
        transactionHelper.beginAuditLoggingFor(loanProductForUpdate);
        loanProductForUpdate.updateDetailsOfProductNotInUse(newLoanProductDetails.getPrdOfferingName(), newLoanProductDetails.getPrdOfferingShortName(), newLoanProductDetails.getDescription(), newLoanProductDetails.getPrdCategory(), newLoanProductDetails.getStartDate(), newLoanProductDetails.getEndDate(), newLoanProductDetails.getPrdApplicableMaster(), newLoanProductDetails.getPrdStatus());
        loanProductForUpdate.update(newLoanProductDetails.isIncludeInLoanCounter(), newLoanProductDetails.isInterestWaived());
        if (newLoanProductDetails.isLoanAmountTypeSameForAllLoan()) {
            loanProductForUpdate.updateLoanAmountDetails(newLoanProductDetails.getEligibleLoanAmountSameForAllLoan());
        } else if (newLoanProductDetails.isLoanAmountTypeAsOfLastLoanAmount()) {
            loanProductForUpdate.updateLoanAmountByLastLoanDetails(newLoanProductDetails.getLoanAmountFromLastLoan());
        } else if (newLoanProductDetails.isLoanAmountTypeFromLoanCycle()) {
            loanProductForUpdate.updateLoanAmountLoanCycleDetails(newLoanProductDetails.getLoanAmountFromLoanCycle());
        }
        loanProductForUpdate.updateInterestRateDetails(newLoanProductDetails.getMinInterestRate(), newLoanProductDetails.getMaxInterestRate(), newLoanProductDetails.getDefInterestRate());
        PrdOfferingMeetingEntity entity = newLoanProductDetails.getLoanOfferingMeeting();
        MeetingBO meeting = new MeetingBO(entity.getMeeting().getRecurrenceType(), entity.getMeeting().getRecurAfter(), entity.getMeeting().getStartDate(), MeetingType.LOAN_INSTALLMENT);
        loanProductForUpdate.updateRepaymentDetails(meeting, newLoanProductDetails.getGracePeriodType(), newLoanProductDetails.getGracePeriodDuration());
        if (newLoanProductDetails.isNoOfInstallTypeSameForAllLoan()) {
            loanProductForUpdate.updateInstallmentDetails(newLoanProductDetails.getNoOfInstallSameForAllLoan());
        } else if (newLoanProductDetails.isNoOfInstallTypeFromLastLoan()) {
            loanProductForUpdate.updateInstallmentByLastLoanDetails(newLoanProductDetails.getNoOfInstallFromLastLoan());
        } else if (newLoanProductDetails.isNoOfInstallTypeFromLoanCycle()) {
            loanProductForUpdate.updateInstallmentLoanCycleDetails(newLoanProductDetails.getNoOfInstallFromLoanCycle());
        }
        loanProductForUpdate.updateFees(newLoanProductDetails.getLoanOfferingFees());
        loanProductForUpdate.updateFunds(newLoanProductDetails.getLoanOfferingFunds());
        loanProductForUpdate.updatePenalties(newLoanProductDetails.getLoanOfferingPenalties());
        this.loanProductDao.save(loanProductForUpdate);
        transactionHelper.commitTransaction();
        return loanProductForUpdate.toDto();
    } catch (Exception e) {
        transactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        transactionHelper.closeSession();
    }
}
Also used : HibernateTransactionHelper(org.mifos.framework.hibernate.helper.HibernateTransactionHelper) PrdOfferingMeetingEntity(org.mifos.accounts.productdefinition.business.PrdOfferingMeetingEntity) HibernateTransactionHelperForStaticHibernateUtil(org.mifos.framework.hibernate.helper.HibernateTransactionHelperForStaticHibernateUtil) UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) BusinessRuleException(org.mifos.service.BusinessRuleException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ServiceException(org.mifos.framework.exceptions.ServiceException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 3 with PrdOfferingMeetingEntity

use of org.mifos.accounts.productdefinition.business.PrdOfferingMeetingEntity in project head by mifos.

the class LoanProductBuilder method build.

private LoanOfferingBO build() {
    final LoanOfferingBO loanProduct = new LoanOfferingBO(depositGLCode, interesetGLCode, interestType, minInterestRate, maxInterestRate, defaultInterestRate, interestPaidAtDisbursement, principalDueLastInstallment, name, shortName, globalProductNumber, startDate, applicableToCustomer, category, productStatusEntity, createdDate, createdByUserId);
    if (useLoanAmountSameForAllLoans) {
        final Double minLoanAmount = Double.valueOf("100.0");
        final Double maxLoanAmount = Double.valueOf("100000.0");
        final Double defaultLoanAmount = Double.valueOf("1000.0");
        loanProduct.setLoanAmountSameForAllLoan(new LoanAmountSameForAllLoanBO(minLoanAmount, maxLoanAmount, defaultLoanAmount, loanProduct));
    }
    if (useNoOfInstallSameForAllLoans) {
        final Short minNoOfInstallmentsForLoan = Short.valueOf("1");
        final Short maxNoOfInstallmentsForLoan = Short.valueOf("11");
        final Short defaultNoOfInstallmentsForLoan = Short.valueOf("6");
        loanProduct.setNoOfInstallSameForAllLoan(new NoOfInstallSameForAllLoanBO(minNoOfInstallmentsForLoan, maxNoOfInstallmentsForLoan, defaultNoOfInstallmentsForLoan, loanProduct));
    }
    loanProduct.setGracePeriodType(new GracePeriodTypeEntity(graceType));
    loanProduct.setLoanOfferingMeeting(new PrdOfferingMeetingEntity(meeting, loanProduct, MeetingType.LOAN_INSTALLMENT));
    return loanProduct;
}
Also used : PrdOfferingMeetingEntity(org.mifos.accounts.productdefinition.business.PrdOfferingMeetingEntity) NoOfInstallSameForAllLoanBO(org.mifos.accounts.productdefinition.business.NoOfInstallSameForAllLoanBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) GracePeriodTypeEntity(org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity) LoanAmountSameForAllLoanBO(org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO)

Example 4 with PrdOfferingMeetingEntity

use of org.mifos.accounts.productdefinition.business.PrdOfferingMeetingEntity in project head by mifos.

the class SavingsProductBuilder method build.

private SavingsOfferingBO build() {
    final SavingsOfferingBO savingsProduct = new SavingsOfferingBO(savingsType, name, shortName, globalProductNumber, startDate, applicableToCustomer, category, productStatusEntity, interestCalcType, interestRate, maxAmountOfWithdrawal, depositGLCode, interesetGLCode, createdDate, createdByUserId);
    savingsProduct.setMinAmntForInt(minAmountForInterestCalculation);
    final PrdOfferingMeetingEntity scheduleForInstcalc = new PrdOfferingMeetingEntity(scheduleForInterestCalculationMeeting, savingsProduct, MeetingType.SAVINGS_INTEREST_CALCULATION_TIME_PERIOD);
    final PrdOfferingMeetingEntity scheduleForInterestPosting = new PrdOfferingMeetingEntity(scheduleForInterestPostingMeeting, savingsProduct, MeetingType.SAVINGS_INTEREST_POSTING);
    savingsProduct.setTimePerForInstcalc(scheduleForInstcalc);
    savingsProduct.setTimePerForInstcalc(scheduleForInterestPosting);
    savingsProduct.setMinAmntForInt(minAmntForInt);
    if (this.mandatoryGroupTrackingType != null) {
        savingsProduct.setRecommendedAmntUnit(this.mandatoryGroupTrackingType);
    }
    savingsProduct.setRecommendedAmount(mandatoryOrRecommendedAmount);
    return savingsProduct;
}
Also used : PrdOfferingMeetingEntity(org.mifos.accounts.productdefinition.business.PrdOfferingMeetingEntity) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO)

Aggregations

PrdOfferingMeetingEntity (org.mifos.accounts.productdefinition.business.PrdOfferingMeetingEntity)4 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)2 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 GracePeriodTypeEntity (org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity)1 LoanAmountSameForAllLoanBO (org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO)1 NoOfInstallSameForAllLoanBO (org.mifos.accounts.productdefinition.business.NoOfInstallSameForAllLoanBO)1 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)1 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)1 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)1 MeetingBO (org.mifos.application.meeting.business.MeetingBO)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 ApplicationException (org.mifos.framework.exceptions.ApplicationException)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1 ServiceException (org.mifos.framework.exceptions.ServiceException)1 SystemException (org.mifos.framework.exceptions.SystemException)1 HibernateTransactionHelper (org.mifos.framework.hibernate.helper.HibernateTransactionHelper)1 HibernateTransactionHelperForStaticHibernateUtil (org.mifos.framework.hibernate.helper.HibernateTransactionHelperForStaticHibernateUtil)1 MifosUser (org.mifos.security.MifosUser)1 UserContext (org.mifos.security.util.UserContext)1 BusinessRuleException (org.mifos.service.BusinessRuleException)1