Search in sources :

Example 6 with CategoryTypeEntity

use of org.mifos.accounts.fees.business.CategoryTypeEntity 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)

Example 7 with CategoryTypeEntity

use of org.mifos.accounts.fees.business.CategoryTypeEntity in project head by mifos.

the class FeeDaoHibernateIntegrationTest method shouldFindFeeCategoryType.

@Test
public void shouldFindFeeCategoryType() {
    // exercise test
    CategoryTypeEntity entity = this.feeDao.findFeeCategoryTypeEntityByType(FeeCategory.ALLCUSTOMERS);
    // verification
    assertThat(entity, is(notNullValue()));
}
Also used : CategoryTypeEntity(org.mifos.accounts.fees.business.CategoryTypeEntity) Test(org.junit.Test)

Example 8 with CategoryTypeEntity

use of org.mifos.accounts.fees.business.CategoryTypeEntity in project head by mifos.

the class LoanOfferingBOIntegrationTest method testFeeNotMatchingFrequencyOfLoanOffering.

@Test
public void testFeeNotMatchingFrequencyOfLoanOffering() throws ProductDefinitionException, FeeException {
    createIntitalObjects();
    GracePeriodTypeEntity gracePeriodType = new GracePeriodTypeEntity(GraceType.NONE);
    Date startDate = offSetCurrentDate(0);
    Date endDate = offSetCurrentDate(2);
    FeeBO fee = new AmountFeeBO(TestObjectFactory.getContext(), "Loan Periodic", new CategoryTypeEntity(FeeCategory.LOAN), new FeeFrequencyTypeEntity(FeeFrequencyType.PERIODIC), intglCodeEntity, new Money(getCurrency(), "100"), false, TestObjectFactory.createMeeting(TestObjectFactory.getNewMeeting(MONTHLY, EVERY_MONTH, CUSTOMER_MEETING, MONDAY)));
    List<FeeBO> fees = new ArrayList<FeeBO>();
    fees.add(fee);
    try {
        new LoanOfferingBO(TestObjectFactory.getContext(), "Loan Offering", "LOAP", productCategory, prdApplicableMaster, startDate, endDate, null, gracePeriodType, null, interestTypes, new Money(getCurrency(), "1000"), new Money(getCurrency(), "3000"), new Money(getCurrency(), "2000.0"), 12.0, 2.0, 3.0, (short) 20, (short) 11, (short) 17, false, false, false, null, fees, null, frequency, principalglCodeEntity, intglCodeEntity, waiverInterest);
        Assert.fail();
    } catch (ProductDefinitionException e) {
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) FeeFrequencyTypeEntity(org.mifos.accounts.fees.business.FeeFrequencyTypeEntity) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) ArrayList(java.util.ArrayList) CategoryTypeEntity(org.mifos.accounts.fees.business.CategoryTypeEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Date(java.sql.Date) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Test(org.junit.Test)

Example 9 with CategoryTypeEntity

use of org.mifos.accounts.fees.business.CategoryTypeEntity in project head by mifos.

the class TestObjectFactory method createOneTimeAmountFee.

public static FeeBO createOneTimeAmountFee(final String feeName, final FeeCategory feeCategory, final String feeAmnt, final FeePayment feePayment, final UserContext userContext, String categoryTypeName) {
    GLCodeEntity glCode = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, TestGeneralLedgerCode.FEES);
    try {
        CategoryTypeEntity categoryType = new CategoryTypeEntity(feeCategory);
        LookUpValueEntity lookUpValue = new LookUpValueEntity();
        lookUpValue.setLookUpName(categoryTypeName);
        categoryType.setLookUpValue(lookUpValue);
        FeeBO fee = new AmountFeeBO(userContext, feeName, categoryType, new FeeFrequencyTypeEntity(FeeFrequencyType.ONETIME), glCode, TestUtils.createMoney(feeAmnt), false, new FeePaymentEntity(feePayment));
        return testObjectPersistence.createFee(fee);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : 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) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) 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 10 with CategoryTypeEntity

use of org.mifos.accounts.fees.business.CategoryTypeEntity in project head by mifos.

the class LoanOfferingBOIntegrationTest method testUpdateWithFundsAndOneTimeFee.

@Test
public void testUpdateWithFundsAndOneTimeFee() throws ProductDefinitionException, FeeException {
    createIntitalObjects();
    GracePeriodTypeEntity gracePeriodType = new GracePeriodTypeEntity(GraceType.GRACEONALLREPAYMENTS);
    Date startDate = offSetCurrentDate(0);
    Date endDate = offSetCurrentDate(2);
    FeeBO fee = new AmountFeeBO(TestObjectFactory.getContext(), "Loan Periodic", new CategoryTypeEntity(FeeCategory.LOAN), new FeeFrequencyTypeEntity(FeeFrequencyType.PERIODIC), intglCodeEntity, new Money(getCurrency(), "100"), false, TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting()));
    FeeBO fee1 = new AmountFeeBO(TestObjectFactory.getContext(), "Loan Periodic", new CategoryTypeEntity(FeeCategory.LOAN), new FeeFrequencyTypeEntity(FeeFrequencyType.ONETIME), intglCodeEntity, new Money(getCurrency(), "100"), false, new FeePaymentEntity(FeePayment.UPFRONT));
    List<FeeBO> fees = new ArrayList<FeeBO>();
    fees.add(fee);
    fees.add(fee1);
    List<FundBO> funds = new ArrayList<FundBO>();
    funds.add(null);
    product = createLoanOfferingBO("Loan Product", "LOAP");
    product.update((short) 1, "Loan Product", "LOAN", productCategory, prdApplicableMaster, startDate, endDate, "Loan Product updated", PrdStatus.LOAN_ACTIVE, gracePeriodType, interestTypes, (short) 0, new Money(getCurrency(), "3000"), new Money(getCurrency(), "1000"), new Money(getCurrency(), "1000"), 12.0, 2.0, 12.0, (short) 12, (short) 1, (short) 2, false, true, false, funds, fees, null, (short) 2, RecurrenceType.WEEKLY, waiverInterest);
    Assert.assertEquals(2, product.getLoanOfferingFees().size());
    Assert.assertEquals(1, product.getLoanOfferingFunds().size());
}
Also used : Money(org.mifos.framework.util.helpers.Money) FeeFrequencyTypeEntity(org.mifos.accounts.fees.business.FeeFrequencyTypeEntity) FundBO(org.mifos.accounts.fund.business.FundBO) ArrayList(java.util.ArrayList) 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) Date(java.sql.Date) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Test(org.junit.Test)

Aggregations

CategoryTypeEntity (org.mifos.accounts.fees.business.CategoryTypeEntity)11 FeeFrequencyTypeEntity (org.mifos.accounts.fees.business.FeeFrequencyTypeEntity)10 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)8 FeeBO (org.mifos.accounts.fees.business.FeeBO)8 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)6 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)6 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 FeePaymentEntity (org.mifos.accounts.fees.business.FeePaymentEntity)5 RateFeeBO (org.mifos.accounts.fees.business.RateFeeBO)5 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)5 MifosRuntimeException (org.mifos.core.MifosRuntimeException)5 ApplicationException (org.mifos.framework.exceptions.ApplicationException)5 Date (java.sql.Date)4 CustomerException (org.mifos.customers.exceptions.CustomerException)4 OfficeException (org.mifos.customers.office.exceptions.OfficeException)4 PersistenceException (org.mifos.framework.exceptions.PersistenceException)4 SystemException (org.mifos.framework.exceptions.SystemException)4 Money (org.mifos.framework.util.helpers.Money)4 FeeFormulaEntity (org.mifos.accounts.fees.business.FeeFormulaEntity)3