use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.
the class SavingsOfferingBOIntegrationTest method testBuildSavingsOfferingWithoutName.
@Test
public void testBuildSavingsOfferingWithoutName() throws SystemException {
PrdApplicableMasterEntity prdApplicableMaster = new PrdApplicableMasterEntity(ApplicableTo.CLIENTS);
SavingsTypeEntity savingsType = new SavingsTypeEntity(SavingsType.MANDATORY);
InterestCalcTypeEntity intCalType = new InterestCalcTypeEntity(InterestCalcType.AVERAGE_BALANCE);
MeetingBO intCalcMeeting = getMeeting();
MeetingBO intPostMeeting = getMeeting();
GLCodeEntity depglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, (short) 7);
GLCodeEntity intglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, (short) 7);
ProductCategoryBO productCategory = (ProductCategoryBO) TestObjectFactory.getObject(ProductCategoryBO.class, (short) 2);
try {
new SavingsOfferingBO(TestUtils.makeUser(), null, "S", productCategory, prdApplicableMaster, new Date(System.currentTimeMillis()), savingsType, intCalType, intCalcMeeting, intPostMeeting, new Money(getCurrency(), "10"), 10.0, depglCodeEntity, intglCodeEntity);
Assert.fail();
} catch (ProductDefinitionException e) {
Assert.assertTrue(true);
}
}
use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.
the class SavingsOfferingBOIntegrationTest method testBuildSavingsOfferingWithStartDateLessThanCurrentDate.
@Test
public void testBuildSavingsOfferingWithStartDateLessThanCurrentDate() throws SystemException {
PrdApplicableMasterEntity prdApplicableMaster = new PrdApplicableMasterEntity(ApplicableTo.CLIENTS);
SavingsTypeEntity savingsType = new SavingsTypeEntity(SavingsType.MANDATORY);
InterestCalcTypeEntity intCalType = new InterestCalcTypeEntity(InterestCalcType.AVERAGE_BALANCE);
MeetingBO intCalcMeeting = getMeeting();
MeetingBO intPostMeeting = getMeeting();
GLCodeEntity depglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, (short) 7);
GLCodeEntity intglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, (short) 7);
ProductCategoryBO productCategory = (ProductCategoryBO) TestObjectFactory.getObject(ProductCategoryBO.class, (short) 2);
Date startDate = offSetCurrentDate(-2);
try {
new SavingsOfferingBO(TestUtils.makeUser(), "Savings Offering", "Savi", productCategory, prdApplicableMaster, startDate, savingsType, intCalType, intCalcMeeting, intPostMeeting, new Money(getCurrency(), "10"), 10.0, depglCodeEntity, intglCodeEntity);
Assert.fail();
} catch (ProductDefinitionException e) {
Assert.assertTrue(true);
}
}
use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.
the class SavingsOfferingBOIntegrationTest method testBuildSavingsOfferingWithDuplicatePrdOfferingName.
@Test
public void testBuildSavingsOfferingWithDuplicatePrdOfferingName() throws SystemException {
savingsProduct = createSavingsOfferingBO("Savings Product", "SAVP");
PrdApplicableMasterEntity prdApplicableMaster = new PrdApplicableMasterEntity(ApplicableTo.CLIENTS);
SavingsTypeEntity savingsType = new SavingsTypeEntity(SavingsType.MANDATORY);
InterestCalcTypeEntity intCalType = new InterestCalcTypeEntity(InterestCalcType.AVERAGE_BALANCE);
MeetingBO intCalcMeeting = getMeeting();
MeetingBO intPostMeeting = getMeeting();
GLCodeEntity depglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, (short) 7);
GLCodeEntity intglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, (short) 7);
ProductCategoryBO productCategory = (ProductCategoryBO) TestObjectFactory.getObject(ProductCategoryBO.class, (short) 2);
Date startDate = offSetCurrentDate(0);
try {
new SavingsOfferingBO(TestUtils.makeUser(), "Savings Product", "Savi", productCategory, prdApplicableMaster, startDate, savingsType, intCalType, intCalcMeeting, intPostMeeting, new Money(getCurrency(), "10"), 10.0, depglCodeEntity, intglCodeEntity);
Assert.fail();
} catch (ProductDefinitionException pde) {
Assert.assertTrue(true);
Assert.assertEquals(ProductDefinitionConstants.DUPLPRDINSTNAME, pde.getKey());
}
}
use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.
the class SavingsOfferingBOIntegrationTest method testBuildSavingsOfferingWithNoRecommendedAmountForMandatoryOffering.
@Test
public void testBuildSavingsOfferingWithNoRecommendedAmountForMandatoryOffering() throws SystemException {
PrdApplicableMasterEntity prdApplicableMaster = new PrdApplicableMasterEntity(ApplicableTo.CLIENTS);
SavingsTypeEntity savingsType = new SavingsTypeEntity(SavingsType.MANDATORY);
InterestCalcTypeEntity intCalType = new InterestCalcTypeEntity(InterestCalcType.AVERAGE_BALANCE);
MeetingBO intCalcMeeting = getMeeting();
MeetingBO intPostMeeting = getMeeting();
GLCodeEntity depglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, (short) 7);
GLCodeEntity intglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, (short) 7);
ProductCategoryBO productCategory = (ProductCategoryBO) TestObjectFactory.getObject(ProductCategoryBO.class, (short) 2);
Date startDate = offSetCurrentDate(-2);
try {
new SavingsOfferingBO(TestUtils.makeUser(), "Savings Product1", "SAVP", productCategory, prdApplicableMaster, startDate, savingsType, intCalType, intCalcMeeting, intPostMeeting, null, 10.0, depglCodeEntity, intglCodeEntity);
Assert.fail();
} catch (ProductDefinitionException e) {
Assert.assertTrue(true);
}
}
use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.
the class WebTierPenaltyServiceFacade method createPenalty.
@Override
public void createPenalty(PenaltyFormDto dto) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(user);
try {
PenaltyCategory penaltyCategory = dto.getCategoryType() != null ? PenaltyCategory.getPenaltyCategory(dto.getCategoryType()) : null;
PenaltyFrequency penaltyFrequency = dto.getPenaltyFrequency() != null ? PenaltyFrequency.getPenaltyFrequencyType(dto.getPenaltyFrequency()) : null;
PenaltyPeriod penaltyPeriod = dto.getPenaltyPeriod() != null ? PenaltyPeriod.getPenaltyPeriod(dto.getPenaltyPeriod()) : null;
PenaltyFormula penaltyFormula = dto.getPenaltyFormula() != null ? PenaltyFormula.getPenaltyFormula(dto.getPenaltyFormula()) : null;
PenaltyCategoryEntity penaltyCategoryEntity = this.penaltyDao.findPenaltyCategoryEntityByType(penaltyCategory);
PenaltyPeriodEntity penaltyPeriodEntity = this.penaltyDao.findPenaltyPeriodEntityByType(penaltyPeriod);
PenaltyFrequencyEntity penaltyFrequencyEntity = this.penaltyDao.findPenaltyFrequencyEntityByType(penaltyFrequency);
GLCodeEntity glCodeEntity = this.generalLedgerDao.findGlCodeById(dto.getGlCode());
PenaltyBO penaltyBO = null;
String penaltyName = dto.getPenaltyName();
Integer periodDuration = dto.getDuration();
Double min = dto.getMin();
Double max = dto.getMax();
if (dto.isRatePenalty()) {
Double rate = dto.getRate();
PenaltyFormulaEntity formula = this.penaltyDao.findPenaltyFormulaEntityByType(penaltyFormula);
penaltyBO = new RatePenaltyBO(userContext, penaltyName, penaltyCategoryEntity, penaltyPeriodEntity, periodDuration, min, max, penaltyFrequencyEntity, glCodeEntity, formula, rate);
} else {
Money amount = new Money(getCurrency(dto.getCurrencyId()), dto.getAmount());
penaltyBO = new AmountPenaltyBO(userContext, penaltyName, penaltyCategoryEntity, penaltyPeriodEntity, periodDuration, min, max, penaltyFrequencyEntity, glCodeEntity, amount);
}
try {
StaticHibernateUtil.startTransaction();
this.penaltyDao.save(penaltyBO);
StaticHibernateUtil.commitTransaction();
} catch (Exception e) {
StaticHibernateUtil.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
StaticHibernateUtil.closeSession();
}
} catch (ApplicationException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
Aggregations