use of org.mifos.accounts.fees.business.FeeFrequencyTypeEntity 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);
}
use of org.mifos.accounts.fees.business.FeeFrequencyTypeEntity 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;
}
use of org.mifos.accounts.fees.business.FeeFrequencyTypeEntity in project head by mifos.
the class FeeDaoHibernateIntegrationTest method shouldFindOneTimeFeeFrequencyType.
@Test
public void shouldFindOneTimeFeeFrequencyType() {
// exercise test
FeeFrequencyTypeEntity entity = this.feeDao.findFeeFrequencyEntityByType(FeeFrequencyType.ONETIME);
// verification
assertThat(entity, is(notNullValue()));
}
use of org.mifos.accounts.fees.business.FeeFrequencyTypeEntity 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) {
}
}
use of org.mifos.accounts.fees.business.FeeFrequencyTypeEntity 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);
}
}
Aggregations