use of org.mifos.dto.domain.SavingsProductDto in project head by mifos.
the class SavingsProductFormBeanAssembler method assembleSavingsProductRequest.
public SavingsProductDto assembleSavingsProductRequest(SavingsProductFormBean formBean) {
Integer category = Integer.valueOf(formBean.getGeneralDetails().getSelectedCategory());
Integer applicableFor = Integer.valueOf(formBean.getGeneralDetails().getSelectedApplicableFor());
DateTime startDate = new DateTime().withDate(Integer.valueOf(formBean.getGeneralDetails().getStartDateYear()), formBean.getGeneralDetails().getStartDateMonth(), formBean.getGeneralDetails().getStartDateDay());
DateTime endDate = null;
if (StringUtils.isNotBlank(formBean.getGeneralDetails().getEndDateYear())) {
endDate = new DateTime().withDate(Integer.valueOf(formBean.getGeneralDetails().getEndDateYear()), formBean.getGeneralDetails().getEndDateMonth(), formBean.getGeneralDetails().getEndDateDay());
}
ProductDetailsDto productDetails = new ProductDetailsDto(formBean.getGeneralDetails().getName(), formBean.getGeneralDetails().getShortName(), formBean.getGeneralDetails().getDescription(), category, startDate, endDate, applicableFor);
productDetails.setId(formBean.getGeneralDetails().getId());
if (StringUtils.isNotBlank(formBean.getGeneralDetails().getSelectedStatus())) {
Integer status = Integer.valueOf(formBean.getGeneralDetails().getSelectedStatus());
productDetails.setStatus(status);
}
Integer depositType = Integer.valueOf(formBean.getSelectedDepositType());
Integer groupSavingsType = null;
if (StringUtils.isNotBlank(formBean.getSelectedGroupSavingsApproach())) {
groupSavingsType = Integer.valueOf(formBean.getSelectedGroupSavingsApproach());
}
Double amountForDeposit = formBean.getAmountForDeposit();
Double maxWithdrawal = formBean.getMaxWithdrawalAmount();
BigDecimal interestRate = formBean.getInterestRate();
Integer interestCalculationType = Integer.valueOf(formBean.getSelectedInterestCalculation());
Integer interestCalculationFrequencyPeriod = Integer.valueOf(formBean.getSelectedFequencyPeriod());
BigDecimal minBalanceForInterestCalculation = BigDecimal.valueOf(Double.valueOf(formBean.getMinBalanceRequiredForInterestCalculation()));
Integer interestGlCode = Integer.parseInt(formBean.getSelectedInterestGlCode());
Integer depositGlCode = Integer.parseInt(formBean.getSelectedPrincipalGlCode());
return new SavingsProductDto(productDetails, formBean.isGroupSavingAccount(), depositType, groupSavingsType, amountForDeposit, maxWithdrawal, interestRate, interestCalculationType, formBean.getInterestCalculationFrequency(), interestCalculationFrequencyPeriod, formBean.getInterestPostingMonthlyFrequency(), minBalanceForInterestCalculation, depositGlCode, interestGlCode, formBean.getIsDaily());
}
use of org.mifos.dto.domain.SavingsProductDto 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.domain.SavingsProductDto in project head by mifos.
the class AdminServiceFacadeWebTier method retrieveSavingsProductDetails.
@Override
public SavingsProductDto retrieveSavingsProductDetails(Integer productId) {
SavingsOfferingBO savingsProduct = this.savingsProductDao.findById(productId);
boolean openSavingsAccountsExist = this.savingsProductDao.activeOrInactiveSavingsAccountsExistForProduct(productId);
SavingsProductDto dto = savingsProduct.toFullDto();
dto.setOpenSavingsAccountsExist(openSavingsAccountsExist);
return dto;
}
use of org.mifos.dto.domain.SavingsProductDto 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.domain.SavingsProductDto 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