Search in sources :

Example 1 with RateFeeBO

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

the class TestObjectFactory method createPeriodicRateFee.

public static RateFeeBO createPeriodicRateFee(final String feeName, final FeeCategory feeCategory, final Double rate, final FeeFormula feeFormula, final RecurrenceType meetingFrequency, final Short recurAfter, final UserContext userContext, final MeetingBO meeting) {
    try {
        MeetingBO newMeeting = new MeetingBO(meetingFrequency, recurAfter, new DateTimeService().getCurrentJavaDateTime(), MeetingType.PERIODIC_FEE);
        // GLCodeEntity glCode =
        // ChartOfAccountsCache.get("31301").getAssociatedGlcode();
        GLCodeEntity glCode = new GLCodeEntity((short) 1, "31301");
        RateFeeBO fee = new RateFeeBO(userContext, feeName, new CategoryTypeEntity(feeCategory), new FeeFrequencyTypeEntity(FeeFrequencyType.PERIODIC), glCode, rate, new FeeFormulaEntity(feeFormula), false, newMeeting);
        // [keith] I have no idea why the fee must save itself. Otherwise
        // mySQL errors crop up
        // when you try to attach the fee to a loan.
        fee.save();
        // addObject(fee);
        return fee;
    // return (RateFeeBO) addObject(testObjectPersistence.persist(fee));
    // return (RateFeeBO)
    // addObject(testObjectPersistence.createFee(fee));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
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) MeetingBO(org.mifos.application.meeting.business.MeetingBO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) CategoryTypeEntity(org.mifos.accounts.fees.business.CategoryTypeEntity) DateTimeService(org.mifos.framework.util.DateTimeService) 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)

Example 2 with RateFeeBO

use of org.mifos.accounts.fees.business.RateFeeBO 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 3 with RateFeeBO

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

the class LoanAccountActionFormTest method createDefaultFees.

private ArrayList<FeeDto> createDefaultFees() {
    AmountFeeBO amountFee = createMock(AmountFeeBO.class);
    expect(amountFee.getFeeId()).andReturn(Short.valueOf("1"));
    expect(amountFee.getFeeType()).andReturn(RateAmountFlag.AMOUNT).times(2);
    expect(amountFee.getFeeName()).andReturn("TestAmountFee");
    expect(amountFee.getFeeAmount()).andReturn(new Money(TestUtils.RUPEE, "5000.0")).times(2);
    expect(amountFee.isPeriodic()).andReturn(false).times(2);
    replay(amountFee);
    RateFeeBO rateFee = createMock(RateFeeBO.class);
    expect(rateFee.getFeeId()).andReturn(Short.valueOf("1"));
    expect(rateFee.getFeeType()).andReturn(RateAmountFlag.RATE).times(2);
    expect(rateFee.getFeeName()).andReturn("TestRateFee");
    expect(rateFee.getRate()).andReturn(2.12345);
    expect(rateFee.getFeeFormula()).andReturn(createFeeFormulaEntityMock());
    expect(rateFee.isPeriodic()).andReturn(false).times(2);
    replay(rateFee);
    UserContext userContext = createMock(UserContext.class);
    expect(userContext.getLocaleId()).andReturn(Short.valueOf("1")).times(2);
    replay(userContext);
    ArrayList<FeeDto> defaultFees = new ArrayList<FeeDto>();
    defaultFees.add(new FeeDto(userContext, amountFee));
    defaultFees.add(new FeeDto(userContext, rateFee));
    return defaultFees;
}
Also used : RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) Money(org.mifos.framework.util.helpers.Money) UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) FeeDto(org.mifos.accounts.fees.business.FeeDto) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO)

Example 4 with RateFeeBO

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

the class FeeServiceImpl method createOneTimeFee.

private FeeBO createOneTimeFee(FeeCreateRequest feeCreateRequest, FeeFrequencyTypeEntity feeFrequencyType, CategoryTypeEntity feeCategoryType, GLCodeEntity glCodeEntity, UserContext userContext) throws FeeException {
    FeePaymentEntity feePaymentEntity = this.feeDao.findFeePaymentEntityByType(feeCreateRequest.getFeePaymentType());
    FeeBO feeBO = null;
    if (feeCreateRequest.isRateFee()) {
        FeeFormulaEntity feeFormulaEntity = this.feeDao.findFeeFormulaEntityByType(feeCreateRequest.getFeeFormula());
        feeBO = new RateFeeBO(userContext, feeCreateRequest.getFeeName(), feeCategoryType, feeFrequencyType, glCodeEntity, feeCreateRequest.getRate(), feeFormulaEntity, feeCreateRequest.isCustomerDefaultFee(), feePaymentEntity);
    } else {
        Money feeMoney = new Money(getCurrency(feeCreateRequest.getCurrencyId()), feeCreateRequest.getAmount());
        feeBO = new AmountFeeBO(userContext, feeCreateRequest.getFeeName(), feeCategoryType, feeFrequencyType, glCodeEntity, feeMoney, feeCreateRequest.isCustomerDefaultFee(), feePaymentEntity);
    }
    return feeBO;
}
Also used : RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) Money(org.mifos.framework.util.helpers.Money) FeeFormulaEntity(org.mifos.accounts.fees.business.FeeFormulaEntity) FeePaymentEntity(org.mifos.accounts.fees.business.FeePaymentEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO)

Example 5 with RateFeeBO

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

the class FeeServiceImpl method createPeriodicFee.

private FeeBO createPeriodicFee(FeeCreateRequest feeCreateRequest, FeeFrequencyTypeEntity feeFrequencyType, CategoryTypeEntity feeCategoryType, GLCodeEntity glCodeEntity, UserContext userContext) throws FeeException, MeetingException {
    MeetingBO feeMeeting = feeCreateRequest.getFeeRecurrenceType().equals(RecurrenceType.MONTHLY) ? new MeetingBO(feeCreateRequest.getFeeRecurrenceType(), feeCreateRequest.getMonthRecurAfter(), new DateTimeService().getCurrentJavaDateTime(), MeetingType.PERIODIC_FEE) : new MeetingBO(feeCreateRequest.getFeeRecurrenceType(), feeCreateRequest.getWeekRecurAfter(), new DateTimeService().getCurrentJavaDateTime(), MeetingType.PERIODIC_FEE);
    FeeBO feeBO = null;
    if (feeCreateRequest.isRateFee()) {
        FeeFormulaEntity feeFormulaEntity = this.feeDao.findFeeFormulaEntityByType(feeCreateRequest.getFeeFormula());
        feeBO = new RateFeeBO(userContext, feeCreateRequest.getFeeName(), feeCategoryType, feeFrequencyType, glCodeEntity, feeCreateRequest.getRate(), feeFormulaEntity, feeCreateRequest.isCustomerDefaultFee(), feeMeeting);
    } else {
        Money feeMoney = new Money(getCurrency(feeCreateRequest.getCurrencyId()), feeCreateRequest.getAmount());
        feeBO = new AmountFeeBO(userContext, feeCreateRequest.getFeeName(), feeCategoryType, feeFrequencyType, glCodeEntity, feeMoney, feeCreateRequest.isCustomerDefaultFee(), feeMeeting);
    }
    return feeBO;
}
Also used : RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) Money(org.mifos.framework.util.helpers.Money) FeeFormulaEntity(org.mifos.accounts.fees.business.FeeFormulaEntity) MeetingBO(org.mifos.application.meeting.business.MeetingBO) FeeBO(org.mifos.accounts.fees.business.FeeBO) RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) DateTimeService(org.mifos.framework.util.DateTimeService) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO)

Aggregations

RateFeeBO (org.mifos.accounts.fees.business.RateFeeBO)14 FeeBO (org.mifos.accounts.fees.business.FeeBO)8 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)6 FeeFormulaEntity (org.mifos.accounts.fees.business.FeeFormulaEntity)6 Money (org.mifos.framework.util.helpers.Money)6 MeetingBO (org.mifos.application.meeting.business.MeetingBO)4 MifosRuntimeException (org.mifos.core.MifosRuntimeException)4 ApplicationException (org.mifos.framework.exceptions.ApplicationException)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)3 UserContext (org.mifos.security.util.UserContext)3 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)2 AccountPenaltiesEntity (org.mifos.accounts.business.AccountPenaltiesEntity)2 CategoryTypeEntity (org.mifos.accounts.fees.business.CategoryTypeEntity)2 FeeDto (org.mifos.accounts.fees.business.FeeDto)2 FeeFrequencyTypeEntity (org.mifos.accounts.fees.business.FeeFrequencyTypeEntity)2 FeePaymentEntity (org.mifos.accounts.fees.business.FeePaymentEntity)2 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)2 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)2