Search in sources :

Example 1 with ListElement

use of org.mifos.dto.screen.ListElement 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 ListElement

use of org.mifos.dto.screen.ListElement in project head by mifos.

the class Localization method getLocaleList.

public List<ListElement> getLocaleList() {
    List<ListElement> localeForUI = new ArrayList<ListElement>();
    for (Short key : LOCALE_MAP.keySet()) {
        String displayName = getDisplayName(key);
        ListElement localeValue = new ListElement(key.intValue(), displayName);
        localeForUI.add(localeValue);
        Collections.sort(localeForUI, new ListElementSortByName());
    }
    return localeForUI;
}
Also used : ArrayList(java.util.ArrayList) ListElement(org.mifos.dto.screen.ListElement) ValueListElement(org.mifos.dto.domain.ValueListElement)

Example 3 with ListElement

use of org.mifos.dto.screen.ListElement in project head by mifos.

the class SavingsServiceFacadeWebTier method retrieveClosingDetails.

@Override
public SavingsAccountClosureDto retrieveClosingDetails(Long savingsId, LocalDate closureDate) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    SavingsBO savingsAccount = this.savingsDao.findById(savingsId);
    InterestScheduledEvent postingSchedule = savingsInterestScheduledEventFactory.createScheduledEventFrom(savingsAccount.getInterestPostingMeeting());
    LocalDate nextPostingDate = new LocalDate(savingsAccount.getNextIntPostDate());
    LocalDate startOfPostingPeriod = postingSchedule.findFirstDateOfPeriodForMatchingDate(nextPostingDate);
    CalendarPeriod postingPeriodAtClosure;
    if (startOfPostingPeriod.isAfter(closureDate)) {
        postingPeriodAtClosure = new CalendarPeriod(closureDate, closureDate);
    } else {
        postingPeriodAtClosure = new CalendarPeriod(startOfPostingPeriod, closureDate);
    }
    List<EndOfDayDetail> allEndOfDayDetailsForAccount = savingsDao.retrieveAllEndOfDayDetailsFor(savingsAccount.getCurrency(), Long.valueOf(savingsId));
    InterestPostingPeriodResult postingPeriodAtClosureResult = determinePostingPeriodResult(postingPeriodAtClosure, savingsAccount, allEndOfDayDetailsForAccount);
    Money endOfAccountBalance = postingPeriodAtClosureResult.getPeriodBalance();
    Money interestAmountAtClosure = postingPeriodAtClosureResult.getPeriodInterest();
    List<ListElement> depositPaymentTypes = retrieveDepositPaymentTypes(userContext);
    return new SavingsAccountClosureDto(new LocalDate(), endOfAccountBalance.toString(), interestAmountAtClosure.toString(), depositPaymentTypes);
}
Also used : InterestPostingPeriodResult(org.mifos.accounts.savings.interest.InterestPostingPeriodResult) UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) LocalDate(org.joda.time.LocalDate) SavingsAccountClosureDto(org.mifos.dto.domain.SavingsAccountClosureDto) Money(org.mifos.framework.util.helpers.Money) InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) EndOfDayDetail(org.mifos.accounts.savings.interest.EndOfDayDetail) CalendarPeriod(org.mifos.accounts.savings.interest.CalendarPeriod) ListElement(org.mifos.dto.screen.ListElement)

Example 4 with ListElement

use of org.mifos.dto.screen.ListElement in project head by mifos.

the class SavingsServiceFacadeWebTier method retrieveSavingsProductReferenceData.

@Override
public SavingsProductReferenceDto retrieveSavingsProductReferenceData(Integer productId) {
    SavingsOfferingBO savingsProduct = this.savingsProductDao.findById(productId);
    List<ListElement> interestCalcTypeOptions = new ArrayList<ListElement>();
    List<InterestCalcTypeEntity> interestCalculationTypes = this.savingsProductDao.retrieveInterestCalculationTypes();
    for (InterestCalcTypeEntity entity : interestCalculationTypes) {
        interestCalcTypeOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
    }
    boolean savingsPendingApprovalEnabled = ProcessFlowRules.isSavingsPendingApprovalStateEnabled();
    return new SavingsProductReferenceDto(interestCalcTypeOptions, savingsProduct.toFullDto(), savingsPendingApprovalEnabled);
}
Also used : InterestCalcTypeEntity(org.mifos.accounts.productdefinition.business.InterestCalcTypeEntity) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) ArrayList(java.util.ArrayList) ListElement(org.mifos.dto.screen.ListElement) SavingsProductReferenceDto(org.mifos.dto.screen.SavingsProductReferenceDto)

Example 5 with ListElement

use of org.mifos.dto.screen.ListElement in project head by mifos.

the class SavingsServiceFacadeWebTier method retrieveAccountStatuses.

@Override
public AccountStatusDto retrieveAccountStatuses(Long savingsId) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    SavingsBO savingsAccount = this.savingsDao.findById(savingsId);
    try {
        List<ListElement> savingsStatesList = new ArrayList<ListElement>();
        AccountStateMachines.getInstance().initializeSavingsStates();
        List<AccountStateEntity> statusList = AccountStateMachines.getInstance().getSavingsStatusList(savingsAccount.getAccountState());
        for (AccountStateEntity accountState : statusList) {
            savingsStatesList.add(new ListElement(accountState.getId().intValue(), accountState.getName()));
        }
        return new AccountStatusDto(savingsStatesList);
    } catch (StatesInitializationException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : AccountStatusDto(org.mifos.dto.domain.AccountStatusDto) UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) ListElement(org.mifos.dto.screen.ListElement) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) MifosUser(org.mifos.security.MifosUser) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

ListElement (org.mifos.dto.screen.ListElement)41 ArrayList (java.util.ArrayList)20 LinkedHashMap (java.util.LinkedHashMap)17 MifosRuntimeException (org.mifos.core.MifosRuntimeException)14 ValueListElement (org.mifos.dto.domain.ValueListElement)7 PersistenceException (org.mifos.framework.exceptions.PersistenceException)7 AddressDto (org.mifos.dto.domain.AddressDto)5 StatesInitializationException (org.mifos.framework.exceptions.StatesInitializationException)5 MifosUser (org.mifos.security.MifosUser)5 UserContext (org.mifos.security.util.UserContext)5 DateTime (org.joda.time.DateTime)4 OfficeBO (org.mifos.customers.office.business.OfficeBO)4 RoleBO (org.mifos.security.rolesandpermission.business.RoleBO)4 BusinessRuleException (org.mifos.service.BusinessRuleException)4 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)3 CustomerStatusEntity (org.mifos.customers.business.CustomerStatusEntity)3 CreateOrUpdatePersonnelInformation (org.mifos.dto.domain.CreateOrUpdatePersonnelInformation)3 Address (org.mifos.framework.business.util.Address)3 LocalDate (org.joda.time.LocalDate)2 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)2