use of org.mifos.dto.domain.ProductDetailsDto in project head by mifos.
the class LoanProductAssembler method fromDto.
public LoanOfferingBO fromDto(MifosUser user, LoanProductRequest loanProductRequest) {
try {
Integer userId = user.getUserId();
ProductDetailsDto productDetails = loanProductRequest.getProductDetails();
String name = productDetails.getName();
String shortName = productDetails.getShortName();
String description = productDetails.getDescription();
Integer category = productDetails.getCategory();
boolean loanCycleCounter = loanProductRequest.isIncludeInLoanCycleCounter();
boolean waiverInterest = loanProductRequest.isWaiverInterest();
PrdStatusEntity activeStatus = new PrdOfferingPersistence().getPrdStatus(PrdStatus.LOAN_ACTIVE);
PrdStatusEntity inActiveStatus = new PrdOfferingPersistence().getPrdStatus(PrdStatus.LOAN_INACTIVE);
PrdStatusEntity selectedStatus = activeStatus;
if (productDetails.getStatus() != null && inActiveStatus.getOfferingStatusId().equals(productDetails.getStatus().shortValue())) {
selectedStatus = inActiveStatus;
}
MifosCurrency currency = Money.getDefaultCurrency();
if (AccountingRules.isMultiCurrencyEnabled()) {
currency = AccountingRules.getCurrencyByCurrencyId(loanProductRequest.getCurrencyId().shortValue());
}
ProductCategoryBO productCategory = this.loanProductDao.findActiveProductCategoryById(category);
DateTime startDate = productDetails.getStartDate();
DateTime endDate = productDetails.getEndDate();
ApplicableTo applicableTo = ApplicableTo.fromInt(productDetails.getApplicableFor());
PrdApplicableMasterEntity applicableToEntity = this.loanProductDao.findApplicableProductType(applicableTo);
LoanAmountCalculation loanAmountCalculation = this.loanProductCaluclationTypeAssembler.assembleLoanAmountCalculationFromDto(loanProductRequest.getLoanAmountDetails());
InterestType interestType = InterestType.fromInt(loanProductRequest.getInterestRateType());
Double minRate = loanProductRequest.getInterestRateRange().getMin().doubleValue();
Double maxRate = loanProductRequest.getInterestRateRange().getMax().doubleValue();
Double defaultRate = loanProductRequest.getInterestRateRange().getTheDefault().doubleValue();
InterestTypesEntity interestTypeEntity = this.loanProductDao.findInterestType(interestType);
RecurrenceType recurrence = RecurrenceType.fromInt(loanProductRequest.getRepaymentDetails().getFrequencyType().shortValue());
Integer recurEvery = loanProductRequest.getRepaymentDetails().getRecurs();
LoanInstallmentCalculation loanInstallmentCalculation = this.loanProductCaluclationTypeAssembler.assembleLoanInstallmentCalculationFromDto(loanProductRequest.getRepaymentDetails().getInstallmentCalculationDetails());
GraceType gracePeriodType = GraceType.fromInt(loanProductRequest.getRepaymentDetails().getGracePeriodType());
GracePeriodTypeEntity gracePeriodTypeEntity = this.loanProductDao.findGracePeriodType(gracePeriodType);
Integer gracePeriodDuration = loanProductRequest.getRepaymentDetails().getGracePeriodDuration();
List<FeeBO> applicableFees = new ArrayList<FeeBO>();
List<Integer> applicableFeeIds = loanProductRequest.getApplicableFees();
for (Integer feeId : applicableFeeIds) {
FeeBO fee = ApplicationContextProvider.getBean(FeeDao.class).findById(feeId.shortValue());
applicableFees.add(fee);
}
List<FundBO> applicableFunds = new ArrayList<FundBO>();
List<Integer> applicableFundIds = loanProductRequest.getAccountDetails().getApplicableFunds();
for (Integer fundId : applicableFundIds) {
FundBO fund = this.fundDao.findById(fundId.shortValue());
applicableFunds.add(fund);
}
List<PenaltyBO> applicablePenalties = new ArrayList<PenaltyBO>();
List<Integer> applicablePenaltyIds = loanProductRequest.getApplicablePenalties();
for (Integer penaltyId : applicablePenaltyIds) {
PenaltyBO penalty = this.penaltyDao.findPenaltyById(penaltyId);
applicablePenalties.add(penalty);
}
GLCodeEntity interestGlCode = this.generalLedgerDao.findGlCodeById(loanProductRequest.getAccountDetails().getInterestGlCodeId().shortValue());
GLCodeEntity principalGlCode = this.generalLedgerDao.findGlCodeById(loanProductRequest.getAccountDetails().getPrincipalClCodeId().shortValue());
String globalProductId = generateProductGlobalNum(user);
LoanOfferingBO loanProduct = LoanOfferingBO.createNew(userId, globalProductId, name, shortName, description, productCategory, startDate, endDate, applicableToEntity, currency, interestTypeEntity, minRate, maxRate, defaultRate, recurrence, recurEvery, interestGlCode, principalGlCode, activeStatus, inActiveStatus, gracePeriodTypeEntity, gracePeriodDuration, waiverInterest, loanCycleCounter, loanAmountCalculation, loanInstallmentCalculation, applicableFees, applicableFunds, applicablePenalties);
loanProduct.updateStatus(selectedStatus);
return loanProduct;
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.dto.domain.ProductDetailsDto in project head by mifos.
the class PrdOfferingBO method toDetailsDto.
public ProductDetailsDto toDetailsDto() {
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault());
DateTime startDateTime = new DateTime(this.startDate);
String startDateFormatted = format.format(this.startDate);
String endDateFormatted = "";
DateTime endDateTime = null;
if (this.endDate != null) {
endDateTime = new DateTime(this.endDate);
endDateFormatted = format.format(this.endDate);
}
ProductDetailsDto detailsDto = new ProductDetailsDto(this.prdOfferingName, this.prdOfferingShortName, this.description, this.prdCategory.getProductCategoryID().intValue(), startDateTime, endDateTime, this.prdApplicableMaster.getId().intValue());
detailsDto.setId(this.prdOfferingId.intValue());
detailsDto.setGlobalNumber(this.globalPrdOfferingNum);
detailsDto.setStatus(this.prdStatus.getOfferingStatusId().intValue());
detailsDto.setCategoryName(this.prdCategory.getProductCategoryName());
detailsDto.setStartDateFormatted(startDateFormatted);
detailsDto.setEndDateFormatted(endDateFormatted);
detailsDto.setCreatedDate(new DateTime(this.getCreatedDate()));
detailsDto.setCreatedDateFormatted(format.format(this.getCreatedDate()));
return detailsDto;
}
use of org.mifos.dto.domain.ProductDetailsDto in project head by mifos.
the class SavingsOfferingBO method toFullDto.
public SavingsProductDto toFullDto() {
ProductDetailsDto details = super.toDetailsDto();
Integer groupSavingsType = Integer.valueOf(0);
boolean groupSavingsAccount = false;
if (this.recommendedAmntUnit != null) {
groupSavingsType = this.recommendedAmntUnit.getId().intValue();
groupSavingsAccount = true;
}
PrdOfferingMeetingEntity interestCalculationPeriod = getTimePerForInstcalc();
PrdOfferingMeetingEntity interestPosting = getFreqOfPostIntcalc();
SavingsProductDto savingsProductDto = new SavingsProductDto(details, groupSavingsAccount, this.savingsType.getId().intValue(), groupSavingsType, this.recommendedAmount.getAmountDoubleValue(), this.maxAmntWithdrawl.getAmountDoubleValue(), BigDecimal.valueOf(this.interestRate), this.interestCalcType.getId().intValue(), interestCalculationPeriod.getMeeting().getRecurAfter().intValue(), interestCalculationPeriod.getMeeting().getRecurrenceType().getValue().intValue(), interestPosting.getMeeting().getRecurAfter().intValue(), this.minAmntForInt.getAmount(), this.depositGLCode.getGlcodeId().intValue(), this.interestGLCode.getGlcodeId().intValue(), interestPosting.getMeeting().isDaily());
savingsProductDto.setDepositGlCodeValue(this.depositGLCode.getGlcode());
savingsProductDto.setInterestGlCodeValue(this.interestGLCode.getGlcode());
savingsProductDto.setDepositGlCodeName(this.depositGLCode.getAssociatedCOA().getAccountName());
savingsProductDto.setInterestGlCodeName(this.interestGLCode.getAssociatedCOA().getAccountName());
return savingsProductDto;
}
use of org.mifos.dto.domain.ProductDetailsDto 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.ProductDetailsDto in project head by mifos.
the class EditSavingsProductsFormController method showPopulatedForm.
@RequestMapping(method = RequestMethod.GET)
public ModelAndView showPopulatedForm(@RequestParam(value = "productId", required = true) Integer productId) {
ModelAndView modelAndView = new ModelAndView("editSavingsProduct");
configurationDto = this.configurationServiceFacade.getAccountingConfiguration();
modelAndView.addObject("GLCodeMode", configurationDto.getGlCodeMode());
SavingsProductFormDto referenceData = this.adminServiceFacade.retrieveSavingsProductFormReferenceData();
SavingsProductDto savingsProductDto = adminServiceFacade.retrieveSavingsProductDetails(productId);
SavingsProductFormBean savingsProductBean = new SavingsProductFormBeanAssembler().assembleReferenceData(referenceData);
ProductDetailsDto productDto = savingsProductDto.getProductDetails();
GeneralProductBean productBean = new GeneralProductBeanAssembler().assembleFrom(savingsProductBean.getGeneralDetails(), productDto);
savingsProductBean.setGeneralDetails(productBean);
savingsProductBean.setSelectedDepositType(savingsProductDto.getDepositType().toString());
savingsProductBean.setAmountForDeposit(savingsProductDto.getAmountForDeposit());
if (savingsProductDto.getGroupMandatorySavingsType() > 0) {
savingsProductBean.setSelectedGroupSavingsApproach(savingsProductDto.getGroupMandatorySavingsType().toString());
} else {
savingsProductBean.setSelectedGroupSavingsApproach("");
}
savingsProductBean.setMaxWithdrawalAmount(savingsProductDto.getMaxWithdrawal());
savingsProductBean.setInterestRate(savingsProductDto.getInterestRate());
savingsProductBean.setSelectedInterestCalculation(savingsProductDto.getInterestCalculationType().toString());
savingsProductBean.setInterestCalculationFrequency(savingsProductDto.getInterestCalculationFrequency());
savingsProductBean.setSelectedFequencyPeriod(savingsProductDto.getInterestCalculationFrequencyPeriod().toString());
savingsProductBean.setInterestPostingMonthlyFrequency(savingsProductDto.getInterestPostingFrequency());
savingsProductBean.setMinBalanceRequiredForInterestCalculation(Long.toString(savingsProductDto.getMinBalanceForInterestCalculation().longValue()));
savingsProductBean.setIsDaily(savingsProductDto.isDailyPosting());
savingsProductBean.setSelectedPrincipalGlCode(savingsProductDto.getDepositGlCode().toString());
savingsProductBean.setSelectedInterestGlCode(savingsProductDto.getInterestGlCode().toString());
savingsProductBean.setNotUpdateable(savingsProductDto.isOpenSavingsAccountsExist());
modelAndView.addObject("savingsProduct", savingsProductBean);
return modelAndView;
}
Aggregations