use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.
the class WebTierPenaltyServiceFacade method getPenaltyParameters.
@Override
public PenaltyParametersDto getPenaltyParameters() {
try {
List<GLCodeEntity> glCodes = generalLedgerDao.retreiveGlCodesBy(FinancialActionConstants.PENALTYPOSTING, FinancialConstants.CREDIT);
List<PenaltyCategoryEntity> categories = this.penaltyDao.getPenaltiesCategories();
List<PenaltyPeriodEntity> periods = this.penaltyDao.getPenaltiesPeriods();
List<PenaltyFormulaEntity> formulas = this.penaltyDao.getPenaltiesFormulas();
List<PenaltyFrequencyEntity> frequencies = this.penaltyDao.getPenaltiesFrequencies();
List<PenaltyStatusEntity> statuses = this.penaltyDao.getPenaltiesStatuses();
return new PenaltyParametersDto(listToMap(categories), listToMap(statuses), listToMap(periods), listToMap(formulas), listToMap(frequencies), glCodesToMap(glCodes));
} catch (FinancialException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.
the class LegacyAccountDao method updateLedgerAccount.
public void updateLedgerAccount(COABO coaBo, String accountName, String glCode, String parentGlCode) throws PersistenceException {
Session session = StaticHibernateUtil.getSessionTL();
Transaction transaction = session.beginTransaction();
try {
Short newParentId = getAccountIdFromGlCode(parentGlCode);
coaBo.setAccountName(accountName);
GLCodeEntity glCodeEntity = coaBo.getAssociatedGlcode();
createOrUpdate(coaBo);
glCodeEntity.setGlcode(glCode);
createOrUpdate(glCodeEntity);
Query query = session.getNamedQuery(NamedQueryConstants.SET_COA_PARENT);
query.setShort("parentId", newParentId);
query.setShort("id", coaBo.getAccountId());
query.executeUpdate();
transaction.commit();
} catch (HibernateException ex) {
transaction.rollback();
throw new PersistenceException(ex);
}
}
use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.
the class SavingsProductAssembler method fromDto.
public SavingsOfferingBO fromDto(MifosUser user, SavingsProductDto savingsProductRequest) {
try {
// FIXME - keithw - this is general assembler common to both savings and loans i.e. all products. so
// ProductDao and ProductAssembler
ProductDetailsDto productDetails = savingsProductRequest.getProductDetails();
String name = productDetails.getName();
String shortName = productDetails.getShortName();
String description = productDetails.getDescription();
Integer category = productDetails.getCategory();
ProductCategoryBO productCategory = this.loanProductDao.findActiveProductCategoryById(category);
DateTime startDate = productDetails.getStartDate();
DateTime endDate = productDetails.getEndDate();
ApplicableTo applicableTo = ApplicableTo.fromInt(productDetails.getApplicableFor());
PrdApplicableMasterEntity applicableToEntity = this.loanProductDao.findApplicableProductType(applicableTo);
PrdStatusEntity activeStatus = new PrdOfferingPersistence().getPrdStatus(PrdStatus.SAVINGS_ACTIVE);
PrdStatusEntity inActiveStatus = new PrdOfferingPersistence().getPrdStatus(PrdStatus.SAVINGS_INACTIVE);
PrdStatusEntity selectedStatus = activeStatus;
if (productDetails.getStatus() != null && inActiveStatus.getOfferingStatusId().equals(productDetails.getStatus().shortValue())) {
selectedStatus = inActiveStatus;
}
String globalNum = generateProductGlobalNum(user);
// savings specific
SavingsType savingsType = SavingsType.fromInt(savingsProductRequest.getDepositType());
SavingsTypeEntity savingsTypeEntity = this.loanProductDao.retrieveSavingsType(savingsType);
RecommendedAmntUnitEntity recommendedAmntUnitEntity = null;
if (savingsProductRequest.getGroupMandatorySavingsType() != null) {
RecommendedAmountUnit recommendedAmountType = RecommendedAmountUnit.fromInt(savingsProductRequest.getGroupMandatorySavingsType());
recommendedAmntUnitEntity = this.loanProductDao.retrieveRecommendedAmountType(recommendedAmountType);
}
Money amountForDeposit = new Money(Money.getDefaultCurrency(), BigDecimal.valueOf(savingsProductRequest.getAmountForDeposit()));
Money maxWithdrawal = new Money(Money.getDefaultCurrency(), BigDecimal.valueOf(savingsProductRequest.getMaxWithdrawal()));
// interest specific
BigDecimal interestRate = savingsProductRequest.getInterestRate();
InterestCalcType interestCalcType = InterestCalcType.fromInt(savingsProductRequest.getInterestCalculationType());
InterestCalcTypeEntity interestCalcTypeEntity = this.savingsProductDao.retrieveInterestCalcType(interestCalcType);
RecurrenceType recurrence = RecurrenceType.fromInt(savingsProductRequest.getInterestCalculationFrequencyPeriod().shortValue());
Integer every = savingsProductRequest.getInterestCalculationFrequency();
MeetingBO interestCalculationMeeting = new MeetingBO(recurrence, every.shortValue(), new Date(), MeetingType.SAVINGS_INTEREST_CALCULATION_TIME_PERIOD);
Integer interestPostingEveryMonthFreq = savingsProductRequest.getInterestPostingFrequency();
RecurrenceType interestPostingRecurrenceType = null;
if (savingsProductRequest.isDailyPosting()) {
interestPostingRecurrenceType = RecurrenceType.DAILY;
} else {
interestPostingRecurrenceType = RecurrenceType.MONTHLY;
}
MeetingBO interestPostingMeeting = new MeetingBO(interestPostingRecurrenceType, interestPostingEveryMonthFreq.shortValue(), new Date(), MeetingType.SAVINGS_INTEREST_POSTING);
Money minAmountForCalculation = new Money(Money.getDefaultCurrency(), savingsProductRequest.getMinBalanceForInterestCalculation());
GLCodeEntity depositGlEntity = this.generalLedgerDao.findGlCodeById(savingsProductRequest.getDepositGlCode().shortValue());
GLCodeEntity interestGlEntity = this.generalLedgerDao.findGlCodeById(savingsProductRequest.getInterestGlCode().shortValue());
MifosCurrency currency = Money.getDefaultCurrency();
return SavingsOfferingBO.createNew(user.getUserId(), globalNum, name, shortName, description, productCategory, startDate, endDate, applicableToEntity, currency, selectedStatus, savingsTypeEntity, recommendedAmntUnitEntity, amountForDeposit, maxWithdrawal, interestRate, interestCalcTypeEntity, interestCalculationMeeting, interestPostingMeeting, minAmountForCalculation, depositGlEntity, interestGlEntity);
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
} catch (MeetingException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.
the class PenaltyBOIntegrationTest method testCreateAmountPenalty.
@Test
public void testCreateAmountPenalty() throws Exception {
String name = "Amount Penalty Test";
PenaltyCategoryEntity categoryEntity = new PenaltyCategoryEntity(PenaltyCategory.LOAN);
PenaltyPeriodEntity periodEntity = new PenaltyPeriodEntity(PenaltyPeriod.DAYS);
int duration = 10;
double min = 1.0;
double max = 15.0;
PenaltyFrequencyEntity frequencyEntity = new PenaltyFrequencyEntity(PenaltyFrequency.MONTHLY);
GLCodeEntity glCode = getGLCode("42");
Money amount = TestUtils.createMoney(587.6);
penalty = new AmountPenaltyBO(TestUtils.makeUser(), name, categoryEntity, periodEntity, duration, min, max, frequencyEntity, glCode, amount);
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(amount.getAmount(), ((AmountPenaltyBO) penalty).getAmount().getAmount());
StaticHibernateUtil.flushSession();
}
use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.
the class PenaltyDaoHibernateIntegrationTest method cleanDatabaseTables.
@Before
public void cleanDatabaseTables() throws Exception {
databaseCleaner.clean();
periodEntity = new PenaltyPeriodEntity(PenaltyPeriod.INSTALLMENTS);
statusEntity = new PenaltyStatusEntity(PenaltyStatus.ACTIVE);
categoryEntity = new PenaltyCategoryEntity(PenaltyCategory.LOAN);
frequencyEntity = new PenaltyFrequencyEntity(PenaltyFrequency.NONE);
formulaEntity = new PenaltyFormulaEntity(PenaltyFormula.OUTSTANDING_LOAN_AMOUNT);
glCodeEntity = new GLCodeEntity((short) 42, "31102");
amountPenalty = new AmountPenaltyBO(TestUtils.makeUser(), "Amount Penalty Test", new PenaltyCategoryEntity(PenaltyCategory.SAVING), periodEntity, 6, 1.0, 14.0, frequencyEntity, glCodeEntity, TestUtils.createMoney(158.5));
ratePenalty = new RatePenaltyBO(TestUtils.makeUser(), "Rate Penalty Test", categoryEntity, periodEntity, 6, 1.0, 10.0, frequencyEntity, glCodeEntity, formulaEntity, 10.5);
IntegrationTestObjectMother.createPenalty(amountPenalty);
IntegrationTestObjectMother.createPenalty(ratePenalty);
}
Aggregations