use of org.mifos.customers.business.CustomerMeetingEntity in project head by mifos.
the class AccountBO method getNextMeetingDate.
public Date getNextMeetingDate() {
AccountActionDateEntity nextAccountAction = getDetailsOfNextInstallment();
if (nextAccountAction != null) {
return nextAccountAction.getActionDate();
}
// calculate the next date based on the customer's meeting object
CustomerMeetingEntity customerMeeting = customer.getCustomerMeeting();
if (customerMeeting != null) {
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(customerMeeting.getMeeting());
DateTime nextMeetingDate = scheduledEvent.nearestMatchingDateBeginningAt(new LocalDate().toDateTimeAtStartOfDay());
return new java.sql.Date(nextMeetingDate.toDate().getTime());
}
return new java.sql.Date(DateUtils.getCurrentDateWithoutTimeStamp().getTime());
}
use of org.mifos.customers.business.CustomerMeetingEntity in project head by mifos.
the class CustomerServiceImpl method updateCustomerMeetingSchedule.
@Override
public void updateCustomerMeetingSchedule(MeetingBO updatedMeeting, CustomerBO customer) {
try {
customer.validateIsTopOfHierarchy();
customerDao.checkPermissionForEditMeetingSchedule(updatedMeeting.getUserContext(), customer);
CalendarEvent calendarEvents = holidayDao.findCalendarEventsForThisYearAndNext(customer.getOfficeId());
this.hibernateTransactionHelper.startTransaction();
boolean scheduleUpdateRequired = false;
CustomerMeetingEntity meetingEntity = customer.getCustomerMeeting();
if (meetingEntity != null) {
MeetingBO meeting = customer.getCustomerMeetingValue();
scheduleUpdateRequired = updateMeeting(meeting, updatedMeeting);
} else {
CustomerMeetingEntity newMeetingEntity = customer.createCustomerMeeting(updatedMeeting);
customer.setCustomerMeeting(newMeetingEntity);
}
customerDao.save(customer);
if (scheduleUpdateRequired) {
handleChangeInMeetingSchedule(customer, calendarEvents.getWorkingDays(), calendarEvents.getHolidays());
}
this.hibernateTransactionHelper.commitTransaction();
} catch (CustomerException e) {
this.hibernateTransactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
} catch (AccountException e) {
this.hibernateTransactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
} finally {
this.hibernateTransactionHelper.closeSession();
}
}
use of org.mifos.customers.business.CustomerMeetingEntity in project head by mifos.
the class ClientBO method transferTo.
public boolean transferTo(GroupBO receivingGroup) {
boolean regenerateClientSchedules = false;
this.setParentCustomer(receivingGroup);
this.setPersonnel(receivingGroup.getPersonnel());
CustomerHierarchyEntity currentHierarchy = this.getActiveCustomerHierarchy();
if (null != currentHierarchy) {
currentHierarchy.makeInactive(userContext.getId());
}
addCustomerHierarchy(new CustomerHierarchyEntity(this, receivingGroup));
MeetingBO parentGroupMeeting = receivingGroup.getCustomerMeetingValue();
MeetingBO clientMeeting = this.getCustomerMeetingValue();
if (parentGroupMeeting != null) {
if (clientMeeting != null) {
regenerateClientSchedules = receivingGroup.hasMeetingDifferentTo(clientMeeting);
CustomerMeetingEntity clientMeetingEntity = this.getCustomerMeeting();
clientMeetingEntity.setMeeting(receivingGroup.getCustomerMeetingValue());
} else {
CustomerMeetingEntity customerMeeting = this.createCustomerMeeting(parentGroupMeeting);
this.setCustomerMeeting(customerMeeting);
}
} else if (clientMeeting != null) {
this.setCustomerMeeting(null);
}
if (!isSameBranch(receivingGroup.getOffice())) {
this.makeCustomerMovementEntries(receivingGroup.getOffice());
regenerateClientSchedules = true;
}
this.addGroupMembership();
this.generateSearchId();
return regenerateClientSchedules;
}
use of org.mifos.customers.business.CustomerMeetingEntity in project head by mifos.
the class ClientBO method handleGroupTransfer.
public void handleGroupTransfer() {
if (!isSameBranch(getParentCustomer().getOffice())) {
makeCustomerMovementEntries(getParentCustomer().getOffice());
if (isActive()) {
setCustomerStatus(new CustomerStatusEntity(CustomerStatus.CLIENT_HOLD));
}
this.setPersonnel(null);
}
setSearchId(getParentCustomer().getSearchId() + getSearchId().substring(getSearchId().lastIndexOf(".")));
if (getParentCustomer() != null) {
setPersonnel(getParentCustomer().getPersonnel());
CustomerMeetingEntity clientMeetingEntity = this.getCustomerMeeting();
clientMeetingEntity.setMeeting(this.getParentCustomer().getCustomerMeetingValue());
}
}
use of org.mifos.customers.business.CustomerMeetingEntity in project head by mifos.
the class GroupBO method transferTo.
public boolean transferTo(CenterBO receivingCenter) {
boolean regenerateGroupSchedules = false;
this.setParentCustomer(receivingCenter);
this.setPersonnel(receivingCenter.getPersonnel());
CustomerHierarchyEntity currentHierarchy = this.getActiveCustomerHierarchy();
if (null != currentHierarchy) {
currentHierarchy.makeInactive(this.getUserContext().getId());
}
this.addCustomerHierarchy(new CustomerHierarchyEntity(this, receivingCenter));
MeetingBO centerMeeting = receivingCenter.getCustomerMeetingValue();
MeetingBO groupMeeting = this.getCustomerMeetingValue();
if (centerMeeting != null) {
if (groupMeeting != null) {
regenerateGroupSchedules = receivingCenter.hasMeetingDifferentTo(groupMeeting);
CustomerMeetingEntity groupMeetingEntity = this.getCustomerMeeting();
groupMeetingEntity.setMeeting(receivingCenter.getCustomerMeetingValue());
} else {
CustomerMeetingEntity customerMeeting = this.createCustomerMeeting(centerMeeting);
this.setCustomerMeeting(customerMeeting);
}
} else if (groupMeeting != null) {
this.setCustomerMeeting(null);
}
OfficeBO centerOffice = receivingCenter.getOffice();
if (this.isDifferentBranch(centerOffice)) {
this.makeCustomerMovementEntries(centerOffice);
if (this.isActive()) {
this.setCustomerStatus(new CustomerStatusEntity(CustomerStatus.GROUP_HOLD));
}
regenerateGroupSchedules = true;
}
this.generateSearchId();
return regenerateGroupSchedules;
}
Aggregations