Search in sources :

Example 16 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO in project head by mifos.

the class LoanAccountServiceFacadeWebTier method retrieveLoanPaymentsForReversal.

@Override
public List<LoanActivityDto> retrieveLoanPaymentsForReversal(String globalAccountNum) {
    MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(mifosUser);
    OfficeBO userOffice = this.officeDao.findOfficeById(userContext.getBranchId());
    userContext.setOfficeLevelId(userOffice.getOfficeLevel().getValue());
    LoanBO loan = null;
    LoanBO searchedLoan = this.loanDao.findByGlobalAccountNum(globalAccountNum);
    if (searchedLoan != null && isAccountUnderUserScope(searchedLoan, userContext)) {
        loan = searchedLoan;
    }
    if (loan == null) {
        throw new BusinessRuleException(LoanConstants.NOSEARCHRESULTS);
    }
    if (!loan.isAccountActive() || loan.isGroupLoanAccountMember()) {
        throw new BusinessRuleException(LoanConstants.NOSEARCHRESULTS);
    }
    return getApplicablePayments(loan);
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) OfficeBO(org.mifos.customers.office.business.OfficeBO) UserContext(org.mifos.security.util.UserContext) LoanBO(org.mifos.accounts.loan.business.LoanBO) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory)

Example 17 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO in project head by mifos.

the class TestOffices method add.

public OfficeBO add(String shortName, String globalOfficeNum, int parentOfficeId, OfficeLevel level, String searchId, OfficeStatus status) {
    OfficeBO officeBO = new OfficeBO(shortName, shortName, globalOfficeNum, get((short) parentOfficeId), level, searchId, status, 1);
    session.saveOrUpdate(officeBO);
    return officeBO;
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO)

Example 18 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO in project head by mifos.

the class LegacyAccountDaoIntegrationTest method testGetListOfAccountIdsHavingLoanSchedulesWithinAHoliday.

@Test
public void testGetListOfAccountIdsHavingLoanSchedulesWithinAHoliday() throws Exception {
    Set<HolidayBO> holidays;
    DateTime fromDate = new DateMidnight().toDateTime().plusDays(1);
    DateTime thruDate = new DateMidnight().toDateTime().plusDays(30);
    GenericDao genericDao = new GenericDaoHibernate();
    OfficeDao officeDao = new OfficeDaoHibernate(genericDao);
    HolidayDao holidayDao = new HolidayDaoHibernate(genericDao);
    OfficeBO sampleBranch = officeDao.findOfficeById(this.getBranchOffice().getOfficeId());
    holidays = new HashSet<HolidayBO>();
    holiday = new HolidayBuilder().withName("Welcome Holiday").from(fromDate).to(thruDate).build();
    holidayDao.save(holiday);
    holidays.add((HolidayBO) holiday);
    sampleBranch.setHolidays(holidays);
    new OfficePersistence().createOrUpdate(sampleBranch);
    StaticHibernateUtil.flushSession();
    List<Object[]> AccountIds = legacyAccountDao.getListOfAccountIdsHavingLoanSchedulesWithinAHoliday(holiday);
    Assert.assertNotNull(AccountIds);
    assertThat(AccountIds.size(), is(2));
}
Also used : GenericDaoHibernate(org.mifos.accounts.savings.persistence.GenericDaoHibernate) GenericDao(org.mifos.accounts.savings.persistence.GenericDao) DateTime(org.joda.time.DateTime) HolidayDao(org.mifos.application.holiday.persistence.HolidayDao) HolidayDaoHibernate(org.mifos.application.holiday.persistence.HolidayDaoHibernate) DateMidnight(org.joda.time.DateMidnight) OfficeBO(org.mifos.customers.office.business.OfficeBO) OfficeDao(org.mifos.customers.office.persistence.OfficeDao) HolidayBO(org.mifos.application.holiday.business.HolidayBO) OfficeDaoHibernate(org.mifos.customers.office.persistence.OfficeDaoHibernate) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Test(org.junit.Test)

Example 19 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO in project head by mifos.

the class LegacyAccountDaoIntegrationTest method testGetListOfAccountIdsHavingCustomerSchedulesWithinAHoliday.

@Test
public void testGetListOfAccountIdsHavingCustomerSchedulesWithinAHoliday() throws Exception {
    Set<HolidayBO> holidays;
    DateTime fromDate = new DateMidnight().toDateTime().plusDays(1);
    DateTime thruDate = new DateMidnight().toDateTime().plusDays(30);
    GenericDao genericDao = new GenericDaoHibernate();
    OfficeDao officeDao = new OfficeDaoHibernate(genericDao);
    HolidayDao holidayDao = new HolidayDaoHibernate(genericDao);
    OfficeBO sampleBranch = officeDao.findOfficeById(this.getBranchOffice().getOfficeId());
    holidays = new HashSet<HolidayBO>();
    holiday = new HolidayBuilder().withName("Welcome Holiday").from(fromDate).to(thruDate).build();
    holidayDao.save(holiday);
    holidays.add((HolidayBO) holiday);
    sampleBranch.setHolidays(holidays);
    new OfficePersistence().createOrUpdate(sampleBranch);
    StaticHibernateUtil.flushSession();
    List<Object[]> AccountIds = legacyAccountDao.getListOfAccountIdsHavingCustomerSchedulesWithinAHoliday(holiday);
    Assert.assertNotNull(AccountIds);
    assertThat(AccountIds.size(), is(3));
}
Also used : GenericDaoHibernate(org.mifos.accounts.savings.persistence.GenericDaoHibernate) GenericDao(org.mifos.accounts.savings.persistence.GenericDao) DateTime(org.joda.time.DateTime) HolidayDao(org.mifos.application.holiday.persistence.HolidayDao) HolidayDaoHibernate(org.mifos.application.holiday.persistence.HolidayDaoHibernate) DateMidnight(org.joda.time.DateMidnight) OfficeBO(org.mifos.customers.office.business.OfficeBO) OfficeDao(org.mifos.customers.office.persistence.OfficeDao) HolidayBO(org.mifos.application.holiday.business.HolidayBO) OfficeDaoHibernate(org.mifos.customers.office.persistence.OfficeDaoHibernate) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Test(org.junit.Test)

Example 20 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO in project head by mifos.

the class GroupServiceFacadeWebTierIntegrationTest method shouldCreateGroupWithExpectedSearchId.

@Test
public void shouldCreateGroupWithExpectedSearchId() {
    // setup
    OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
    createOfficeHierarchyUnderHeadOffice(headOffice);
    boolean centerHierarchyExistsOriginal = ClientRules.getCenterHierarchyExists();
    ClientRules.setCenterHierarchyExists(false);
    Short officeId = branch1.getOfficeId();
    String displayName = "testGroup";
    CustomerDetailsDto newlyCreatedGroupDetails = createGroup(displayName, officeId);
    // verification
    ClientRules.setCenterHierarchyExists(centerHierarchyExistsOriginal);
    GroupBO group = customerDao.findGroupBySystemId(newlyCreatedGroupDetails.getGlobalCustNum());
    Assert.assertThat(group.getSearchId(), is("1." + group.getCustomerId()));
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) GroupBO(org.mifos.customers.group.business.GroupBO) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) Test(org.junit.Test)

Aggregations

OfficeBO (org.mifos.customers.office.business.OfficeBO)115 Test (org.junit.Test)62 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)45 DateTime (org.joda.time.DateTime)33 ArrayList (java.util.ArrayList)31 MeetingBO (org.mifos.application.meeting.business.MeetingBO)28 UserContext (org.mifos.security.util.UserContext)25 OfficeBuilder (org.mifos.domain.builders.OfficeBuilder)23 CenterBO (org.mifos.customers.center.business.CenterBO)21 CenterBuilder (org.mifos.domain.builders.CenterBuilder)21 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)19 MifosUser (org.mifos.security.MifosUser)18 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)17 Address (org.mifos.framework.business.util.Address)17 GroupBO (org.mifos.customers.group.business.GroupBO)16 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)16 MifosRuntimeException (org.mifos.core.MifosRuntimeException)14 ClientBO (org.mifos.customers.client.business.ClientBO)14 GroupBuilder (org.mifos.domain.builders.GroupBuilder)14 AddressDto (org.mifos.dto.domain.AddressDto)13