use of org.mifos.accounts.productdefinition.business.ProductCategoryBO in project head by mifos.
the class AdminServiceFacadeWebTier method retrieveAllProductMix.
@Override
public ProductDto retrieveAllProductMix() {
try {
List<ProductCategoryBO> productCategoryList = new ProductCategoryBusinessService().getAllCategories();
List<PrdOfferingBO> prdOfferingList = new ProductMixBusinessService().getPrdOfferingMix();
List<ProductCategoryTypeDto> pcList = new ArrayList<ProductCategoryTypeDto>();
for (ProductCategoryBO pcBO : productCategoryList) {
ProductCategoryTypeDto pcDto = new ProductCategoryTypeDto(pcBO.getProductType().getProductTypeID(), pcBO.getProductType().getLookUpValue().getLookUpName());
pcList.add(pcDto);
}
List<ProductMixDto> pmList = new ArrayList<ProductMixDto>();
for (PrdOfferingBO poBO : prdOfferingList) {
ProductMixDto pmDto = new ProductMixDto(poBO.getPrdCategory().getProductType().getProductTypeID(), poBO.getPrdOfferingId(), poBO.getPrdType().getProductTypeID(), poBO.getPrdOfferingName());
pmList.add(pmDto);
}
ProductDto productDto = new ProductDto(pcList, pmList);
return productDto;
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.accounts.productdefinition.business.ProductCategoryBO in project head by mifos.
the class AdminServiceFacadeWebTier method retrieveAllProductCategories.
@Override
public ProductCategoryDisplayDto retrieveAllProductCategories() {
try {
List<ProductCategoryBO> productCategoryList = new ProductCategoryBusinessService().getAllCategories();
List<ProductCategoryTypeDto> pcTypeList = new ArrayList<ProductCategoryTypeDto>();
List<ProductCategoryDto> pcList = new ArrayList<ProductCategoryDto>();
for (ProductCategoryBO pcBO : productCategoryList) {
ProductCategoryTypeDto pcTypeDto = new ProductCategoryTypeDto(pcBO.getProductType().getProductTypeID(), pcBO.getProductType().getLookUpValue().getLookUpName());
pcTypeList.add(pcTypeDto);
ProductCategoryDto pcDto = new ProductCategoryDto(pcBO.getProductCategoryName(), pcBO.getPrdCategoryStatus().getId(), pcBO.getGlobalPrdCategoryNum());
pcList.add(pcDto);
}
ProductCategoryDisplayDto productCategoryDisplayDto = new ProductCategoryDisplayDto(pcTypeList, pcList);
return productCategoryDisplayDto;
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.accounts.productdefinition.business.ProductCategoryBO in project head by mifos.
the class LoanPrdAction method create.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("start create method of Loan Product Action");
LoanPrdActionForm loanPrdActionForm = (LoanPrdActionForm) form;
UserContext userContext = getUserContext(request);
Locale locale = getLocale(userContext);
LoanOfferingBO loanOffering = new LoanOfferingBO(userContext, loanPrdActionForm.getPrdOfferingName(), loanPrdActionForm.getPrdOfferingShortName(), getProductCategory(((List<ProductCategoryBO>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRODUCTCATEGORYLIST, request)), loanPrdActionForm.getPrdCategoryValue()), (PrdApplicableMasterEntity) findMasterEntity(request, ProductDefinitionConstants.LOANAPPLFORLIST, loanPrdActionForm.getPrdApplicableMasterEnum().getValue()), loanPrdActionForm.getStartDateValue(locale), loanPrdActionForm.getEndDateValue(locale), loanPrdActionForm.getDescription(), (GracePeriodTypeEntity) findMasterEntity(request, ProductDefinitionConstants.LOANGRACEPERIODTYPELIST, loanPrdActionForm.getGracePeriodTypeValue()), loanPrdActionForm.getGracePeriodDurationValue(), (InterestTypesEntity) findMasterEntity(request, ProductDefinitionConstants.INTERESTTYPESLIST, loanPrdActionForm.getInterestTypesValue()), loanPrdActionForm.getMaxInterestRateValue(), loanPrdActionForm.getMinInterestRateValue(), loanPrdActionForm.getDefInterestRateValue(), loanPrdActionForm.isLoanCounterValue(), loanPrdActionForm.isIntDedAtDisbValue(), loanPrdActionForm.isPrinDueLastInstValue(), getFundsFromList((List<FundBO>) SessionUtils.getAttribute(ProductDefinitionConstants.SRCFUNDSLIST, request), loanPrdActionForm.getLoanOfferingFunds()), getFeeList((List<FeeBO>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRDFEE, request), loanPrdActionForm.getPrdOfferinFees()), getPenaltyList((List<PenaltyBO>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRDPENALTY, request), loanPrdActionForm.getPrdOfferinPenalties()), new MeetingBO(RecurrenceType.fromInt(loanPrdActionForm.getFreqOfInstallmentsValue()), loanPrdActionForm.getRecurAfterValue(), loanPrdActionForm.getStartDateValue(locale), MeetingType.LOAN_INSTALLMENT), findGLCodeEntity(request, ProductDefinitionConstants.LOANPRICIPALGLCODELIST, loanPrdActionForm.getPrincipalGLCode()), findGLCodeEntity(request, ProductDefinitionConstants.LOANINTERESTGLCODELIST, loanPrdActionForm.getInterestGLCode()), loanPrdActionForm, loanPrdActionForm.shouldWaiverInterest());
loanOffering.setQuestionGroups(getQuestionGroups(request));
loanOffering.setCurrency(getCurrency(loanPrdActionForm.getCurrencyId()));
loanOffering.setRoundingDifferenceInFirstPayment(loanPrdActionForm.isRoundingDifferenceInFirstPayment());
mapCashFlowDetail(loanPrdActionForm, loanOffering);
mapVariableInstallmentDetails(loanOffering, loanPrdActionForm);
loanOffering.setFixedRepaymentSchedule(loanPrdActionForm.isFixedRepaymentSchedule());
loanOffering.save();
request.setAttribute(ProductDefinitionConstants.LOANPRODUCTID, loanOffering.getPrdOfferingId());
request.setAttribute(ProductDefinitionConstants.LOANPRDGLOBALOFFERINGNUM, loanOffering.getGlobalPrdOfferingNum());
return mapping.findForward(ActionForwards.create_success.toString());
}
use of org.mifos.accounts.productdefinition.business.ProductCategoryBO in project head by mifos.
the class AdminServiceFacadeWebTier method updateProductCategory.
@Override
public void updateProductCategory(CreateOrUpdateProductCategory productCategoryDto) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(user);
HibernateTransactionHelper transactionHelper = new HibernateTransactionHelperForStaticHibernateUtil();
try {
ProductCategoryBO categoryForUpdate = this.loanProductDao.findProductCategoryByGlobalNum(productCategoryDto.getGlobalPrdCategoryNum());
if (categoryForUpdate.hasDifferentName(productCategoryDto.getProductCategoryName())) {
this.loanProductDao.validateNameIsAvailableForCategory(productCategoryDto.getProductCategoryName(), productCategoryDto.getProductTypeEntityId());
}
transactionHelper.startTransaction();
categoryForUpdate.update(productCategoryDto.getProductCategoryName(), productCategoryDto.getProductCategoryDesc(), PrdCategoryStatus.fromInt(productCategoryDto.getProductCategoryStatusId()));
this.loanProductDao.save(categoryForUpdate);
transactionHelper.commitTransaction();
} catch (BusinessRuleException e) {
transactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getMessageKey(), e);
} catch (Exception e) {
transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
transactionHelper.closeSession();
}
}
use of org.mifos.accounts.productdefinition.business.ProductCategoryBO 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);
}
}
Aggregations