Search in sources :

Example 1 with GracePeriodTypeEntity

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

the class AdminServiceFacadeWebTier method retrieveLoanProductFormReferenceData.

@Override
public LoanProductFormDto retrieveLoanProductFormReferenceData() {
    try {
        LoanPrdBusinessService service = new LoanPrdBusinessService();
        List<ListElement> productCategoryOptions = new ArrayList<ListElement>();
        List<ProductCategoryBO> productCategories = service.getActiveLoanProductCategories();
        for (ProductCategoryBO category : productCategories) {
            productCategoryOptions.add(new ListElement(category.getProductCategoryID().intValue(), category.getProductCategoryName()));
        }
        List<ListElement> applicableForOptions = new ArrayList<ListElement>();
        List<PrdApplicableMasterEntity> applicableCustomerTypes = this.loanProductDao.retrieveLoanApplicableProductCategories();
        for (PrdApplicableMasterEntity entity : applicableCustomerTypes) {
            applicableForOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
        }
        List<ListElement> gracePeriodTypeOptions = new ArrayList<ListElement>();
        List<GracePeriodTypeEntity> gracePeriodTypes = this.loanProductDao.retrieveGracePeriodTypes();
        for (GracePeriodTypeEntity gracePeriodTypeEntity : gracePeriodTypes) {
            gracePeriodTypeOptions.add(new ListElement(gracePeriodTypeEntity.getId().intValue(), gracePeriodTypeEntity.getName()));
        }
        List<ListElement> interestCalcTypesOptions = new ArrayList<ListElement>();
        List<InterestTypesEntity> interestCalcTypes = this.loanProductDao.retrieveInterestTypes();
        for (InterestTypesEntity entity : interestCalcTypes) {
            interestCalcTypesOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
        }
        List<ListElement> sourceOfFunds = new ArrayList<ListElement>();
        List<FundBO> funds = this.fundDao.findAllFunds();
        for (FundBO fund : funds) {
            sourceOfFunds.add(new ListElement(fund.getFundId().intValue(), fund.getFundName()));
        }
        List<ListElement> loanFee = new ArrayList<ListElement>();
        List<FeeBO> fees = feeDao.getAllAppllicableFeeForLoanCreation();
        for (FeeBO fee : fees) {
            loanFee.add(new ListElement(fee.getFeeId().intValue(), fee.getFeeName()));
        }
        List<ListElement> principalGlCodes = new ArrayList<ListElement>();
        List<GLCodeEntity> principalGlCodeEntities = new FinancialBusinessService().getGLCodes(FinancialActionConstants.PRINCIPALPOSTING, FinancialConstants.CREDIT);
        for (GLCodeEntity glCode : principalGlCodeEntities) {
            principalGlCodes.add(new ListElement(glCode.getGlcodeId().intValue(), glCode.getGlcode()));
        }
        List<ListElement> interestGlCodes = new ArrayList<ListElement>();
        List<GLCodeEntity> interestGlCodeEntities = new FinancialBusinessService().getGLCodes(FinancialActionConstants.INTERESTPOSTING, FinancialConstants.CREDIT);
        for (GLCodeEntity glCode : interestGlCodeEntities) {
            interestGlCodes.add(new ListElement(glCode.getGlcodeId().intValue(), glCode.getGlcode()));
        }
        List<ListElement> statusOptions = new ArrayList<ListElement>();
        List<PrdStatusEntity> applicableStatuses = service.getApplicablePrdStatus(Short.valueOf("1"));
        for (PrdStatusEntity entity : applicableStatuses) {
            statusOptions.add(new ListElement(entity.getOfferingStatusId().intValue(), entity.getPrdState().getName()));
        }
        boolean multiCurrencyEnabled = AccountingRules.isMultiCurrencyEnabled();
        List<ListElement> currencyOptions = new ArrayList<ListElement>();
        if (multiCurrencyEnabled) {
            LinkedList<MifosCurrency> currencies = AccountingRules.getCurrencies();
            for (MifosCurrency mifosCurrency : currencies) {
                currencyOptions.add(new ListElement(mifosCurrency.getCurrencyId().intValue(), mifosCurrency.getCurrencyCode()));
            }
        }
        return new LoanProductFormDto(productCategoryOptions, gracePeriodTypeOptions, sourceOfFunds, loanFee, principalGlCodes, interestGlCodes, interestCalcTypesOptions, applicableForOptions, statusOptions, currencyOptions, multiCurrencyEnabled);
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    } catch (SystemException e) {
        throw new MifosRuntimeException(e);
    } catch (ApplicationException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : InterestTypesEntity(org.mifos.application.master.business.InterestTypesEntity) LoanPrdBusinessService(org.mifos.accounts.productdefinition.business.service.LoanPrdBusinessService) ArrayList(java.util.ArrayList) FinancialBusinessService(org.mifos.accounts.financial.business.service.FinancialBusinessService) LoanProductFormDto(org.mifos.dto.screen.LoanProductFormDto) BusinessRuleException(org.mifos.service.BusinessRuleException) SystemException(org.mifos.framework.exceptions.SystemException) GracePeriodTypeEntity(org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity) MifosCurrency(org.mifos.application.master.business.MifosCurrency) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) FundBO(org.mifos.accounts.fund.business.FundBO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) ApplicationException(org.mifos.framework.exceptions.ApplicationException) ListElement(org.mifos.dto.screen.ListElement) PersistenceException(org.mifos.framework.exceptions.PersistenceException) FeeBO(org.mifos.accounts.fees.business.FeeBO) PrdStatusEntity(org.mifos.accounts.productdefinition.business.PrdStatusEntity) PrdApplicableMasterEntity(org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with GracePeriodTypeEntity

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

the class OfficeHierarchyServiceImpl method updateApplicationLabels.

@Override
public void updateApplicationLabels(List<OfficeLevelEntity> changedOfficeLabels, List<LookUpEntity> lookupEntities, List<GracePeriodTypeEntity> gracePeriods, List<LookUpValueEntity> accountStatuses) {
    try {
        transactionHelper.startTransaction();
        for (OfficeLevelEntity entity : changedOfficeLabels) {
            officeDao.save(entity);
            LookUpValueEntity lookupValue = entity.getLookUpValue();
            String messageText = lookupValue.getMessageText();
            if (StringUtils.isBlank(messageText)) {
                messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
            }
            ApplicationContextProvider.getBean(MessageLookup.class).updateLookupValueInCache(entity.getLookUpValue().getLookUpName(), messageText);
        }
        for (GracePeriodTypeEntity entity : gracePeriods) {
            applicationConfigurationDao.save(entity);
            LookUpValueEntity lookupValue = entity.getLookUpValue();
            String messageText = lookupValue.getMessageText();
            if (StringUtils.isBlank(messageText)) {
                messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
            }
            ApplicationContextProvider.getBean(MessageLookup.class).updateLookupValueInCache(entity.getLookUpValue().getLookUpName(), messageText);
        }
        for (LookUpEntity entity : lookupEntities) {
            applicationConfigurationDao.save(entity);
            ApplicationContextProvider.getBean(MessageLookup.class).updateLookupValueInCache(entity.getEntityType(), entity.findLabel());
        }
        for (LookUpValueEntity entity : accountStatuses) {
            applicationConfigurationDao.save(entity);
        }
        transactionHelper.commitTransaction();
        if (!accountStatuses.isEmpty()) {
            MenuRepository.getInstance().removeMenuForAllLocale();
        }
    } catch (BusinessRuleException e) {
        transactionHelper.rollbackTransaction();
        throw e;
    } catch (Exception e) {
        transactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        transactionHelper.closeSession();
    }
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) LookUpEntity(org.mifos.application.master.business.LookUpEntity) MessageLookup(org.mifos.application.master.MessageLookup) GracePeriodTypeEntity(org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException) BusinessRuleException(org.mifos.service.BusinessRuleException) OfficeLevelEntity(org.mifos.customers.office.business.OfficeLevelEntity) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 3 with GracePeriodTypeEntity

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

the class LoanBOTestUtils method createLoanAccountWithDisbursement.

/**
     * Like
     * {@link #createLoanAccount(String, CustomerBO, AccountState, Date, LoanOfferingBO)}
     * but differs in various ways.
     *
     * Note: the manipulation done in this method looks very suspicious and
     * possibly wrong. Tests that use this method should be considered as
     * suspect.
     */
public static LoanBO createLoanAccountWithDisbursement(final CustomerBO customer, final AccountState state, final Date startDate, final LoanOfferingBO loanOffering, final int disbursalType, final Short noOfInstallments) {
    Calendar calendar = new GregorianCalendar();
    calendar.setTime(startDate);
    MeetingBO meeting = TestObjectFactory.createLoanMeeting(customer.getCustomerMeeting().getMeeting());
    List<Date> meetingDates = TestObjectFactory.getMeetingDates(customer.getOfficeId(), meeting, 6);
    MifosCurrency currency = TestUtils.RUPEE;
    List<CreateAccountFeeDto> accountFees = new ArrayList<CreateAccountFeeDto>();
    AmountFeeBO maintanenceFee = (AmountFeeBO) TestObjectFactory.createPeriodicAmountFee("Mainatnence Fee", FeeCategory.LOAN, "100", RecurrenceType.WEEKLY, Short.valueOf("1"));
    IntegrationTestObjectMother.saveFee(maintanenceFee);
    accountFees.add(new CreateAccountFeeDto(maintanenceFee.getFeeId().intValue(), maintanenceFee.getFeeAmount().toString()));
    AccountFeesEntity accountDisbursementFee = null;
    AmountFeeBO disbursementFee = null;
    AccountFeesEntity accountDisbursementFee2 = null;
    AmountFeeBO disbursementFee2 = null;
    if (disbursalType == 1 || disbursalType == 2) {
        disbursementFee = (AmountFeeBO) TestObjectFactory.createOneTimeAmountFee("Disbursement Fee 1", FeeCategory.LOAN, "10", FeePayment.TIME_OF_DISBURSEMENT);
        IntegrationTestObjectMother.saveFee(disbursementFee);
        accountFees.add(new CreateAccountFeeDto(disbursementFee.getFeeId().intValue(), disbursementFee.getFeeAmount().toString()));
        disbursementFee2 = (AmountFeeBO) TestObjectFactory.createOneTimeAmountFee("Disbursement Fee 2", FeeCategory.LOAN, "20", FeePayment.TIME_OF_DISBURSEMENT);
        IntegrationTestObjectMother.saveFee(disbursementFee2);
        accountFees.add(new CreateAccountFeeDto(disbursementFee2.getFeeId().intValue(), disbursementFee2.getFeeAmount().toString()));
    }
    BigDecimal loanAmount = BigDecimal.valueOf(DEFAULT_LOAN_AMOUNT);
    BigDecimal minAllowedLoanAmount = loanAmount;
    BigDecimal maxAllowedLoanAmount = loanAmount;
    Double interestRate = Double.valueOf("10.0");
    LocalDate disbursementDate = new LocalDate(meetingDates.get(0));
    int numberOfInstallments = noOfInstallments;
    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;
    CreateLoanAccount createLoanAccount = new CreateLoanAccount(customer.getCustomerId(), loanOffering.getPrdOfferingId().intValue(), state.getValue().intValue(), loanAmount, minAllowedLoanAmount, maxAllowedLoanAmount, interestRate, disbursementDate, null, numberOfInstallments, minAllowedNumberOfInstallments, maxAllowedNumberOfInstallments, graceDuration, sourceOfFundId, loanPurposeId, collateralTypeId, collateralNotes, externalId, repaymentScheduleIndependentOfCustomerMeeting, recurringSchedule, accountFees, new ArrayList<CreateAccountPenaltyDto>());
    SecurityContext securityContext = new SecurityContextImpl();
    MifosUser principal = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
    Authentication authentication = new TestingAuthenticationToken(principal, principal);
    securityContext.setAuthentication(authentication);
    SecurityContextHolder.setContext(securityContext);
    LoanBO loan = IntegrationTestObjectMother.createClientLoan(createLoanAccount);
    loan.updateDetails(TestUtils.makeUser());
    AccountFeesEntity accountPeriodicFee = new AccountFeesEntity(loan, maintanenceFee, new Double("10.0"));
    AccountTestUtils.addAccountFees(accountPeriodicFee, loan);
    if (disbursalType == 1 || disbursalType == 2) {
        accountDisbursementFee = new AccountFeesEntity(loan, disbursementFee, new Double("10.0"));
        AccountTestUtils.addAccountFees(accountDisbursementFee, loan);
        accountDisbursementFee2 = new AccountFeesEntity(loan, disbursementFee2, new Double("20.0"));
        AccountTestUtils.addAccountFees(accountDisbursementFee2, loan);
    }
    loan.setLoanMeeting(meeting);
    if (// 2-Interest At Disbursement
    disbursalType == 2) {
        loan.setInterestDeductedAtDisbursement(true);
        meetingDates = TestObjectFactory.getMeetingDates(customer.getOfficeId(), loan.getLoanMeeting(), 6);
        short i = 0;
        for (Date date : meetingDates) {
            if (i == 0) {
                i++;
                loan.setDisbursementDate(date);
                LoanScheduleEntity actionDate = (LoanScheduleEntity) loan.getAccountActionDate(i);
                actionDate.setActionDate(new java.sql.Date(date.getTime()));
                actionDate.setInterest(new Money(currency, "12.0"));
                actionDate.setPaymentStatus(PaymentStatus.UNPAID);
                AccountTestUtils.addAccountActionDate(actionDate, loan);
                // periodic fee
                AccountFeesActionDetailEntity accountFeesaction = new LoanFeeScheduleEntity(actionDate, maintanenceFee, accountPeriodicFee, new Money(currency, "10.0"));
                setFeeAmountPaid(accountFeesaction, new Money(currency, "0.0"));
                actionDate.addAccountFeesAction(accountFeesaction);
                // dibursement fee one
                AccountFeesActionDetailEntity accountFeesaction1 = new LoanFeeScheduleEntity(actionDate, disbursementFee, accountDisbursementFee, new Money(currency, "10.0"));
                setFeeAmountPaid(accountFeesaction1, new Money(currency, "0.0"));
                actionDate.addAccountFeesAction(accountFeesaction1);
                // disbursementfee2
                AccountFeesActionDetailEntity accountFeesaction2 = new LoanFeeScheduleEntity(actionDate, disbursementFee2, accountDisbursementFee2, new Money(currency, "20.0"));
                setFeeAmountPaid(accountFeesaction2, new Money(currency, "0.0"));
                actionDate.addAccountFeesAction(accountFeesaction2);
                continue;
            }
            i++;
            LoanScheduleEntity actionDate = (LoanScheduleEntity) loan.getAccountActionDate(i);
            actionDate.setActionDate(new java.sql.Date(date.getTime()));
            actionDate.setPrincipal(new Money(currency, "100.0"));
            actionDate.setInterest(new Money(currency, "12.0"));
            actionDate.setPaymentStatus(PaymentStatus.UNPAID);
            AccountTestUtils.addAccountActionDate(actionDate, loan);
            AccountFeesActionDetailEntity accountFeesaction = new LoanFeeScheduleEntity(actionDate, maintanenceFee, accountPeriodicFee, new Money(currency, "100.0"));
            setFeeAmountPaid(accountFeesaction, new Money(currency, "0.0"));
            actionDate.addAccountFeesAction(accountFeesaction);
        }
    } else if (disbursalType == 1 || disbursalType == 3) {
        loan.setInterestDeductedAtDisbursement(false);
        meetingDates = TestObjectFactory.getMeetingDates(customer.getOfficeId(), loan.getLoanMeeting(), 6);
        short i = 0;
        for (Date date : meetingDates) {
            if (i == 0) {
                i++;
                loan.setDisbursementDate(date);
                continue;
            }
            LoanScheduleEntity actionDate = (LoanScheduleEntity) loan.getAccountActionDate(i++);
            actionDate.setActionDate(new java.sql.Date(date.getTime()));
            actionDate.setPrincipal(new Money(currency, "100.0"));
            actionDate.setInterest(new Money(currency, "12.0"));
            actionDate.setPaymentStatus(PaymentStatus.UNPAID);
            AccountTestUtils.addAccountActionDate(actionDate, loan);
            AccountFeesActionDetailEntity accountFeesaction = new LoanFeeScheduleEntity(actionDate, maintanenceFee, accountPeriodicFee, new Money(currency, "100.0"));
            setFeeAmountPaid(accountFeesaction, new Money(currency, "0.0"));
            actionDate.addAccountFeesAction(accountFeesaction);
        }
    }
    GracePeriodTypeEntity gracePeriodType = new GracePeriodTypeEntity(GraceType.NONE);
    loan.setGracePeriodType(gracePeriodType);
    loan.setCreatedBy(Short.valueOf("1"));
    // Set collateral type to lookup id 109, which references the lookup
    // value 'Type 1'
    loan.setCollateralTypeId(Integer.valueOf("109"));
    InterestTypesEntity interestTypes = new InterestTypesEntity(InterestType.FLAT);
    loan.setInterestType(interestTypes);
    loan.setInterestRate(10.0);
    loan.setCreatedDate(new Date(System.currentTimeMillis()));
    setLoanSummary(loan, currency);
    return loan;
}
Also used : InterestTypesEntity(org.mifos.application.master.business.InterestTypesEntity) SecurityContextImpl(org.springframework.security.core.context.SecurityContextImpl) AccountFeesActionDetailEntity(org.mifos.accounts.business.AccountFeesActionDetailEntity) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) LocalDate(org.joda.time.LocalDate) Money(org.mifos.framework.util.helpers.Money) CreateLoanAccount(org.mifos.clientportfolio.newloan.applicationservice.CreateLoanAccount) CreateAccountPenaltyDto(org.mifos.dto.domain.CreateAccountPenaltyDto) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto) GracePeriodTypeEntity(org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) MifosCurrency(org.mifos.application.master.business.MifosCurrency) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) MifosUser(org.mifos.security.MifosUser) MifosUserBuilder(org.mifos.builders.MifosUserBuilder) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) BigDecimal(java.math.BigDecimal) RecurringSchedule(org.mifos.clientportfolio.loan.service.RecurringSchedule) Authentication(org.springframework.security.core.Authentication) SecurityContext(org.springframework.security.core.context.SecurityContext)

Example 4 with GracePeriodTypeEntity

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

the class TestObjectFactory method createLoanOffering.

public static LoanOfferingBO createLoanOffering(final String name, final String shortName, final ApplicableTo applicableTo, final Date startDate, final PrdStatus offeringStatus, final Double defLnAmnt, final Double defIntRate, final Short defInstallments, final InterestType interestType, final boolean interestDeductedAtDisbursement, final boolean principalDueInLastInstallment, final MeetingBO meeting, final GraceType graceType, final short gracePeriodDuration, final String loanAmountCalcType, final String noOfInstallCalcType, final MifosCurrency currency, VariableInstallmentDetailsBO variableInstallmentDetails) {
    PrdApplicableMasterEntity prdApplicableMaster = new PrdApplicableMasterEntity(applicableTo);
    ProductCategoryBO productCategory = TestObjectFactory.getLoanPrdCategory();
    GracePeriodTypeEntity gracePeriodType = new GracePeriodTypeEntity(graceType);
    InterestTypesEntity interestTypes = new InterestTypesEntity(interestType);
    GLCodeEntity glCodePrincipal = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, TestGeneralLedgerCode.LOANS_TO_CLIENTS);
    GLCodeEntity glCodeInterest = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, TestGeneralLedgerCode.INTEREST_ON_LOANS);
    LoanOfferingBO loanOffering;
    boolean loanCounter = true;
    boolean waiverInterest = true;
    try {
        loanOffering = new LoanOfferingBO(getContext(), name, shortName, productCategory, prdApplicableMaster, startDate, null, null, gracePeriodType, gracePeriodDuration, interestTypes, new Money(currency, defLnAmnt.toString()), new Money(currency, defLnAmnt.toString()), new Money(currency, defLnAmnt.toString()), defIntRate, defIntRate, defIntRate, defInstallments, defInstallments, defInstallments, loanCounter, interestDeductedAtDisbursement, principalDueInLastInstallment, new ArrayList<FundBO>(), new ArrayList<FeeBO>(), new ArrayList<PenaltyBO>(), meeting, glCodePrincipal, glCodeInterest, loanAmountCalcType, noOfInstallCalcType, waiverInterest);
    } catch (ProductDefinitionException e) {
        throw new RuntimeException(e);
    }
    loanOffering.setCurrency(currency);
    PrdStatusEntity prdStatus = testObjectPersistence.retrievePrdStatus(offeringStatus);
    LoanOfferingTestUtils.setStatus(loanOffering, prdStatus);
    LoanOfferingTestUtils.setGracePeriodType(loanOffering, gracePeriodType, gracePeriodDuration);
    if (variableInstallmentDetails != null) {
        loanOffering.setVariableInstallmentsAllowed(true);
        loanOffering.setVariableInstallmentDetails(variableInstallmentDetails);
    }
    IntegrationTestObjectMother.saveLoanProducts(loanOffering);
    return IntegrationTestObjectMother.findLoanProductBySystemId(loanOffering.getGlobalPrdOfferingNum());
}
Also used : InterestTypesEntity(org.mifos.application.master.business.InterestTypesEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) ArrayList(java.util.ArrayList) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) GracePeriodTypeEntity(org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity) PrdStatusEntity(org.mifos.accounts.productdefinition.business.PrdStatusEntity) PrdApplicableMasterEntity(org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity)

Example 5 with GracePeriodTypeEntity

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

the class TestObjectFactory method createLoanOffering.

/**
     * @param defLnAmnt       - Loan Amount same would be set as min and max amounts
     * @param defIntRate      - Interest Rate same would be set as min and max amounts
     * @param defInstallments Number of installments set as min and max amounts
     */
public static LoanOfferingBO createLoanOffering(final String name, final String shortName, final ApplicableTo applicableTo, final Date startDate, final PrdStatus offeringStatus, final Double defLnAmnt, final Double defIntRate, final Short defInstallments, final InterestType interestType, final boolean interestDeductedAtDisbursement, final boolean principalDueInLastInstallment, final MeetingBO meeting, final GraceType graceType) {
    PrdApplicableMasterEntity prdApplicableMaster = new PrdApplicableMasterEntity(applicableTo);
    ProductCategoryBO productCategory = TestObjectFactory.getLoanPrdCategory();
    GracePeriodTypeEntity gracePeriodType = new GracePeriodTypeEntity(graceType);
    InterestTypesEntity interestTypes = new InterestTypesEntity(interestType);
    GLCodeEntity glCodePrincipal = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, Short.valueOf("11"));
    GLCodeEntity glCodeInterest = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, Short.valueOf("21"));
    LoanOfferingBO loanOffering;
    short gracePeriodDuration = (short) 0;
    boolean loanCounter = true;
    boolean waiverInterest = true;
    try {
        loanOffering = new LoanOfferingBO(getContext(), name, shortName, productCategory, prdApplicableMaster, startDate, null, null, gracePeriodType, gracePeriodDuration, interestTypes, TestUtils.createMoney(defLnAmnt), TestUtils.createMoney(defLnAmnt), TestUtils.createMoney(defLnAmnt), defIntRate, defIntRate, defIntRate, defInstallments, defInstallments, defInstallments, loanCounter, interestDeductedAtDisbursement, principalDueInLastInstallment, new ArrayList<FundBO>(), new ArrayList<FeeBO>(), new ArrayList<PenaltyBO>(), meeting, glCodePrincipal, glCodeInterest, waiverInterest);
    } catch (ProductDefinitionException e) {
        throw new RuntimeException(e);
    }
    PrdStatusEntity prdStatus = testObjectPersistence.retrievePrdStatus(offeringStatus);
    LoanOfferingTestUtils.setStatus(loanOffering, prdStatus);
    LoanOfferingTestUtils.setGracePeriodType(loanOffering, gracePeriodType, gracePeriodDuration);
    return (LoanOfferingBO) testObjectPersistence.persist(loanOffering);
}
Also used : InterestTypesEntity(org.mifos.application.master.business.InterestTypesEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) ArrayList(java.util.ArrayList) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) GracePeriodTypeEntity(org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity) PrdStatusEntity(org.mifos.accounts.productdefinition.business.PrdStatusEntity) PrdApplicableMasterEntity(org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity)

Aggregations

GracePeriodTypeEntity (org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity)9 ArrayList (java.util.ArrayList)7 InterestTypesEntity (org.mifos.application.master.business.InterestTypesEntity)7 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)6 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)6 PrdApplicableMasterEntity (org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity)6 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)6 MifosRuntimeException (org.mifos.core.MifosRuntimeException)6 PrdStatusEntity (org.mifos.accounts.productdefinition.business.PrdStatusEntity)5 FeeBO (org.mifos.accounts.fees.business.FeeBO)3 FundBO (org.mifos.accounts.fund.business.FundBO)3 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)3 MifosCurrency (org.mifos.application.master.business.MifosCurrency)3 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)2 MeetingBO (org.mifos.application.meeting.business.MeetingBO)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 BigDecimal (java.math.BigDecimal)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1