use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class CustomerServiceImpl method updateGroupStatus.
@Override
public final void updateGroupStatus(GroupBO group, CustomerStatus oldStatus, CustomerStatus newStatus, CustomerStatusFlag customerStatusFlag, CustomerNoteEntity customerNote) throws CustomerException {
validateChangeOfStatusForGroup(group, oldStatus, newStatus);
CustomerStatusFlagEntity customerStatusFlagEntity = populateCustomerStatusFlag(customerStatusFlag);
try {
hibernateTransactionHelper.startTransaction();
hibernateTransactionHelper.beginAuditLoggingFor(group);
if (group.isActiveForFirstTime(oldStatus.getValue(), newStatus.getValue())) {
group.setCustomerActivationDate(new DateTime().toDate());
group.updateCustomerHierarchy();
CalendarEvent applicableCalendarEvents = this.holidayDao.findCalendarEventsForThisYearAndNext(group.getOfficeId());
group.regenerateCustomerFeeSchedule(applicableCalendarEvents);
}
Set<CustomerBO> groupChildren = group.getChildren();
if (oldStatus.isGroupPending() && newStatus.isGroupCancelled() && groupChildren != null) {
for (CustomerBO child : groupChildren) {
ClientBO client = (ClientBO) child;
if (client.isPending()) {
client.setUserContext(group.getUserContext());
hibernateTransactionHelper.beginAuditLoggingFor(client);
client.updateCustomerStatus(CustomerStatus.CLIENT_PARTIAL);
customerDao.save(client);
}
}
}
group.updateCustomerStatus(newStatus, customerNote, customerStatusFlagEntity);
customerDao.save(group);
hibernateTransactionHelper.commitTransaction();
} catch (Exception e) {
this.hibernateTransactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
this.hibernateTransactionHelper.closeSession();
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class ClientBO method handleAttendance.
// when this method is called from Bulk Entry preview persist will be false
public void handleAttendance(final Date meetingDate, final Short attendance, final boolean persist) throws CustomerException {
ClientAttendanceBO clientAttendance = getClientAttendanceForMeeting(meetingDate);
if (clientAttendance == null) {
clientAttendance = new ClientAttendanceBO();
clientAttendance.setMeetingDate(meetingDate);
addClientAttendance(clientAttendance);
}
clientAttendance.setAttendance(attendance);
if (persist) {
try {
getCustomerPersistence().createOrUpdate(this);
} catch (PersistenceException e) {
throw new CustomerException(e);
}
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class LegacyClientDao method saveClient.
public void saveClient(final ClientBO clientBO) throws CustomerException {
CustomerPersistence customerPersistence = new CustomerPersistence();
customerPersistence.saveCustomer(clientBO);
try {
if (clientBO.getParentCustomer() != null) {
customerPersistence.createOrUpdate(clientBO.getParentCustomer());
}
// seems fishy... why do savings accounts need updating here?
new SavingsPersistence().persistSavingAccounts(clientBO);
} catch (PersistenceException pe) {
throw new CustomerException(CustomerConstants.CREATE_FAILED_EXCEPTION, pe);
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class CustomerBO method update.
/**
* @deprecated - use {@link CustomerDao}.
*/
@Deprecated
public void update() throws CustomerException {
try {
setUpdateDetails();
getCustomerPersistence().createOrUpdate(this);
} catch (PersistenceException e) {
throw new CustomerException(CustomerConstants.UPDATE_FAILED_EXCEPTION, e);
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class CustomerDaoHibernate method validateGroupNameIsNotTakenForOffice.
@SuppressWarnings("unchecked")
@Override
public void validateGroupNameIsNotTakenForOffice(String displayName, Short officeId) throws CustomerException {
Map<String, Object> queryParameters = new HashMap<String, Object>();
queryParameters.put(CustomerConstants.DISPLAY_NAME, displayName);
queryParameters.put(CustomerConstants.OFFICE_ID, officeId);
List queryResult = this.genericDao.executeNamedQuery("Customer.getGroupCountByGroupNameAndOffice", queryParameters);
if (Integer.valueOf(queryResult.get(0).toString()) > 0) {
throw new CustomerException(CustomerConstants.ERRORS_DUPLICATE_CUSTOMER, new Object[] { displayName });
}
}
Aggregations