Search in sources :

Example 31 with GLCodeEntity

use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.

the class TestObjectFactory method createOneTimeRateFee.

/**
     * createOneTimeRateFee.
     * <p/>
     * Changing TestObjectFactory#getUserContext() to {@link TestUtils#makeUserWithLocales()} caused a failure in
     * {@link LoanBOIntegrationTest#testApplyUpfrontFee} (and other tests).
     *
     * @param categoryTypeName TODO
     */
public static FeeBO createOneTimeRateFee(final String feeName, final FeeCategory feeCategory, final Double rate, final FeeFormula feeFormula, final FeePayment feePayment, String categoryTypeName) {
    GLCodeEntity glCode = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, TestGeneralLedgerCode.FEES);
    FeeBO fee;
    try {
        LookUpValueEntity lookUpValue = new LookUpValueEntity();
        lookUpValue.setLookUpName(categoryTypeName);
        CategoryTypeEntity categoryType = new CategoryTypeEntity(feeCategory);
        categoryType.setLookUpValue(lookUpValue);
        fee = new RateFeeBO(getUserContext(), feeName, categoryType, new FeeFrequencyTypeEntity(FeeFrequencyType.ONETIME), glCode, rate, new FeeFormulaEntity(feeFormula), false, new FeePaymentEntity(feePayment));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return testObjectPersistence.createFee(fee);
}
Also used : RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) FeeFormulaEntity(org.mifos.accounts.fees.business.FeeFormulaEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException) FeeFrequencyTypeEntity(org.mifos.accounts.fees.business.FeeFrequencyTypeEntity) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) CategoryTypeEntity(org.mifos.accounts.fees.business.CategoryTypeEntity) FeePaymentEntity(org.mifos.accounts.fees.business.FeePaymentEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerException(org.mifos.customers.exceptions.CustomerException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) OfficeException(org.mifos.customers.office.exceptions.OfficeException) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity)

Example 32 with GLCodeEntity

use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.

the class TestObjectFactory method createCompleteLoanOfferingObject.

public static LoanOfferingBO createCompleteLoanOfferingObject() throws Exception {
    PrdApplicableMasterEntity prdApplicableMaster = new PrdApplicableMasterEntity(ApplicableTo.GROUPS);
    MeetingBO frequency = TestObjectFactory.createMeeting(getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    GLCodeEntity principalglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, TestGeneralLedgerCode.BANK_ACCOUNT_ONE);
    GLCodeEntity intglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, TestGeneralLedgerCode.BANK_ACCOUNT_ONE);
    ProductCategoryBO productCategory = getLoanPrdCategory();
    InterestTypesEntity interestTypes = new InterestTypesEntity(InterestType.FLAT);
    GracePeriodTypeEntity gracePeriodType = new GracePeriodTypeEntity(GraceType.GRACEONALLREPAYMENTS);
    List<FeeBO> fees = new ArrayList<FeeBO>();
    List<FundBO> funds = new ArrayList<FundBO>();
    FundBO fundBO = (FundBO) StaticHibernateUtil.getSessionTL().get(FundBO.class, Short.valueOf("2"));
    funds.add(fundBO);
    LoanOfferingBO loanOfferingBO = new LoanOfferingBO(getContext(), "Loan Offering", "LOAP", productCategory, prdApplicableMaster, DateUtils.getCurrentDateWithoutTimeStamp(), null, null, gracePeriodType, (short) 2, interestTypes, TestUtils.createMoney("1000"), TestUtils.createMoney("3000"), TestUtils.createMoney("2000.0"), 12.0, 2.0, 3.0, (short) 20, (short) 11, (short) 17, false, false, false, funds, fees, null, frequency, principalglCodeEntity, intglCodeEntity, true);
    loanOfferingBO.save();
    return loanOfferingBO;
}
Also used : InterestTypesEntity(org.mifos.application.master.business.InterestTypesEntity) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) FundBO(org.mifos.accounts.fund.business.FundBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) GracePeriodTypeEntity(org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity) PrdApplicableMasterEntity(org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity)

Example 33 with GLCodeEntity

use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.

the class AdminServiceFacadeWebTier method retrieveSavingsProductFormReferenceData.

@Override
public SavingsProductFormDto retrieveSavingsProductFormReferenceData() {
    try {
        SavingsPrdBusinessService service = new SavingsPrdBusinessService();
        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()));
        }
        List<ListElement> penaltiesOptions = new ArrayList<ListElement>();
        List<PenaltyBO> applicablePenalties = this.penaltyDao.findAllSavingPenalties();
        for (PenaltyBO entity : applicablePenalties) {
            penaltiesOptions.add(new ListElement(entity.getPenaltyId().intValue(), entity.getPenaltyName()));
        }
        List<ListElement> productCategoryOptions = new ArrayList<ListElement>();
        List<ProductCategoryBO> productCategories = service.getActiveSavingsProductCategories();
        for (ProductCategoryBO category : productCategories) {
            productCategoryOptions.add(new ListElement(category.getProductCategoryID().intValue(), category.getProductCategoryName()));
        }
        List<ListElement> applicableForOptions = new ArrayList<ListElement>();
        List<PrdApplicableMasterEntity> applicableCustomerTypes = this.loanProductDao.retrieveSavingsApplicableProductCategories();
        for (PrdApplicableMasterEntity entity : applicableCustomerTypes) {
            applicableForOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
        }
        List<ListElement> savingsTypeOptions = new ArrayList<ListElement>();
        List<SavingsTypeEntity> savingsTypes = this.loanProductDao.retrieveSavingsTypes();
        for (SavingsTypeEntity entity : savingsTypes) {
            savingsTypeOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
        }
        List<ListElement> recommendedAmountTypeOptions = new ArrayList<ListElement>();
        List<RecommendedAmntUnitEntity> recommendedAmountTypes = this.loanProductDao.retrieveRecommendedAmountTypes();
        for (RecommendedAmntUnitEntity entity : recommendedAmountTypes) {
            recommendedAmountTypeOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
        }
        List<ListElement> interestCalcTypeOptions = new ArrayList<ListElement>();
        List<InterestCalcTypeEntity> interestCalcTypes = this.savingsProductDao.retrieveInterestCalculationTypes();
        for (InterestCalcTypeEntity entity : interestCalcTypes) {
            interestCalcTypeOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
        }
        List<ListElement> timePeriodOptions = new ArrayList<ListElement>();
        List<RecurrenceTypeEntity> applicableRecurrences = savingsProductDao.getSavingsApplicableRecurrenceTypes();
        for (RecurrenceTypeEntity entity : applicableRecurrences) {
            timePeriodOptions.add(new ListElement(entity.getRecurrenceId().intValue(), entity.getRecurrenceName()));
        }
        List<GLCodeEntity> depositGlCodeList = new ArrayList<GLCodeEntity>();
        depositGlCodeList.addAll(new FinancialBusinessService().getGLCodes(FinancialActionConstants.MANDATORYDEPOSIT, FinancialConstants.CREDIT));
        depositGlCodeList.addAll(new FinancialBusinessService().getGLCodes(FinancialActionConstants.VOLUNTARYDEPOSIT, FinancialConstants.CREDIT));
        List<ListElement> depositGlCodeOptions = new ArrayList<ListElement>();
        for (GLCodeEntity glCode : depositGlCodeList) {
            depositGlCodeOptions.add(new ListElement(glCode.getGlcodeId().intValue(), glCode.getGlcode(), glCode.getAssociatedCOA().getAccountName()));
        }
        List<GLCodeEntity> interestGlCodeList = new FinancialBusinessService().getGLCodes(FinancialActionConstants.SAVINGS_INTERESTPOSTING, FinancialConstants.DEBIT);
        List<ListElement> interestGlCodes = new ArrayList<ListElement>();
        for (GLCodeEntity glCode : interestGlCodeList) {
            interestGlCodes.add(new ListElement(glCode.getGlcodeId().intValue(), glCode.getGlcode(), glCode.getAssociatedCOA().getAccountName()));
        }
        return new SavingsProductFormDto(productCategoryOptions, applicableForOptions, savingsTypeOptions, recommendedAmountTypeOptions, interestCalcTypeOptions, timePeriodOptions, depositGlCodeOptions, interestGlCodes, statusOptions);
    } 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 : ArrayList(java.util.ArrayList) FinancialBusinessService(org.mifos.accounts.financial.business.service.FinancialBusinessService) BusinessRuleException(org.mifos.service.BusinessRuleException) SystemException(org.mifos.framework.exceptions.SystemException) SavingsPrdBusinessService(org.mifos.accounts.productdefinition.business.service.SavingsPrdBusinessService) PenaltyBO(org.mifos.accounts.penalties.business.PenaltyBO) RecurrenceTypeEntity(org.mifos.application.meeting.business.RecurrenceTypeEntity) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) InterestCalcTypeEntity(org.mifos.accounts.productdefinition.business.InterestCalcTypeEntity) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) RecommendedAmntUnitEntity(org.mifos.accounts.productdefinition.business.RecommendedAmntUnitEntity) ApplicationException(org.mifos.framework.exceptions.ApplicationException) SavingsTypeEntity(org.mifos.accounts.productdefinition.business.SavingsTypeEntity) SavingsProductFormDto(org.mifos.dto.screen.SavingsProductFormDto) ListElement(org.mifos.dto.screen.ListElement) PersistenceException(org.mifos.framework.exceptions.PersistenceException) PrdStatusEntity(org.mifos.accounts.productdefinition.business.PrdStatusEntity) PrdApplicableMasterEntity(org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 34 with GLCodeEntity

use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.

the class PenaltyBOIntegrationTest method testCreateRatePenalty.

@Test
public void testCreateRatePenalty() throws Exception {
    String name = "Rate Penalty Test";
    PenaltyCategoryEntity categoryEntity = new PenaltyCategoryEntity(PenaltyCategory.LOAN);
    PenaltyPeriodEntity periodEntity = new PenaltyPeriodEntity(PenaltyPeriod.DAYS);
    int duration = 2;
    double min = 1.0;
    double max = 15.0;
    PenaltyFrequencyEntity frequencyEntity = new PenaltyFrequencyEntity(PenaltyFrequency.MONTHLY);
    GLCodeEntity glCode = getGLCode("42");
    PenaltyFormulaEntity formulaEntity = new PenaltyFormulaEntity(PenaltyFormula.OVERDUE_AMOUNT_DUE);
    double rate = 7.5;
    penalty = new RatePenaltyBO(TestUtils.makeUser(), name, categoryEntity, periodEntity, duration, min, max, frequencyEntity, glCode, formulaEntity, rate);
    penalty.save();
    StaticHibernateUtil.flushSession();
    penalty = (PenaltyBO) TestObjectFactory.getObject(PenaltyBO.class, penalty.getPenaltyId());
    Assert.assertEquals(name, penalty.getPenaltyName());
    Assert.assertEquals(categoryEntity.getId(), penalty.getCategoryType().getId());
    Assert.assertEquals(duration, penalty.getPeriodDuration().intValue());
    Assert.assertEquals(min, penalty.getMinimumLimit().doubleValue());
    Assert.assertEquals(max, penalty.getMaximumLimit().doubleValue());
    Assert.assertEquals(frequencyEntity.getId(), penalty.getPenaltyFrequency().getId());
    Assert.assertEquals(glCode.getGlcodeId(), penalty.getGlCode().getGlcodeId());
    Assert.assertEquals(formulaEntity.getId(), ((RatePenaltyBO) penalty).getFormula().getId());
    Assert.assertEquals(rate, ((RatePenaltyBO) penalty).getRate());
    StaticHibernateUtil.flushSession();
}
Also used : GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) Test(org.junit.Test)

Example 35 with GLCodeEntity

use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.

the class FeeServiceImpl method create.

@Override
public FeeBO create(FeeCreateRequest feeCreateRequest, UserContext userContext) throws ApplicationException {
    FeeFrequencyTypeEntity feeFrequencyType = this.feeDao.findFeeFrequencyEntityByType(feeCreateRequest.getFeeFrequencyType());
    CategoryTypeEntity feeCategoryType = this.feeDao.findFeeCategoryTypeEntityByType(feeCreateRequest.getCategoryType());
    GLCodeEntity glCodeEntity = this.generalLedgerDao.findGlCodeById(feeCreateRequest.getGlCode());
    FeeBO feeBO = null;
    if (feeFrequencyType.isOneTime()) {
        feeBO = createOneTimeFee(feeCreateRequest, feeFrequencyType, feeCategoryType, glCodeEntity, userContext);
    } else {
        feeBO = createPeriodicFee(feeCreateRequest, feeFrequencyType, feeCategoryType, glCodeEntity, userContext);
    }
    try {
        hibernateTransactionHelper.startTransaction();
        this.feeDao.save(feeBO);
        hibernateTransactionHelper.commitTransaction();
    } catch (Exception e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
    return feeBO;
}
Also used : FeeFrequencyTypeEntity(org.mifos.accounts.fees.business.FeeFrequencyTypeEntity) CategoryTypeEntity(org.mifos.accounts.fees.business.CategoryTypeEntity) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) FeeException(org.mifos.accounts.fees.exceptions.FeeException) BusinessRuleException(org.mifos.service.BusinessRuleException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)58 Money (org.mifos.framework.util.helpers.Money)21 MeetingBO (org.mifos.application.meeting.business.MeetingBO)18 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)17 Test (org.junit.Test)16 MifosRuntimeException (org.mifos.core.MifosRuntimeException)15 FinancialActionTypeEntity (org.mifos.accounts.financial.business.FinancialActionTypeEntity)14 Date (java.sql.Date)12 ArrayList (java.util.ArrayList)11 FeeBO (org.mifos.accounts.fees.business.FeeBO)11 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)11 COABO (org.mifos.accounts.financial.business.COABO)10 PersistenceException (org.mifos.framework.exceptions.PersistenceException)10 PrdApplicableMasterEntity (org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity)9 PrdStatusEntity (org.mifos.accounts.productdefinition.business.PrdStatusEntity)9 ApplicationException (org.mifos.framework.exceptions.ApplicationException)8 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)7 SystemException (org.mifos.framework.exceptions.SystemException)7 CategoryTypeEntity (org.mifos.accounts.fees.business.CategoryTypeEntity)6 FeeFrequencyTypeEntity (org.mifos.accounts.fees.business.FeeFrequencyTypeEntity)6