Search in sources :

Example 36 with GLCodeEntity

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);
}
Also used : Money(org.mifos.framework.util.helpers.Money) FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) LoanBO(org.mifos.accounts.loan.business.LoanBO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity)

Example 37 with GLCodeEntity

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;
}
Also used : GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) FinancialBusinessService(org.mifos.accounts.financial.business.service.FinancialBusinessService)

Example 38 with GLCodeEntity

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;
}
Also used : COABO(org.mifos.accounts.financial.business.COABO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) COAHierarchyEntity(org.mifos.accounts.financial.business.COAHierarchyEntity)

Example 39 with GLCodeEntity

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);
    }
}
Also used : ArrayList(java.util.ArrayList) FinancialBusinessService(org.mifos.accounts.financial.business.service.FinancialBusinessService) BusinessRuleException(org.mifos.service.BusinessRuleException) SystemException(org.mifos.framework.exceptions.SystemException) SavingsPrdBusinessService(org.mifos.accounts.productdefinition.business.service.SavingsPrdBusinessService) PenaltyBO(org.mifos.accounts.penalties.business.PenaltyBO) RecurrenceTypeEntity(org.mifos.application.meeting.business.RecurrenceTypeEntity) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) InterestCalcTypeEntity(org.mifos.accounts.productdefinition.business.InterestCalcTypeEntity) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) RecommendedAmntUnitEntity(org.mifos.accounts.productdefinition.business.RecommendedAmntUnitEntity) ApplicationException(org.mifos.framework.exceptions.ApplicationException) SavingsTypeEntity(org.mifos.accounts.productdefinition.business.SavingsTypeEntity) SavingsProductFormDto(org.mifos.dto.screen.SavingsProductFormDto) ListElement(org.mifos.dto.screen.ListElement) PersistenceException(org.mifos.framework.exceptions.PersistenceException) PrdStatusEntity(org.mifos.accounts.productdefinition.business.PrdStatusEntity) PrdApplicableMasterEntity(org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 40 with GLCodeEntity

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();
}
Also used : GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) Test(org.junit.Test)

Aggregations

GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)58 Money (org.mifos.framework.util.helpers.Money)21 MeetingBO (org.mifos.application.meeting.business.MeetingBO)18 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)17 Test (org.junit.Test)16 MifosRuntimeException (org.mifos.core.MifosRuntimeException)15 FinancialActionTypeEntity (org.mifos.accounts.financial.business.FinancialActionTypeEntity)14 Date (java.sql.Date)12 ArrayList (java.util.ArrayList)11 FeeBO (org.mifos.accounts.fees.business.FeeBO)11 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)11 COABO (org.mifos.accounts.financial.business.COABO)10 PersistenceException (org.mifos.framework.exceptions.PersistenceException)10 PrdApplicableMasterEntity (org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity)9 PrdStatusEntity (org.mifos.accounts.productdefinition.business.PrdStatusEntity)9 ApplicationException (org.mifos.framework.exceptions.ApplicationException)8 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)7 SystemException (org.mifos.framework.exceptions.SystemException)7 CategoryTypeEntity (org.mifos.accounts.fees.business.CategoryTypeEntity)6 FeeFrequencyTypeEntity (org.mifos.accounts.fees.business.FeeFrequencyTypeEntity)6