Search in sources :

Example 21 with CustomerPersistence

use of org.mifos.customers.persistence.CustomerPersistence in project head by mifos.

the class TestObjectFactory method createCenter.

public static CenterBO createCenter(final String customerName, final MeetingBO meeting, final Short officeId, final Short personnelId, final List<FeeDto> fees) {
    CenterBO center;
    try {
        center = new CenterBO(TestUtils.makeUserWithLocales(), customerName, null, null, fees, null, null, new OfficePersistence().getOffice(officeId), meeting, ApplicationContextProvider.getBean(LegacyPersonnelDao.class).getPersonnel(personnelId), new CustomerPersistence());
        new CenterPersistence().saveCenter(center);
        StaticHibernateUtil.flushSession();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return center;
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) CenterBO(org.mifos.customers.center.business.CenterBO) LegacyPersonnelDao(org.mifos.customers.personnel.persistence.LegacyPersonnelDao) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerException(org.mifos.customers.exceptions.CustomerException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) OfficeException(org.mifos.customers.office.exceptions.OfficeException) CenterPersistence(org.mifos.customers.center.persistence.CenterPersistence)

Example 22 with CustomerPersistence

use of org.mifos.customers.persistence.CustomerPersistence in project head by mifos.

the class ProcessFlowRulesIntegrationTest method testValidOverrideAgainstDb.

@Test
public void testValidOverrideAgainstDb() throws Exception {
    CustomerPersistence cp = new CustomerPersistence();
    CustomerStatusEntity cse = (CustomerStatusEntity) cp.loadPersistentObject(CustomerStatusEntity.class, CustomerStatus.CLIENT_PENDING.getValue());
    Assert.assertTrue(cse.getIsOptional());
    cse.setIsOptional(false);
    StaticHibernateUtil.flushSession();
    Assert.assertFalse(cse.getIsOptional());
    Assert.assertTrue(ProcessFlowRules.isClientPendingApprovalStateEnabled());
    ProcessFlowRules.init();
    Assert.assertTrue(cse.getIsOptional());
}
Also used : CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) Test(org.junit.Test)

Example 23 with CustomerPersistence

use of org.mifos.customers.persistence.CustomerPersistence in project head by mifos.

the class CustomerCreationDaoHibernateIntegrationTest method testShouldCreateCustomerAndCustomerAccount.

@Test
public void testShouldCreateCustomerAndCustomerAccount() throws Exception {
    String displayName = "centerCascade";
    Address address = null;
    final List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    final List<FeeDto> fees = new ArrayList<FeeDto>();
    final String externalId = null;
    final Date mfiJoiningDate = new DateTime().minusDays(1).toDate();
    final OfficeBO existingOffice = IntegrationTestObjectMother.sampleBranchOffice();
    final PersonnelBO loanOfficer = IntegrationTestObjectMother.testUser();
    UserContext userContext = new UserContext();
    userContext.setId(loanOfficer.getPersonnelId());
    userContext.setBranchId(existingOffice.getOfficeId());
    userContext.setBranchGlobalNum(existingOffice.getGlobalOfficeNum());
    center = new CenterBO(userContext, displayName, address, customFields, fees, externalId, mfiJoiningDate, existingOffice, weeklyMeeting, loanOfficer, new CustomerPersistence());
    StaticHibernateUtil.startTransaction();
    customerDao.save(center);
    StaticHibernateUtil.flushSession();
    assertThat(center.getCustomerAccount(), is(notNullValue()));
    assertThat(center.getGlobalCustNum(), is(nullValue()));
}
Also used : Address(org.mifos.framework.business.util.Address) UserContext(org.mifos.security.util.UserContext) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) FeeDto(org.mifos.accounts.fees.business.FeeDto) CenterBO(org.mifos.customers.center.business.CenterBO) Date(java.util.Date) DateTime(org.joda.time.DateTime) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) Test(org.junit.Test)

Example 24 with CustomerPersistence

use of org.mifos.customers.persistence.CustomerPersistence in project head by mifos.

the class IntegrationTestObjectMother method update.

public static void update(CustomerBO customer) {
    try {
        new CustomerPersistence().createOrUpdate(customer);
        StaticHibernateUtil.flushSession();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) CustomerException(org.mifos.customers.exceptions.CustomerException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AccountException(org.mifos.accounts.exceptions.AccountException)

Example 25 with CustomerPersistence

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());
}
Also used : ClosedAccountDto(org.mifos.dto.screen.ClosedAccountDto) AccountBO(org.mifos.accounts.business.AccountBO) UserContext(org.mifos.security.util.UserContext) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

CustomerPersistence (org.mifos.customers.persistence.CustomerPersistence)40 PersistenceException (org.mifos.framework.exceptions.PersistenceException)15 UserContext (org.mifos.security.util.UserContext)14 ArrayList (java.util.ArrayList)13 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)11 Date (java.util.Date)10 Test (org.junit.Test)9 MifosRuntimeException (org.mifos.core.MifosRuntimeException)9 ConfigurationPersistence (org.mifos.config.persistence.ConfigurationPersistence)8 CustomerBO (org.mifos.customers.business.CustomerBO)8 LocalDate (org.joda.time.LocalDate)7 AccountException (org.mifos.accounts.exceptions.AccountException)7 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)7 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)7 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)6 CustomerException (org.mifos.customers.exceptions.CustomerException)6 BusinessRuleException (org.mifos.service.BusinessRuleException)6 AccountBO (org.mifos.accounts.business.AccountBO)5 CenterPersistence (org.mifos.customers.center.persistence.CenterPersistence)5 DateTime (org.joda.time.DateTime)4