use of org.mifos.dto.domain.ProductDetailsDto in project head by mifos.
the class LoanOfferingBO method toFullDto.
public LoanProductRequest toFullDto() {
ProductDetailsDto details = super.toDetailsDto();
Integer currencyId = super.getCurrency().getCurrencyId().intValue();
String currencyCode = super.getCurrency().getCurrencyName();
boolean includeInLoanCounter = YesNoFlag.YES.getValue().equals(this.loanCounter);
boolean waiverInterestBool = YesNoFlag.YES.getValue().equals(this.waiverInterest);
Integer frequencyType = this.loanOfferingMeeting.getMeeting().getRecurrenceType().getValue().intValue();
Integer recurs = this.loanOfferingMeeting.getMeeting().getRecurAfter().intValue();
Integer loanAmountCalculationType = LoanProductCalculationType.UNKNOWN.getValue();
MinMaxDefaultDto loanAmountSameForAllLoanRange = null;
List<LowerUpperMinMaxDefaultDto> loanAmountByLastLoanAmountList = new ArrayList<LowerUpperMinMaxDefaultDto>();
List<MinMaxDefaultDto> loanAmountByLoanCycleList = new ArrayList<MinMaxDefaultDto>();
if (!this.loanAmountSameForAllLoan.isEmpty()) {
loanAmountCalculationType = LoanProductCalculationType.SAME_FOR_ALL_LOANS.getValue();
LoanAmountSameForAllLoanBO sameForAllLoans = getEligibleLoanAmountSameForAllLoan();
loanAmountSameForAllLoanRange = MinMaxDefaultDto.create(sameForAllLoans.getMinLoanAmount(), sameForAllLoans.getMaxLoanAmount(), sameForAllLoans.getDefaultLoanAmount());
}
if (!this.loanAmountFromLastLoan.isEmpty()) {
loanAmountCalculationType = LoanProductCalculationType.BY_LAST_LOAN.getValue();
for (LoanAmountFromLastLoanAmountBO loanCycle : this.loanAmountFromLastLoan) {
LowerUpperMinMaxDefaultDto cycle = LowerUpperMinMaxDefaultDto.create(loanCycle.getStartRange(), loanCycle.getEndRange(), loanCycle.getMinLoanAmount(), loanCycle.getMaxLoanAmount(), loanCycle.getDefaultLoanAmount());
loanAmountByLastLoanAmountList.add(cycle);
}
}
if (!this.loanAmountFromLoanCycle.isEmpty()) {
loanAmountCalculationType = LoanProductCalculationType.BY_LOAN_CYCLE.getValue();
for (LoanAmountFromLoanCycleBO loanCycle : this.loanAmountFromLoanCycle) {
MinMaxDefaultDto cycle = MinMaxDefaultDto.create(loanCycle.getMinLoanAmount(), loanCycle.getMaxLoanAmount(), loanCycle.getDefaultLoanAmount());
loanAmountByLoanCycleList.add(cycle);
}
}
LoanAmountDetailsDto loanAmountDetails = new LoanAmountDetailsDto(loanAmountCalculationType, loanAmountSameForAllLoanRange, loanAmountByLastLoanAmountList, loanAmountByLoanCycleList);
Integer installmentCalculationType = LoanProductCalculationType.UNKNOWN.getValue();
MinMaxDefaultDto installmentSameForAllLoanRange = null;
List<LowerUpperMinMaxDefaultDto> installmentByLastLoanAmountList = new ArrayList<LowerUpperMinMaxDefaultDto>();
List<MinMaxDefaultDto> installmentByLoanCycleList = new ArrayList<MinMaxDefaultDto>();
if (!this.noOfInstallSameForAllLoan.isEmpty()) {
installmentCalculationType = LoanProductCalculationType.SAME_FOR_ALL_LOANS.getValue();
LoanOfferingInstallmentRange sameForAllLoans = getEligibleInstallmentSameForAllLoan();
installmentSameForAllLoanRange = MinMaxDefaultDto.create(sameForAllLoans.getMinNoOfInstall(), sameForAllLoans.getMaxNoOfInstall(), sameForAllLoans.getDefaultNoOfInstall());
}
if (!this.noOfInstallFromLastLoan.isEmpty()) {
installmentCalculationType = LoanProductCalculationType.BY_LAST_LOAN.getValue();
for (NoOfInstallFromLastLoanAmountBO loanCycle : this.noOfInstallFromLastLoan) {
LowerUpperMinMaxDefaultDto cycle = LowerUpperMinMaxDefaultDto.create(loanCycle.getStartRange(), loanCycle.getEndRange(), loanCycle.getMinNoOfInstall(), loanCycle.getMaxNoOfInstall(), loanCycle.getDefaultNoOfInstall());
installmentByLastLoanAmountList.add(cycle);
}
}
if (!this.noOfInstallFromLoanCycle.isEmpty()) {
installmentCalculationType = LoanProductCalculationType.BY_LOAN_CYCLE.getValue();
for (NoOfInstallFromLoanCycleBO loanCycle : this.noOfInstallFromLoanCycle) {
MinMaxDefaultDto cycle = MinMaxDefaultDto.create(loanCycle.getMinNoOfInstall(), loanCycle.getMaxNoOfInstall(), loanCycle.getDefaultNoOfInstall());
installmentByLoanCycleList.add(cycle);
}
}
LoanAmountDetailsDto installmentCalculationDetails = new LoanAmountDetailsDto(installmentCalculationType, installmentSameForAllLoanRange, installmentByLastLoanAmountList, installmentByLoanCycleList);
RepaymentDetailsDto repaymentDetails = new RepaymentDetailsDto(frequencyType, recurs, installmentCalculationDetails, this.gracePeriodType.getId().intValue(), this.gracePeriodDuration.intValue());
Integer interestRateType = this.interestTypes.getId().intValue();
MinMaxDefaultDto interestRateRange = MinMaxDefaultDto.create(this.minInterestRate, this.maxInterestRate, this.defInterestRate);
List<String> fees = new ArrayList<String>();
List<Integer> applicableFees = new ArrayList<Integer>();
for (LoanOfferingFeesEntity fee : this.loanOfferingFees) {
applicableFees.add(fee.getFees().getFeeId().intValue());
fees.add(fee.getFees().getFeeName());
}
List<String> funds = new ArrayList<String>();
List<Integer> applicableFunds = new ArrayList<Integer>();
for (LoanOfferingFundEntity fund : this.loanOfferingFunds) {
applicableFunds.add(fund.getFund().getFundId().intValue());
funds.add(fund.getFund().getFundName());
}
List<String> penalties = new ArrayList<String>();
List<Integer> applicablePenalties = new ArrayList<Integer>();
for (PrdOfferingPenaltiesEntity penalty : this.loanOfferingPenalties) {
applicablePenalties.add(penalty.getPenalty().getPenaltyId().intValue());
penalties.add(penalty.getPenalty().getPenaltyName());
}
Integer interestGlCodeId = this.interestGLcode.getGlcodeId().intValue();
String interestGlCodeValue = this.interestGLcode.getGlcode();
Integer principalClCodeId = this.principalGLcode.getGlcodeId().intValue();
String principalGlCodeValue = this.principalGLcode.getGlcode();
AccountingDetailsDto accountDetails = new AccountingDetailsDto(applicableFunds, interestGlCodeId, principalClCodeId);
LoanProductRequest loanProductDto = new LoanProductRequest(details, includeInLoanCounter, waiverInterestBool, currencyId, loanAmountDetails, interestRateType, interestRateRange, repaymentDetails, applicableFees, applicablePenalties, accountDetails);
loanProductDto.setMultiCurrencyEnabled(false);
loanProductDto.setCurrencyCode(currencyCode);
loanProductDto.setInterestRateTypeName(this.interestTypes.getName());
loanProductDto.setFees(fees);
loanProductDto.setFunds(funds);
loanProductDto.setPenalties(penalties);
loanProductDto.setInterestGlCodeValue(interestGlCodeValue);
loanProductDto.setPrincipalGlCodeValue(principalGlCodeValue);
return loanProductDto;
}
use of org.mifos.dto.domain.ProductDetailsDto in project head by mifos.
the class LoanAccountServiceFacadeWebTier method retrieveLoanDetailsForLoanAccountCreation.
@Override
public LoanCreationLoanDetailsDto retrieveLoanDetailsForLoanAccountCreation(Integer customerId, Short productId, boolean isLoanWithBackdatedPayments) {
try {
List<org.mifos.dto.domain.FeeDto> additionalFees = new ArrayList<org.mifos.dto.domain.FeeDto>();
List<org.mifos.dto.domain.FeeDto> defaultFees = new ArrayList<org.mifos.dto.domain.FeeDto>();
List<PenaltyDto> defaultPenalties = new ArrayList<PenaltyDto>();
LoanOfferingBO loanProduct = this.loanProductDao.findById(productId.intValue());
MeetingBO loanProductMeeting = loanProduct.getLoanOfferingMeetingValue();
MeetingDto loanOfferingMeetingDto = loanProductMeeting.toDto();
List<FeeBO> fees = this.feeDao.getAllAppllicableFeeForLoanCreation();
for (FeeBO fee : fees) {
if (!fee.isPeriodic() || (MeetingBO.isMeetingMatched(fee.getFeeFrequency().getFeeMeetingFrequency(), loanProductMeeting))) {
org.mifos.dto.domain.FeeDto feeDto = fee.toDto();
FeeFrequencyType feeFrequencyType = FeeFrequencyType.getFeeFrequencyType(fee.getFeeFrequency().getFeeFrequencyType().getId());
FeeFrequencyTypeEntity feeFrequencyEntity = this.loanProductDao.retrieveFeeFrequencyType(feeFrequencyType);
String feeFrequencyTypeName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(feeFrequencyEntity.getLookUpValue());
feeDto.setFeeFrequencyType(feeFrequencyTypeName);
if (feeDto.getFeeFrequency().isOneTime()) {
FeePayment feePayment = FeePayment.getFeePayment(fee.getFeeFrequency().getFeePayment().getId());
FeePaymentEntity feePaymentEntity = this.loanProductDao.retrieveFeePaymentType(feePayment);
String feePaymentName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(feePaymentEntity.getLookUpValue());
feeDto.getFeeFrequency().setPayment(feePaymentName);
}
if (loanProduct.isFeePresent(fee)) {
defaultFees.add(feeDto);
} else {
additionalFees.add(feeDto);
}
}
}
List<PenaltyBO> penalties = this.penaltyDao.getAllAppllicablePenaltyForLoanCreation();
for (PenaltyBO penalty : penalties) {
if (loanProduct.isPenaltyPresent(penalty)) {
defaultPenalties.add(penalty.toDto());
}
}
if (AccountingRules.isMultiCurrencyEnabled()) {
defaultFees = getFilteredFeesByCurrency(defaultFees, loanProduct.getCurrency().getCurrencyId());
additionalFees = getFilteredFeesByCurrency(additionalFees, loanProduct.getCurrency().getCurrencyId());
}
Map<String, String> defaultFeeOptions = new LinkedHashMap<String, String>();
for (org.mifos.dto.domain.FeeDto feeDto : defaultFees) {
defaultFeeOptions.put(feeDto.getId(), feeDto.getName());
}
Map<String, String> additionalFeeOptions = new LinkedHashMap<String, String>();
for (org.mifos.dto.domain.FeeDto feeDto : additionalFees) {
additionalFeeOptions.put(feeDto.getId(), feeDto.getName());
}
CustomerBO customer = this.customerDao.findCustomerById(customerId);
boolean isRepaymentIndependentOfMeetingEnabled = new ConfigurationBusinessService().isRepaymentIndepOfMeetingEnabled();
LoanDisbursementDateFactory loanDisbursementDateFactory = new LoanDisbursmentDateFactoryImpl();
LoanDisbursementDateFinder loanDisbursementDateFinder = null;
LocalDate nextPossibleDisbursementDate = null;
MeetingBO customerMeeting = customer.getCustomerMeetingValue();
LocalDate dateToStart = new LocalDate();
if (customerMeeting.isWeekly()) {
LocalDate meetingStartDate = new LocalDate(customerMeeting.getMeetingStartDate());
if (dateToStart.isBefore(meetingStartDate)) {
dateToStart = meetingStartDate;
loanDisbursementDateFinder = loanDisbursementDateFactory.create(customer, loanProduct, false, isLoanWithBackdatedPayments);
} else {
loanDisbursementDateFinder = loanDisbursementDateFactory.create(customer, loanProduct, isRepaymentIndependentOfMeetingEnabled, isLoanWithBackdatedPayments);
}
nextPossibleDisbursementDate = loanDisbursementDateFinder.findClosestMatchingDateFromAndInclusiveOf(dateToStart);
} else {
loanDisbursementDateFinder = loanDisbursementDateFactory.create(customer, loanProduct, isRepaymentIndependentOfMeetingEnabled, isLoanWithBackdatedPayments);
nextPossibleDisbursementDate = loanDisbursementDateFinder.findClosestMatchingDateFromAndInclusiveOf(dateToStart);
}
LoanAmountOption eligibleLoanAmount = loanProduct.eligibleLoanAmount(customer.getMaxLoanAmount(loanProduct), customer.getMaxLoanCycleForProduct(loanProduct));
LoanOfferingInstallmentRange eligibleNoOfInstall = loanProduct.eligibleNoOfInstall(customer.getMaxLoanAmount(loanProduct), customer.getMaxLoanCycleForProduct(loanProduct));
Double defaultInterestRate = loanProduct.getDefInterestRate();
Double maxInterestRate = loanProduct.getMaxInterestRate();
Double minInterestRate = loanProduct.getMinInterestRate();
LinkedHashMap<String, String> collateralOptions = new LinkedHashMap<String, String>();
LinkedHashMap<String, String> purposeOfLoanOptions = new LinkedHashMap<String, String>();
CustomValueDto customValueDto = legacyMasterDao.getLookUpEntity(MasterConstants.COLLATERAL_TYPES);
List<CustomValueListElementDto> collateralTypes = customValueDto.getCustomValueListElements();
for (CustomValueListElementDto element : collateralTypes) {
collateralOptions.put(element.getId().toString(), element.getName());
}
// Business activities got in getPrdOfferings also but only for glim.
List<ValueListElement> loanPurposes = legacyMasterDao.findValueListElements(MasterConstants.LOAN_PURPOSES);
for (ValueListElement element : loanPurposes) {
purposeOfLoanOptions.put(element.getId().toString(), element.getName());
}
List<FundDto> fundDtos = new ArrayList<FundDto>();
List<FundBO> funds = getFunds(loanProduct);
for (FundBO fund : funds) {
FundDto fundDto = new FundDto();
fundDto.setId(Short.toString(fund.getFundId()));
fundDto.setCode(translateFundCodeToDto(fund.getFundCode()));
fundDto.setName(fund.getFundName());
fundDtos.add(fundDto);
}
ProductDetailsDto productDto = loanProduct.toDetailsDto();
CustomerDetailDto customerDetailDto = customer.toCustomerDetailDto();
Integer gracePeriodInInstallments = loanProduct.getGracePeriodDuration().intValue();
final List<PrdOfferingDto> loanProductDtos = retrieveActiveLoanProductsApplicableForCustomer(customer, isRepaymentIndependentOfMeetingEnabled);
InterestType interestType = InterestType.fromInt(loanProduct.getInterestTypes().getId().intValue());
InterestTypesEntity productInterestType = this.loanProductDao.findInterestType(interestType);
String interestTypeName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(productInterestType.getLookUpValue());
LinkedHashMap<String, String> daysOfTheWeekOptions = new LinkedHashMap<String, String>();
List<WeekDay> workingDays = new FiscalCalendarRules().getWorkingDays();
for (WeekDay workDay : workingDays) {
String weekdayName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(workDay.getPropertiesKey());
workDay.setWeekdayName(weekdayName);
daysOfTheWeekOptions.put(workDay.getValue().toString(), weekdayName);
}
LinkedHashMap<String, String> weeksOfTheMonthOptions = new LinkedHashMap<String, String>();
for (RankOfDay weekOfMonth : RankOfDay.values()) {
String weekOfMonthName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(weekOfMonth.getPropertiesKey());
weeksOfTheMonthOptions.put(weekOfMonth.getValue().toString(), weekOfMonthName);
}
boolean variableInstallmentsAllowed = loanProduct.isVariableInstallmentsAllowed();
boolean fixedRepaymentSchedule = loanProduct.isFixedRepaymentSchedule();
Integer minGapInDays = Integer.valueOf(0);
Integer maxGapInDays = Integer.valueOf(0);
BigDecimal minInstallmentAmount = BigDecimal.ZERO;
if (variableInstallmentsAllowed) {
VariableInstallmentDetailsBO variableInstallmentsDetails = loanProduct.getVariableInstallmentDetails();
minGapInDays = variableInstallmentsDetails.getMinGapInDays();
maxGapInDays = variableInstallmentsDetails.getMaxGapInDays();
minInstallmentAmount = variableInstallmentsDetails.getMinInstallmentAmount().getAmount();
}
boolean compareCashflowEnabled = loanProduct.isCashFlowCheckEnabled();
// GLIM specific
final boolean isGroup = customer.isGroup();
final boolean isGlimEnabled = configurationPersistence.isGlimEnabled();
//Group Loan Account with members specific
final boolean isGroupLoanWithMembersEnabled = AccountingRules.isGroupLoanWithMembers();
List<LoanAccountDetailsDto> clientDetails = new ArrayList<LoanAccountDetailsDto>();
if (isGroup && (isGlimEnabled || isGroupLoanWithMembersEnabled)) {
final List<ClientBO> activeClientsOfGroup = customerDao.findActiveClientsUnderGroup(customer);
if (activeClientsOfGroup == null || activeClientsOfGroup.isEmpty()) {
throw new BusinessRuleException(GroupConstants.IMPOSSIBLE_TO_CREATE_GROUP_LOAN);
}
for (ClientBO client : activeClientsOfGroup) {
LoanAccountDetailsDto clientDetail = new LoanAccountDetailsDto();
clientDetail.setClientId(client.getGlobalCustNum());
clientDetail.setClientName(client.getDisplayName());
clientDetails.add(clientDetail);
}
}
// end of GLIM specific
int digitsAfterDecimalForInterest = AccountingRules.getDigitsAfterDecimalForInterest().intValue();
int digitsBeforeDecimalForInterest = AccountingRules.getDigitsBeforeDecimalForInterest().intValue();
int digitsAfterDecimalForMonetaryAmounts = AccountingRules.getDigitsAfterDecimal().intValue();
int digitsBeforeDecimalForMonetaryAmounts = AccountingRules.getDigitsBeforeDecimal().intValue();
ApplicationConfigurationDto appConfig = new ApplicationConfigurationDto(digitsAfterDecimalForInterest, digitsBeforeDecimalForInterest, digitsAfterDecimalForMonetaryAmounts, digitsBeforeDecimalForMonetaryAmounts);
Map<String, String> disbursalPaymentTypes = new LinkedHashMap<String, String>();
try {
for (PaymentTypeDto paymentTypeDto : accountService.getLoanDisbursementTypes()) {
disbursalPaymentTypes.put(paymentTypeDto.getValue().toString(), paymentTypeDto.getName());
}
} catch (Exception e) {
throw new SystemException(e);
}
Map<String, String> repaymentpaymentTypes = new LinkedHashMap<String, String>();
try {
for (PaymentTypeDto paymentTypeDto : accountService.getLoanPaymentTypes()) {
repaymentpaymentTypes.put(paymentTypeDto.getValue().toString(), paymentTypeDto.getName());
}
} catch (Exception e) {
throw new SystemException(e);
}
String currency = loanProduct.getCurrency().getCurrencyCode();
return new LoanCreationLoanDetailsDto(currency, isRepaymentIndependentOfMeetingEnabled, loanOfferingMeetingDto, customer.getCustomerMeetingValue().toDto(), loanPurposes, productDto, gracePeriodInInstallments, customerDetailDto, loanProductDtos, interestTypeName, fundDtos, collateralOptions, purposeOfLoanOptions, defaultFeeOptions, additionalFeeOptions, defaultFees, additionalFees, BigDecimal.valueOf(eligibleLoanAmount.getDefaultLoanAmount()), BigDecimal.valueOf(eligibleLoanAmount.getMaxLoanAmount()), BigDecimal.valueOf(eligibleLoanAmount.getMinLoanAmount()), defaultInterestRate, maxInterestRate, minInterestRate, eligibleNoOfInstall.getDefaultNoOfInstall().intValue(), eligibleNoOfInstall.getMaxNoOfInstall().intValue(), eligibleNoOfInstall.getMinNoOfInstall().intValue(), nextPossibleDisbursementDate, daysOfTheWeekOptions, weeksOfTheMonthOptions, variableInstallmentsAllowed, fixedRepaymentSchedule, minGapInDays, maxGapInDays, minInstallmentAmount, compareCashflowEnabled, isGlimEnabled, isGroup, clientDetails, appConfig, defaultPenalties, disbursalPaymentTypes, repaymentpaymentTypes, isGroupLoanWithMembersEnabled);
} catch (SystemException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.dto.domain.ProductDetailsDto in project head by mifos.
the class SavingsProductAssembler method fromDto.
public SavingsOfferingBO fromDto(MifosUser user, SavingsProductDto savingsProductRequest) {
try {
// FIXME - keithw - this is general assembler common to both savings and loans i.e. all products. so
// ProductDao and ProductAssembler
ProductDetailsDto productDetails = savingsProductRequest.getProductDetails();
String name = productDetails.getName();
String shortName = productDetails.getShortName();
String description = productDetails.getDescription();
Integer category = productDetails.getCategory();
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);
PrdStatusEntity activeStatus = new PrdOfferingPersistence().getPrdStatus(PrdStatus.SAVINGS_ACTIVE);
PrdStatusEntity inActiveStatus = new PrdOfferingPersistence().getPrdStatus(PrdStatus.SAVINGS_INACTIVE);
PrdStatusEntity selectedStatus = activeStatus;
if (productDetails.getStatus() != null && inActiveStatus.getOfferingStatusId().equals(productDetails.getStatus().shortValue())) {
selectedStatus = inActiveStatus;
}
String globalNum = generateProductGlobalNum(user);
// savings specific
SavingsType savingsType = SavingsType.fromInt(savingsProductRequest.getDepositType());
SavingsTypeEntity savingsTypeEntity = this.loanProductDao.retrieveSavingsType(savingsType);
RecommendedAmntUnitEntity recommendedAmntUnitEntity = null;
if (savingsProductRequest.getGroupMandatorySavingsType() != null) {
RecommendedAmountUnit recommendedAmountType = RecommendedAmountUnit.fromInt(savingsProductRequest.getGroupMandatorySavingsType());
recommendedAmntUnitEntity = this.loanProductDao.retrieveRecommendedAmountType(recommendedAmountType);
}
Money amountForDeposit = new Money(Money.getDefaultCurrency(), BigDecimal.valueOf(savingsProductRequest.getAmountForDeposit()));
Money maxWithdrawal = new Money(Money.getDefaultCurrency(), BigDecimal.valueOf(savingsProductRequest.getMaxWithdrawal()));
// interest specific
BigDecimal interestRate = savingsProductRequest.getInterestRate();
InterestCalcType interestCalcType = InterestCalcType.fromInt(savingsProductRequest.getInterestCalculationType());
InterestCalcTypeEntity interestCalcTypeEntity = this.savingsProductDao.retrieveInterestCalcType(interestCalcType);
RecurrenceType recurrence = RecurrenceType.fromInt(savingsProductRequest.getInterestCalculationFrequencyPeriod().shortValue());
Integer every = savingsProductRequest.getInterestCalculationFrequency();
MeetingBO interestCalculationMeeting = new MeetingBO(recurrence, every.shortValue(), new Date(), MeetingType.SAVINGS_INTEREST_CALCULATION_TIME_PERIOD);
Integer interestPostingEveryMonthFreq = savingsProductRequest.getInterestPostingFrequency();
RecurrenceType interestPostingRecurrenceType = null;
if (savingsProductRequest.isDailyPosting()) {
interestPostingRecurrenceType = RecurrenceType.DAILY;
} else {
interestPostingRecurrenceType = RecurrenceType.MONTHLY;
}
MeetingBO interestPostingMeeting = new MeetingBO(interestPostingRecurrenceType, interestPostingEveryMonthFreq.shortValue(), new Date(), MeetingType.SAVINGS_INTEREST_POSTING);
Money minAmountForCalculation = new Money(Money.getDefaultCurrency(), savingsProductRequest.getMinBalanceForInterestCalculation());
GLCodeEntity depositGlEntity = this.generalLedgerDao.findGlCodeById(savingsProductRequest.getDepositGlCode().shortValue());
GLCodeEntity interestGlEntity = this.generalLedgerDao.findGlCodeById(savingsProductRequest.getInterestGlCode().shortValue());
MifosCurrency currency = Money.getDefaultCurrency();
return SavingsOfferingBO.createNew(user.getUserId(), globalNum, name, shortName, description, productCategory, startDate, endDate, applicableToEntity, currency, selectedStatus, savingsTypeEntity, recommendedAmntUnitEntity, amountForDeposit, maxWithdrawal, interestRate, interestCalcTypeEntity, interestCalculationMeeting, interestPostingMeeting, minAmountForCalculation, depositGlEntity, interestGlEntity);
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
} catch (MeetingException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.dto.domain.ProductDetailsDto 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.ProductDetailsDto in project head by mifos.
the class LoanProductFormBeanAssembler method populateWithLoanProductDetails.
public void populateWithLoanProductDetails(LoanProductFormBean loanProductFormBean, LoanProductRequest loanProductRequest) {
ProductDetailsDto productDto = loanProductRequest.getProductDetails();
GeneralProductBean productBean = new GeneralProductBeanAssembler().assembleFrom(loanProductFormBean.getGeneralDetails(), productDto);
loanProductFormBean.setGeneralDetails(productBean);
loanProductFormBean.setSelectedCurrency(loanProductRequest.getCurrencyId().toString());
loanProductFormBean.setIncludeInLoanCycleCounter(loanProductRequest.isIncludeInLoanCycleCounter());
loanProductFormBean.setWaiverInterest(loanProductRequest.isWaiverInterest());
LoanAmountDetailsDto loanAmountDetailsDto = loanProductRequest.getLoanAmountDetails();
populateLoanAmountCalculationDetails(loanProductFormBean, loanAmountDetailsDto);
loanProductFormBean.setSelectedInterestRateCalculationType(loanProductRequest.getInterestRateType().toString());
loanProductFormBean.setMinInterestRate(loanProductRequest.getInterestRateRange().getMin().doubleValue());
loanProductFormBean.setMaxInterestRate(loanProductRequest.getInterestRateRange().getMax().doubleValue());
loanProductFormBean.setDefaultInterestRate(loanProductRequest.getInterestRateRange().getTheDefault().doubleValue());
loanProductFormBean.setInstallmentFrequencyPeriod(loanProductRequest.getRepaymentDetails().getFrequencyType().toString());
loanProductFormBean.setInstallmentFrequencyRecurrenceEvery(loanProductRequest.getRepaymentDetails().getRecurs());
LoanAmountDetailsDto installmentDetailsDto = loanProductRequest.getRepaymentDetails().getInstallmentCalculationDetails();
populateInstallmentCalculationDetails(loanProductFormBean, installmentDetailsDto);
loanProductFormBean.setSelectedGracePeriodType(loanProductRequest.getRepaymentDetails().getGracePeriodType().toString());
loanProductFormBean.setGracePeriodDurationInInstallments(loanProductRequest.getRepaymentDetails().getGracePeriodDuration());
populateFeesAndFundsMultiSelectBoxes(loanProductFormBean, loanProductRequest);
loanProductFormBean.setSelectedInterest(loanProductRequest.getAccountDetails().getInterestGlCodeId().toString());
loanProductFormBean.setSelectedPrincipal(loanProductRequest.getAccountDetails().getPrincipalClCodeId().toString());
}
Aggregations