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);
}
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;
}
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));
}
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));
}
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()));
}
Aggregations