use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.
the class InterestAccountingEntry method log999Account.
private void log999Account(LoanTrxnDetailEntity loanTrxn, boolean isLastPayment, GLCodeEntity glcodeCredit) throws FinancialException {
Money account999 = ((LoanBO) loanTrxn.getAccount()).calculate999Account(isLastPayment);
Money zeroAmount = new Money(account999.getCurrency(), "0");
// only log if amount > or < 0
if (account999.equals(zeroAmount)) {
return;
}
FinancialActionTypeEntity finActionRounding = FinancialActionCache.getFinancialAction(FinancialActionConstants.ROUNDING);
GLCodeEntity codeToDebit = null;
GLCodeEntity codeToCredit = null;
if (account999.isGreaterThanZero()) {
// this code is defined as below in chart of account
// <GLAccount code="31401" name="Income from 999 Account" />
codeToDebit = glcodeCredit;
codeToCredit = getGLcode(finActionRounding.getApplicableCreditCharts());
} else if (account999.isLessThanZero()) {
codeToDebit = getGLcode(finActionRounding.getApplicableDebitCharts());
codeToCredit = glcodeCredit;
account999 = account999.negate();
}
addAccountEntryDetails(account999, finActionRounding, codeToDebit, FinancialConstants.DEBIT);
addAccountEntryDetails(account999, finActionRounding, codeToCredit, FinancialConstants.CREDIT);
}
use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.
the class LoanPrdAction method getGLCodes.
private List<GLCodeEntity> getGLCodes(FinancialActionConstants financialAction, FinancialConstants debitCredit) throws Exception {
logger.debug("getGLCodes method of Loan Product Action called");
List<GLCodeEntity> glCodes = new FinancialBusinessService().getGLCodes(financialAction, debitCredit);
return glCodes;
}
use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.
the class InterestPostingAccountingEntryTest method makeChildCoaboOf.
/**
* Establish child-parent relationship between two COABO instances.
*
* <p>
* ASSUMPTION: the parentCoa's hierarchy has been created. In other words, build the hierarchy from top down.
*
* @throws RuntimeException if parentCoa has no associated COAHierarchy.
*/
protected COABO makeChildCoaboOf(COABO parentCoa, Short accountId, String accountName, String glCode) {
COAHierarchyEntity parentCoah = parentCoa.getCoaHierarchy();
if (parentCoah == null) {
throw new RuntimeException("ParentCoa.coaHierarchy has not been defined");
}
COABO childCoa = new COABO(accountId, accountName, new GLCodeEntity(accountId, glCode));
COAHierarchyEntity hierarchy = new COAHierarchyEntity(childCoa, parentCoa.getCoaHierarchy());
childCoa.setCoaHierarchy(hierarchy);
return childCoa;
}
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();
}
Aggregations