use of org.mifos.accounts.productdefinition.business.NoOfInstallSameForAllLoanBO in project head by mifos.
the class LoanProductCaluclationTypeAssembler method assembleLoanInstallmentCalculationFromDto.
public LoanInstallmentCalculation assembleLoanInstallmentCalculationFromDto(LoanAmountDetailsDto installmentCalculationDetails) {
NoOfInstallSameForAllLoanBO sameForAll = null;
Set<NoOfInstallFromLastLoanAmountBO> fromLastLoan = new HashSet<NoOfInstallFromLastLoanAmountBO>();
Set<NoOfInstallFromLoanCycleBO> fromLoanCycle = new HashSet<NoOfInstallFromLoanCycleBO>();
LoanProductCalculationType installmentCalculation = LoanProductCalculationType.fromInt(installmentCalculationDetails.getCalculationType());
switch(installmentCalculation) {
case SAME_FOR_ALL_LOANS:
sameForAll = new NoOfInstallSameForAllLoanBO(installmentCalculationDetails.getSameForAllLoanRange().getMin().shortValue(), installmentCalculationDetails.getSameForAllLoanRange().getMax().shortValue(), installmentCalculationDetails.getSameForAllLoanRange().getTheDefault().shortValue(), null);
break;
case BY_LAST_LOAN:
List<LowerUpperMinMaxDefaultDto> byLastAmount = installmentCalculationDetails.getByLastLoanAmountList();
for (LowerUpperMinMaxDefaultDto bean : byLastAmount) {
fromLastLoan.add(new NoOfInstallFromLastLoanAmountBO(bean.getMin().shortValue(), bean.getMax().shortValue(), bean.getTheDefault().shortValue(), bean.getLower().doubleValue(), bean.getUpper().doubleValue(), null));
}
break;
case BY_LOAN_CYCLE:
List<MinMaxDefaultDto> byCycle = installmentCalculationDetails.getByLoanCycleList();
Short rangeIndex = Short.valueOf("0");
for (MinMaxDefaultDto bean : byCycle) {
fromLoanCycle.add(new NoOfInstallFromLoanCycleBO(bean.getMin().shortValue(), bean.getMax().shortValue(), bean.getTheDefault().shortValue(), rangeIndex, null));
rangeIndex++;
}
break;
default:
break;
}
return new LoanInstallmentCalculation(sameForAll, fromLastLoan, fromLoanCycle);
}
use of org.mifos.accounts.productdefinition.business.NoOfInstallSameForAllLoanBO in project head by mifos.
the class LoanPrdActionStrutsTest method testGet.
@Test
public void testGet() throws PageExpiredException {
loanOffering = createLoanOfferingBO("Loan Offering", "LOAN");
StaticHibernateUtil.flushAndClearSession();
setRequestPathInfo("/loanproductaction.do");
addRequestParameter("method", "get");
addRequestParameter("prdOfferingId", loanOffering.getPrdOfferingId().toString());
actionPerform();
verifyNoActionErrors();
verifyNoActionMessages();
verifyForward(ActionForwards.get_success.toString());
LoanOfferingBO loanOffering1 = (LoanOfferingBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
loanOffering1 = (LoanOfferingBO) StaticHibernateUtil.getSessionTL().get(LoanOfferingBO.class, loanOffering1.getPrdOfferingId());
// TODO: the need to pass a locale id in to the getName methods below
// points out something that may be a bug which will show up elsewhere.
// In these cases, an object is loaded into the http session which is
// associated with a given Hibernate session. When it is loaded, somehow
// it seems to have the locale set (in MasterDataEntity). However the
// locale is not persisted. When the object is accessed after the
// Hibernate
// session has been closed, then it needs to be reloaded or reattached
// to the session. But in reloaded, the locale that has been set is
// lost.
Assert.assertNotNull(loanOffering1.getPrdOfferingId());
Assert.assertNotNull(loanOffering1.getPrdOfferingName());
Assert.assertNotNull(loanOffering1.getPrdOfferingShortName());
Assert.assertNotNull(loanOffering1.getPrdCategory().getProductCategoryName());
Assert.assertNotNull(loanOffering1.getPrdStatus().getPrdState().getName());
Assert.assertNotNull(loanOffering1.getPrdApplicableMasterEnum());
Assert.assertNotNull(loanOffering1.getStartDate());
Assert.assertNotNull(loanOffering1.getGracePeriodType().getName());
Assert.assertNotNull(loanOffering1.getGracePeriodDuration());
Assert.assertNotNull(loanOffering1.getInterestTypes().getName());
for (LoanAmountSameForAllLoanBO loanAmountSameForAllLoanBO : loanOffering1.getLoanAmountSameForAllLoan()) {
Assert.assertNotNull(loanAmountSameForAllLoanBO.getMaxLoanAmount());
Assert.assertNotNull(loanAmountSameForAllLoanBO.getMinLoanAmount());
Assert.assertNotNull(loanAmountSameForAllLoanBO.getDefaultLoanAmount());
}
Assert.assertNotNull(loanOffering1.getMaxInterestRate());
Assert.assertNotNull(loanOffering1.getMinInterestRate());
Assert.assertNotNull(loanOffering1.getDefInterestRate());
for (NoOfInstallSameForAllLoanBO noOfInstallSameForAllLoanBO : loanOffering1.getNoOfInstallSameForAllLoan()) {
Assert.assertNotNull(noOfInstallSameForAllLoanBO.getMaxNoOfInstall());
Assert.assertNotNull(noOfInstallSameForAllLoanBO.getMinNoOfInstall());
Assert.assertNotNull(noOfInstallSameForAllLoanBO.getDefaultNoOfInstall());
}
Assert.assertNotNull(loanOffering1.isIntDedDisbursement());
Assert.assertNotNull(loanOffering1.isPrinDueLastInst());
Assert.assertNotNull(loanOffering1.isIncludeInLoanCounter());
Assert.assertNotNull(loanOffering1.getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurAfter());
Assert.assertNotNull(loanOffering1.getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurrenceType().getRecurrenceId());
Assert.assertNotNull(loanOffering1.getPrincipalGLcode().getGlcode());
Assert.assertNotNull(loanOffering1.getInterestGLcode().getGlcode());
Assert.assertNotNull(loanOffering1.getLoanOfferingFees());
Assert.assertNotNull(loanOffering1.getLoanOfferingFunds());
StaticHibernateUtil.flushSession();
}
Aggregations