use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.
the class MultipleLoanAccountsCreationActionStrutsTest method testGet.
@Test
public void testGet() throws Exception {
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
createInitialCustomers();
LoanOfferingBO loanOffering = getLoanOffering("vcxvxc", "a123", ApplicableTo.CLIENTS, WEEKLY, EVERY_WEEK);
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);
performNoErrors();
verifyForward(ActionForwards.get_success.toString());
// this retrieve the loan purposes so this is 129 if empty lookup name
// are removed
Assert.assertEquals(131, ((List) SessionUtils.getAttribute(MasterConstants.BUSINESS_ACTIVITIES, request)).size());
Assert.assertNotNull(SessionUtils.getAttribute(LoanConstants.LOANOFFERING, request));
Assert.assertNotNull(SessionUtils.getAttribute(CustomerConstants.PENDING_APPROVAL_DEFINED, request));
TestObjectFactory.removeObject(loanOffering);
}
use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.
the class MultipleLoanAccountsCreationActionStrutsTest method testGetPrdOfferingsApplicableForCustomer.
@SuppressWarnings("unchecked")
@Test
public void testGetPrdOfferingsApplicableForCustomer() throws Exception {
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
createInitialCustomers();
LoanOfferingBO loanOffering1 = getLoanOffering("fdfsdfsd", "ertg", ApplicableTo.GROUPS, WEEKLY, EVERY_WEEK);
LoanOfferingBO loanOffering2 = getLoanOffering("rwrfdb", "1qsd", ApplicableTo.GROUPS, WEEKLY, EVERY_WEEK);
LoanOfferingBO loanOffering3 = getLoanOffering("mksgfgfd", "9u78", ApplicableTo.CLIENTS, WEEKLY, EVERY_WEEK);
setRequestPathInfo("/multipleloansaction.do");
addRequestParameter("method", "getPrdOfferings");
addRequestParameter("loanOfficerId", "1");
addRequestParameter("branchOfficeId", "1");
addRequestParameter("centerId", center.getCustomerId().toString());
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
SessionUtils.setAttribute(LoanConstants.IS_CENTER_HIERARCHY_EXISTS, Constants.YES, request);
performNoErrors();
verifyForward(ActionForwards.load_success.toString());
Assert.assertEquals(1, ((List<LoanOfferingBO>) SessionUtils.getAttribute(LoanConstants.LOANPRDOFFERINGS, request)).size());
TestObjectFactory.removeObject(loanOffering1);
TestObjectFactory.removeObject(loanOffering2);
TestObjectFactory.removeObject(loanOffering3);
}
use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.
the class QuestionGroupFilterForLoanTest method shouldDoFilter.
@Test
public void shouldDoFilter() {
QuestionGroupFilterForLoan questionGroupFilterForLoan = new QuestionGroupFilterForLoan();
LoanOfferingBO loanOfferingBO = new LoanProductBuilder().buildForUnitTests();
loanOfferingBO.setQuestionGroups(getQustionGroups(2, 4));
questionGroupFilterForLoan.setLoanOfferingBO(loanOfferingBO);
List<QuestionGroupDetail> questionGroupDetails = asList(getQuestionGroupDetail(1, "QG1"), getQuestionGroupDetail(2, "QG2"), getQuestionGroupDetail(3, "QG3"), getQuestionGroupDetail(4, "QG4"));
List<QuestionGroupDetail> filteredQuestionGroupDetails = questionGroupFilterForLoan.doFilter(questionGroupDetails, new Criteria<QuestionGroupDetail>() {
@Override
public QuestionGroupDetail filter(Integer questionGroupId, List<QuestionGroupDetail> questionGroupDetails) {
QuestionGroupDetail result = null;
for (QuestionGroupDetail questionGroupDetail : questionGroupDetails) {
if (questionGroupId.equals(questionGroupDetail.getId())) {
result = questionGroupDetail;
break;
}
}
return result;
}
});
assertThat(filteredQuestionGroupDetails, is(notNullValue()));
assertThat(filteredQuestionGroupDetails.size(), is(2));
assertThat(filteredQuestionGroupDetails.get(0).getId(), is(2));
assertThat(filteredQuestionGroupDetails.get(0).getTitle(), is("QG2"));
assertThat(filteredQuestionGroupDetails.get(1).getId(), is(4));
assertThat(filteredQuestionGroupDetails.get(1).getTitle(), is("QG4"));
}
use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.
the class QuestionGroupFilterForLoanTest method shouldDoFilterForNoLoanOfferingQuestionGroups.
@Test
public void shouldDoFilterForNoLoanOfferingQuestionGroups() {
QuestionGroupFilterForLoan questionGroupFilterForLoan = new QuestionGroupFilterForLoan();
LoanOfferingBO loanOfferingBO = new LoanProductBuilder().buildForUnitTests();
loanOfferingBO.setQuestionGroups(new HashSet<QuestionGroupReference>());
questionGroupFilterForLoan.setLoanOfferingBO(loanOfferingBO);
List<QuestionGroupDetail> questionGroupDetails = asList(getQuestionGroupDetail(1, "QG1"), getQuestionGroupDetail(2, "QG2"), getQuestionGroupDetail(3, "QG3"), getQuestionGroupDetail(4, "QG4"));
List<QuestionGroupDetail> filteredQuestionGroupDetails = questionGroupFilterForLoan.doFilter(questionGroupDetails, null);
assertThat(filteredQuestionGroupDetails, is(notNullValue()));
assertThat(filteredQuestionGroupDetails.size(), is(0));
loanOfferingBO.setQuestionGroups(null);
filteredQuestionGroupDetails = questionGroupFilterForLoan.doFilter(questionGroupDetails, null);
assertThat(filteredQuestionGroupDetails, is(notNullValue()));
assertThat(filteredQuestionGroupDetails.size(), is(0));
}
use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.
the class BulkEntryActionStrutsTest method getFailureBulkEntry.
private CollectionSheetEntryGridDto getFailureBulkEntry() throws Exception {
Date startDate = new Date(System.currentTimeMillis());
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("Client", CustomerStatus.CLIENT_ACTIVE, group);
LoanOfferingBO loanOffering1 = TestObjectFactory.createLoanOffering(startDate, meeting);
LoanOfferingBO loanOffering2 = TestObjectFactory.createLoanOffering("Loan2345", "313f", startDate, meeting);
groupAccount = TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering1);
clientAccount = TestObjectFactory.createLoanAccount("3243", client, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering2);
MeetingBO meetingIntCalc = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
MeetingBO meetingIntPost = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
SavingsOfferingBO savingsOffering = TestObjectFactory.createSavingsProduct("SavingPrd123c", "ased", ApplicableTo.GROUPS, startDate, PrdStatus.SAVINGS_ACTIVE, 300.0, RecommendedAmountUnit.PER_INDIVIDUAL, 1.2, 200.0, 200.0, SavingsType.VOLUNTARY, InterestCalcType.MINIMUM_BALANCE, meetingIntCalc, meetingIntPost);
SavingsOfferingBO savingsOffering1 = TestObjectFactory.createSavingsProduct("SavingPrd1we", "vbgr", ApplicableTo.GROUPS, startDate, PrdStatus.SAVINGS_ACTIVE, 300.0, RecommendedAmountUnit.PER_INDIVIDUAL, 1.2, 200.0, 200.0, SavingsType.VOLUNTARY, InterestCalcType.MINIMUM_BALANCE, meetingIntCalc, meetingIntPost);
centerSavingsAccount = TestObjectFactory.createSavingsAccount("432434", center, Short.valueOf("16"), startDate, savingsOffering);
clientSavingsAccount = TestObjectFactory.createSavingsAccount("432434", client, Short.valueOf("16"), startDate, savingsOffering1);
CollectionSheetEntryDto bulkEntryParent = new CollectionSheetEntryDto(getCusomerView(center), null);
bulkEntryParent.addSavingsAccountDetail(getSavingsAccountView(centerSavingsAccount));
bulkEntryParent.setCustomerAccountDetails(getCustomerAccountView(center));
CollectionSheetEntryDto bulkEntryChild = new CollectionSheetEntryDto(getCusomerView(group), null);
LoanAccountDto groupLoanAccountView = getLoanAccountView(groupAccount);
bulkEntryChild.addLoanAccountDetails(groupLoanAccountView);
bulkEntryChild.setCustomerAccountDetails(getCustomerAccountView(group));
CollectionSheetEntryDto bulkEntrySubChild = new CollectionSheetEntryDto(getCusomerView(client), null);
LoanAccountDto clientLoanAccountView = getLoanAccountView(clientAccount);
bulkEntrySubChild.addLoanAccountDetails(clientLoanAccountView);
bulkEntrySubChild.addSavingsAccountDetail(getSavingsAccountView(clientSavingsAccount));
bulkEntrySubChild.setCustomerAccountDetails(getCustomerAccountView(client));
bulkEntryChild.addChildNode(bulkEntrySubChild);
bulkEntryParent.addChildNode(bulkEntryChild);
bulkEntryChild.getLoanAccountDetails().get(0).setEnteredAmount("100.0");
bulkEntryChild.getLoanAccountDetails().get(0).setPrdOfferingId(groupLoanAccountView.getPrdOfferingId());
bulkEntrySubChild.getLoanAccountDetails().get(0).setEnteredAmount("100.0");
bulkEntrySubChild.getLoanAccountDetails().get(0).setPrdOfferingId(clientLoanAccountView.getPrdOfferingId());
ProductDto loanOfferingDto = new ProductDto(loanOffering1.getPrdOfferingId(), loanOffering1.getPrdOfferingShortName());
ProductDto loanOfferingDto2 = new ProductDto(loanOffering2.getPrdOfferingId(), loanOffering2.getPrdOfferingShortName());
List<ProductDto> loanProducts = Arrays.asList(loanOfferingDto, loanOfferingDto2);
ProductDto savingsOfferingDto = new ProductDto(savingsOffering.getPrdOfferingId(), savingsOffering.getPrdOfferingShortName());
List<ProductDto> savingsProducts = Arrays.asList(savingsOfferingDto);
final PersonnelDto loanOfficer = getPersonnelView(center.getPersonnel());
final OfficeDetailsDto officeDetailsDto = null;
final List<CustomValueListElementDto> attendanceTypesList = new ArrayList<CustomValueListElementDto>();
bulkEntryParent.setCountOfCustomers(3);
final CollectionSheetEntryGridDto bulkEntry = new CollectionSheetEntryGridDto(bulkEntryParent, loanOfficer, officeDetailsDto, getPaymentTypeView(), startDate, "324343242", startDate, loanProducts, savingsProducts, attendanceTypesList);
return bulkEntry;
}
Aggregations