use of org.mifos.customers.persistence.CustomerPersistence in project head by mifos.
the class CustAction method getClosedAccounts.
@TransactionDemarcate(joinToken = true)
public ActionForward getClosedAccounts(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In CustAction::getClosedAccounts()");
UserContext userContext = getUserContext(request);
Integer customerId = getIntegerValue(((CustActionForm) form).getCustomerId());
List<ClosedAccountDto> allClosedAccounts = this.centerServiceFacade.retrieveAllClosedAccounts(customerId);
List<AccountBO> loanAccountsList = new CustomerPersistence().getAllClosedAccount(customerId, AccountTypes.LOAN_ACCOUNT.getValue());
loanAccountsList.addAll(new CustomerPersistence().getAllClosedAccount(customerId, AccountTypes.GROUP_LOAN_ACCOUNT.getValue()));
List<AccountBO> savingsAccountList = new CustomerPersistence().getAllClosedAccount(customerId, AccountTypes.SAVINGS_ACCOUNT.getValue());
SessionUtils.setCollectionAttribute(AccountConstants.CLOSEDLOANACCOUNTSLIST, loanAccountsList, request);
SessionUtils.setCollectionAttribute(AccountConstants.CLOSEDSAVINGSACCOUNTSLIST, savingsAccountList, request);
return mapping.findForward(ActionForwards.getAllClosedAccounts.toString());
}
use of org.mifos.customers.persistence.CustomerPersistence in project head by mifos.
the class CustSearchAction method mainSearch.
@TransactionDemarcate(joinToken = true)
public ActionForward mainSearch(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
CustSearchActionForm actionForm = (CustSearchActionForm) form;
Short officeId = getShortValue(actionForm.getOfficeId());
String searchString = actionForm.getSearchString();
UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USERCONTEXT, request.getSession());
super.search(mapping, form, request, response);
if (searchString == null || searchString.equals("")) {
ActionErrors errors = new ActionErrors();
errors.add(CustomerSearchConstants.NAMEMANDATORYEXCEPTION, new ActionMessage(CustomerSearchConstants.NAMEMANDATORYEXCEPTION));
request.setAttribute(Globals.ERROR_KEY, errors);
return mapping.findForward(ActionForwards.mainSearch_success.toString());
}
if (officeId != null && officeId != 0) {
addSeachValues(searchString, officeId.toString(), new OfficePersistence().getOffice(officeId).getOfficeName(), request);
} else {
addSeachValues(searchString, officeId.toString(), new OfficePersistence().getOffice(userContext.getBranchId()).getOfficeName(), request);
}
searchString = SearchUtils.normalizeSearchString(searchString);
if (searchString.equals("")) {
throw new CustomerException(CustomerSearchConstants.NAMEMANDATORYEXCEPTION);
}
if (actionForm.getFilters() == null) {
actionForm.setFilters(new SearchFiltersDto());
}
QueryResult customerSearchResult = new CustomerPersistence().search(searchString, officeId, userContext.getId(), userContext.getBranchId(), actionForm.getFilters());
SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, customerSearchResult, request);
return mapping.findForward(ActionForwards.mainSearch_success.toString());
}
use of org.mifos.customers.persistence.CustomerPersistence in project head by mifos.
the class GroupActionStrutsTest method createCenterWithoutFee.
private void createCenterWithoutFee() throws Exception {
meeting = new MeetingBO(WeekDay.MONDAY, EVERY_WEEK, new Date(), MeetingType.CUSTOMER_MEETING, "Delhi");
center = new CenterBO(userContext, "MyCenter", null, null, null, "1234", null, TestObjectFactory.getBranchOffice(), meeting, TestObjectFactory.getTestUser(), new CustomerPersistence());
new CenterPersistence().saveCenter(center);
StaticHibernateUtil.flushAndClearSession();
}
use of org.mifos.customers.persistence.CustomerPersistence in project head by mifos.
the class CenterBOIntegrationTest method testSuccessfulCreateWithoutFeeAndCustomField.
@Test
public void testSuccessfulCreateWithoutFeeAndCustomField() throws Exception {
String name = "Center";
meeting = getMeeting();
center = new CenterBO(TestUtils.makeUser(), name, null, null, null, null, null, officeBo, meeting, personnelBo, new CustomerPersistence());
new CenterPersistence().saveCenter(center);
StaticHibernateUtil.flushSession();
center = TestObjectFactory.getCenter(center.getCustomerId());
Assert.assertEquals(name, center.getDisplayName());
Assert.assertEquals(officeId, center.getOffice().getOfficeId());
}
use of org.mifos.customers.persistence.CustomerPersistence in project head by mifos.
the class CenterBOIntegrationTest method testSuccessfulCreate.
@Test
public void testSuccessfulCreate() throws Exception {
String name = "Center";
String externalId = "12345";
Date mfiJoiningDate = getDate("11/12/2005");
meeting = getMeeting();
List<FeeDto> fees = getFees();
center = new CenterBO(TestUtils.makeUser(), name, null, getCustomFields(), fees, externalId, mfiJoiningDate, new OfficePersistence().getOffice(officeId), meeting, legacyPersonnelDao.getPersonnel(personnelId), new CustomerPersistence());
new CenterPersistence().saveCenter(center);
StaticHibernateUtil.flushSession();
center = TestObjectFactory.getCenter(center.getCustomerId());
Assert.assertEquals(name, center.getDisplayName());
Assert.assertEquals(externalId, center.getExternalId());
Assert.assertEquals(mfiJoiningDate, DateUtils.getDateWithoutTimeStamp(center.getMfiJoiningDate().getTime()));
Assert.assertEquals(officeId, center.getOffice().getOfficeId());
Assert.assertEquals(2, center.getCustomFields().size());
Assert.assertEquals(AccountState.CUSTOMER_ACCOUNT_ACTIVE.getValue(), center.getCustomerAccount().getAccountState().getId());
// check if values in account fees are entered.
Assert.assertNotNull(center.getCustomerAccount().getAccountFees(fees.get(0).getFeeIdValue()));
Assert.assertNotNull(center.getCustomerAccount().getAccountFees(fees.get(1).getFeeIdValue()));
}
Aggregations