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);
}
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;
}
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);
}
}
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();
}
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;
}
Aggregations