use of org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO in project head by mifos.
the class MultipleLoanAccountsCreationActionStrutsTest method testCreateWithouSelectingClient.
@Test
public void testCreateWithouSelectingClient() throws Exception {
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
createInitialCustomers();
LoanOfferingBO loanOffering = getLoanOffering("vcxvxc", "a123", ApplicableTo.CLIENTS, WEEKLY, EVERY_WEEK);
// loanOffering.updateLoanOfferingSameForAllLoan(loanOffering);
LoanAmountSameForAllLoanBO eligibleLoanAmountRange = loanOffering.getEligibleLoanAmountSameForAllLoan();
setRequestPathInfo("/multipleloansaction.do");
addRequestParameter("method", "get");
addRequestParameter("branchOfficeId", center.getOffice().getOfficeId().toString());
addRequestParameter("loanOfficerId", center.getPersonnel().getPersonnelId().toString());
addRequestParameter("prdOfferingId", loanOffering.getPrdOfferingId().toString());
SessionUtils.setAttribute(LoanConstants.IS_CENTER_HIERARCHY_EXISTS, Constants.YES, request);
addRequestParameter("centerId", center.getCustomerId().toString());
addRequestParameter("centerSearchId", center.getSearchId().toString());
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
actionPerform();
setRequestPathInfo("/multipleloansaction.do");
addRequestParameter("clientDetails[0].loanAmount", eligibleLoanAmountRange.getDefaultLoanAmount().toString());
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
addRequestParameter("stateSelected", "1");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
addRequestParameter("method", "create");
addRequestParameter("stateSelected", "1");
actionPerform();
verifyActionErrors(new String[] { LoanExceptionConstants.SELECT_ATLEAST_ONE_RECORD });
verifyInputForward();
TestObjectFactory.removeObject(loanOffering);
}
use of org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO in project head by mifos.
the class LoanAccountActionFormTest method assertForAmountError.
private void assertForAmountError(String inputValue) {
new LoanAccountActionForm().checkForMinMax(actionErrors, inputValue, new LoanAmountSameForAllLoanBO((double) 1, (double) 3, (double) 2, null), AMOUNT_ERROR_KEY);
Assert.assertEquals(1, actionErrors.size());
ActionMessage message = (ActionMessage) actionErrors.get(AMOUNT_ERROR_KEY).next();
Assert.assertNotNull(message);
Assert.assertEquals(LoanExceptionConstants.INVALIDMINMAX, message.getKey());
}
use of org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO in project head by mifos.
the class LoanProductBuilder method build.
private LoanOfferingBO build() {
final LoanOfferingBO loanProduct = new LoanOfferingBO(depositGLCode, interesetGLCode, interestType, minInterestRate, maxInterestRate, defaultInterestRate, interestPaidAtDisbursement, principalDueLastInstallment, name, shortName, globalProductNumber, startDate, applicableToCustomer, category, productStatusEntity, createdDate, createdByUserId);
if (useLoanAmountSameForAllLoans) {
final Double minLoanAmount = Double.valueOf("100.0");
final Double maxLoanAmount = Double.valueOf("100000.0");
final Double defaultLoanAmount = Double.valueOf("1000.0");
loanProduct.setLoanAmountSameForAllLoan(new LoanAmountSameForAllLoanBO(minLoanAmount, maxLoanAmount, defaultLoanAmount, loanProduct));
}
if (useNoOfInstallSameForAllLoans) {
final Short minNoOfInstallmentsForLoan = Short.valueOf("1");
final Short maxNoOfInstallmentsForLoan = Short.valueOf("11");
final Short defaultNoOfInstallmentsForLoan = Short.valueOf("6");
loanProduct.setNoOfInstallSameForAllLoan(new NoOfInstallSameForAllLoanBO(minNoOfInstallmentsForLoan, maxNoOfInstallmentsForLoan, defaultNoOfInstallmentsForLoan, loanProduct));
}
loanProduct.setGracePeriodType(new GracePeriodTypeEntity(graceType));
loanProduct.setLoanOfferingMeeting(new PrdOfferingMeetingEntity(meeting, loanProduct, MeetingType.LOAN_INSTALLMENT));
return loanProduct;
}
use of org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO in project head by mifos.
the class LoanProductCaluclationTypeAssembler method assembleLoanAmountCalculationFromDto.
public LoanAmountCalculation assembleLoanAmountCalculationFromDto(LoanAmountDetailsDto loanAmountDetails) {
LoanProductCalculationType loanCalculation = LoanProductCalculationType.fromInt(loanAmountDetails.getCalculationType());
LoanAmountSameForAllLoanBO sameForAll = null;
Set<LoanAmountFromLastLoanAmountBO> loanAmountFromLastLoan = new HashSet<LoanAmountFromLastLoanAmountBO>();
Set<LoanAmountFromLoanCycleBO> loanAmountFromLoanCycle = new HashSet<LoanAmountFromLoanCycleBO>();
switch(loanCalculation) {
case SAME_FOR_ALL_LOANS:
MinMaxDefaultDto sameForAllLoan = loanAmountDetails.getSameForAllLoanRange();
sameForAll = new LoanAmountSameForAllLoanBO(sameForAllLoan.getMin().doubleValue(), sameForAllLoan.getMax().doubleValue(), sameForAllLoan.getTheDefault().doubleValue(), null);
break;
case BY_LAST_LOAN:
List<LowerUpperMinMaxDefaultDto> byLastAmount = loanAmountDetails.getByLastLoanAmountList();
for (LowerUpperMinMaxDefaultDto bean : byLastAmount) {
loanAmountFromLastLoan.add(new LoanAmountFromLastLoanAmountBO(bean.getMin().doubleValue(), bean.getMax().doubleValue(), bean.getTheDefault().doubleValue(), bean.getLower().doubleValue(), bean.getUpper().doubleValue(), null));
}
break;
case BY_LOAN_CYCLE:
List<MinMaxDefaultDto> byCycle = loanAmountDetails.getByLoanCycleList();
Short rangeIndex = Short.valueOf("0");
for (MinMaxDefaultDto bean : byCycle) {
loanAmountFromLoanCycle.add(new LoanAmountFromLoanCycleBO(bean.getMin().doubleValue(), bean.getMax().doubleValue(), bean.getTheDefault().doubleValue(), rangeIndex, null));
rangeIndex++;
}
break;
default:
break;
}
return new LoanAmountCalculation(sameForAll, loanAmountFromLastLoan, loanAmountFromLoanCycle);
}
use of org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO 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