Search in sources :

Example 1 with FinancialBusinessService

use of org.mifos.accounts.financial.business.service.FinancialBusinessService in project head by mifos.

the class AdminServiceFacadeWebTier method retrieveLoanProductFormReferenceData.

@Override
public LoanProductFormDto retrieveLoanProductFormReferenceData() {
    try {
        LoanPrdBusinessService service = new LoanPrdBusinessService();
        List<ListElement> productCategoryOptions = new ArrayList<ListElement>();
        List<ProductCategoryBO> productCategories = service.getActiveLoanProductCategories();
        for (ProductCategoryBO category : productCategories) {
            productCategoryOptions.add(new ListElement(category.getProductCategoryID().intValue(), category.getProductCategoryName()));
        }
        List<ListElement> applicableForOptions = new ArrayList<ListElement>();
        List<PrdApplicableMasterEntity> applicableCustomerTypes = this.loanProductDao.retrieveLoanApplicableProductCategories();
        for (PrdApplicableMasterEntity entity : applicableCustomerTypes) {
            applicableForOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
        }
        List<ListElement> gracePeriodTypeOptions = new ArrayList<ListElement>();
        List<GracePeriodTypeEntity> gracePeriodTypes = this.loanProductDao.retrieveGracePeriodTypes();
        for (GracePeriodTypeEntity gracePeriodTypeEntity : gracePeriodTypes) {
            gracePeriodTypeOptions.add(new ListElement(gracePeriodTypeEntity.getId().intValue(), gracePeriodTypeEntity.getName()));
        }
        List<ListElement> interestCalcTypesOptions = new ArrayList<ListElement>();
        List<InterestTypesEntity> interestCalcTypes = this.loanProductDao.retrieveInterestTypes();
        for (InterestTypesEntity entity : interestCalcTypes) {
            interestCalcTypesOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
        }
        List<ListElement> sourceOfFunds = new ArrayList<ListElement>();
        List<FundBO> funds = this.fundDao.findAllFunds();
        for (FundBO fund : funds) {
            sourceOfFunds.add(new ListElement(fund.getFundId().intValue(), fund.getFundName()));
        }
        List<ListElement> loanFee = new ArrayList<ListElement>();
        List<FeeBO> fees = feeDao.getAllAppllicableFeeForLoanCreation();
        for (FeeBO fee : fees) {
            loanFee.add(new ListElement(fee.getFeeId().intValue(), fee.getFeeName()));
        }
        List<ListElement> principalGlCodes = new ArrayList<ListElement>();
        List<GLCodeEntity> principalGlCodeEntities = new FinancialBusinessService().getGLCodes(FinancialActionConstants.PRINCIPALPOSTING, FinancialConstants.CREDIT);
        for (GLCodeEntity glCode : principalGlCodeEntities) {
            principalGlCodes.add(new ListElement(glCode.getGlcodeId().intValue(), glCode.getGlcode()));
        }
        List<ListElement> interestGlCodes = new ArrayList<ListElement>();
        List<GLCodeEntity> interestGlCodeEntities = new FinancialBusinessService().getGLCodes(FinancialActionConstants.INTERESTPOSTING, FinancialConstants.CREDIT);
        for (GLCodeEntity glCode : interestGlCodeEntities) {
            interestGlCodes.add(new ListElement(glCode.getGlcodeId().intValue(), glCode.getGlcode()));
        }
        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()));
        }
        boolean multiCurrencyEnabled = AccountingRules.isMultiCurrencyEnabled();
        List<ListElement> currencyOptions = new ArrayList<ListElement>();
        if (multiCurrencyEnabled) {
            LinkedList<MifosCurrency> currencies = AccountingRules.getCurrencies();
            for (MifosCurrency mifosCurrency : currencies) {
                currencyOptions.add(new ListElement(mifosCurrency.getCurrencyId().intValue(), mifosCurrency.getCurrencyCode()));
            }
        }
        return new LoanProductFormDto(productCategoryOptions, gracePeriodTypeOptions, sourceOfFunds, loanFee, principalGlCodes, interestGlCodes, interestCalcTypesOptions, applicableForOptions, statusOptions, currencyOptions, multiCurrencyEnabled);
    } 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 : InterestTypesEntity(org.mifos.application.master.business.InterestTypesEntity) LoanPrdBusinessService(org.mifos.accounts.productdefinition.business.service.LoanPrdBusinessService) ArrayList(java.util.ArrayList) FinancialBusinessService(org.mifos.accounts.financial.business.service.FinancialBusinessService) LoanProductFormDto(org.mifos.dto.screen.LoanProductFormDto) BusinessRuleException(org.mifos.service.BusinessRuleException) SystemException(org.mifos.framework.exceptions.SystemException) GracePeriodTypeEntity(org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity) MifosCurrency(org.mifos.application.master.business.MifosCurrency) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) FundBO(org.mifos.accounts.fund.business.FundBO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) ApplicationException(org.mifos.framework.exceptions.ApplicationException) ListElement(org.mifos.dto.screen.ListElement) PersistenceException(org.mifos.framework.exceptions.PersistenceException) FeeBO(org.mifos.accounts.fees.business.FeeBO) PrdStatusEntity(org.mifos.accounts.productdefinition.business.PrdStatusEntity) PrdApplicableMasterEntity(org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with FinancialBusinessService

use of org.mifos.accounts.financial.business.service.FinancialBusinessService 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 3 with FinancialBusinessService

use of org.mifos.accounts.financial.business.service.FinancialBusinessService 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)

Aggregations

GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)3 FinancialBusinessService (org.mifos.accounts.financial.business.service.FinancialBusinessService)3 ArrayList (java.util.ArrayList)2 PrdApplicableMasterEntity (org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity)2 PrdStatusEntity (org.mifos.accounts.productdefinition.business.PrdStatusEntity)2 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 ListElement (org.mifos.dto.screen.ListElement)2 ApplicationException (org.mifos.framework.exceptions.ApplicationException)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 SystemException (org.mifos.framework.exceptions.SystemException)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 FeeBO (org.mifos.accounts.fees.business.FeeBO)1 FundBO (org.mifos.accounts.fund.business.FundBO)1 PenaltyBO (org.mifos.accounts.penalties.business.PenaltyBO)1 GracePeriodTypeEntity (org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity)1 InterestCalcTypeEntity (org.mifos.accounts.productdefinition.business.InterestCalcTypeEntity)1 RecommendedAmntUnitEntity (org.mifos.accounts.productdefinition.business.RecommendedAmntUnitEntity)1 SavingsTypeEntity (org.mifos.accounts.productdefinition.business.SavingsTypeEntity)1 LoanPrdBusinessService (org.mifos.accounts.productdefinition.business.service.LoanPrdBusinessService)1