use of org.mifos.dto.screen.SavingsProductReferenceDto in project head by mifos.
the class SavingsAction method load.
@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
SavingsActionForm savingsActionForm = ((SavingsActionForm) form);
logger.debug(" selectedPrdOfferingId: " + savingsActionForm.getSelectedPrdOfferingId());
UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
List<InterestCalcTypeEntity> interestCalculationTypes = this.savingsProductDao.retrieveInterestCalculationTypes();
SessionUtils.setCollectionAttribute(MasterConstants.INTEREST_CAL_TYPES, interestCalculationTypes, request);
Integer productId = Integer.valueOf(savingsActionForm.getSelectedPrdOfferingId());
SavingsOfferingBO savingsOfferingBO = this.savingsProductDao.findById(productId);
SessionUtils.setAttribute(SavingsConstants.PRDOFFERING, savingsOfferingBO, request);
// NOTE - these details are included in SavingsProductReferenceDto but left as is to satisfy JSP at present
SessionUtils.setCollectionAttribute(MasterConstants.SAVINGS_TYPE, legacyMasterDao.findMasterDataEntitiesWithLocale(SavingsTypeEntity.class), request);
SessionUtils.setCollectionAttribute(MasterConstants.RECOMMENDED_AMOUNT_UNIT, legacyMasterDao.findMasterDataEntitiesWithLocale(RecommendedAmntUnitEntity.class), request);
List<CustomFieldDefinitionEntity> customFieldDefinitions = new ArrayList<CustomFieldDefinitionEntity>();
SessionUtils.setCollectionAttribute(SavingsConstants.CUSTOM_FIELDS, customFieldDefinitions, request);
SavingsProductReferenceDto savingsProductReferenceDto = this.savingsServiceFacade.retrieveSavingsProductReferenceData(productId);
savingsActionForm.setRecommendedAmount(savingsProductReferenceDto.getSavingsProductDetails().getAmountForDeposit().toString());
List<CustomFieldDto> customFields = CustomFieldDefinitionEntity.toDto(customFieldDefinitions, uc.getPreferredLocale());
savingsActionForm.setAccountCustomFieldSet(customFields);
return mapping.findForward("load_success");
}
use of org.mifos.dto.screen.SavingsProductReferenceDto 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);
}
use of org.mifos.dto.screen.SavingsProductReferenceDto in project head by mifos.
the class CreateSavingsAccountController method createAccount.
private SavingsAccountDetailDto createAccount(CreateSavingsAccountFormBean formBean, Short accountState) {
SavingsProductReferenceDto productReference = formBean.getProduct();
SavingsProductDto savingsProduct = productReference.getSavingsProductDetails();
Integer productId = savingsProduct.getProductDetails().getId();
Integer customerId = formBean.getCustomer().getCustomerId();
// TODO - deposit amount should be validated before reaching here...
String recommendedOrMandatoryAmount = formBean.getMandatoryDepositAmount();
SavingsAccountCreationDto savingsAccountCreation = new SavingsAccountCreationDto(productId, customerId, accountState, recommendedOrMandatoryAmount);
Long savingsId = savingsServiceFacade.createSavingsAccount(savingsAccountCreation, formBean.getQuestionGroups());
SavingsAccountDetailDto savingsAccountDetailDto = savingsServiceFacade.retrieveSavingsAccountDetails(savingsId);
return savingsAccountDetailDto;
}
use of org.mifos.dto.screen.SavingsProductReferenceDto in project head by mifos.
the class CreateSavingsAccountControllerTest method testLoadProduct.
@SuppressWarnings("unchecked")
@Test
public void testLoadProduct() {
Integer productId = 1;
List<ListElement> interestCalculationOptions = new ArrayList<ListElement>();
boolean groupSavingsAccount = false;
Integer depositType = 1;
Integer groupSavingsType = 1;
Double amountForDeposit = 10.0;
Double maxWithdrawal = 100.0;
BigDecimal interestRate = new BigDecimal("5.0");
Integer interestCalculationType = 1;
Integer interestCalculationFrequency = 1;
Integer interestCalculationFrequencyPeriod = 1;
Integer interestPostingMonthlyFrequency = 1;
BigDecimal minBalanceForInterestCalculation = new BigDecimal("1.0");
Integer depositGlCode = 1;
Integer interestGlCode = 1;
ProductDetailsDto productsDetailDto = null;
SavingsProductDto savingsProductDetails = new SavingsProductDto(productsDetailDto, groupSavingsAccount, depositType, groupSavingsType, amountForDeposit, maxWithdrawal, interestRate, interestCalculationType, interestCalculationFrequency, interestCalculationFrequencyPeriod, interestPostingMonthlyFrequency, minBalanceForInterestCalculation, depositGlCode, interestGlCode, false);
SavingsProductReferenceDto savingsProductReference = new SavingsProductReferenceDto(interestCalculationOptions, savingsProductDetails, true);
when(savingsServiceFacade.retrieveSavingsProductReferenceData(productId)).thenReturn(savingsProductReference);
controller.loadProduct(productId, formBean);
verify(formBean).setProductId(productId);
verify(formBean).setProduct(savingsProductReference);
verify(formBean).setMandatoryDepositAmount(any(String.class));
verify(formBean).setSavingsTypes(any(Map.class));
verify(formBean).setRecurrenceTypes(any(Map.class));
verify(formBean).setRecurrenceFrequencies(any(Map.class));
}
use of org.mifos.dto.screen.SavingsProductReferenceDto in project head by mifos.
the class CreateSavingsAccountFormBeanTest method setDepositType.
/**
* Sets deposit type in the form bean.
*/
private void setDepositType(CreateSavingsAccountFormBean formBean, int depositType) {
SavingsProductDto productDetails = mock(SavingsProductDto.class);
when(productDetails.getDepositType()).thenReturn(depositType);
SavingsProductReferenceDto productRef = mock(SavingsProductReferenceDto.class);
when(productRef.getSavingsProductDetails()).thenReturn(productDetails);
formBean.setProduct(productRef);
}
Aggregations