use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class CustomerServiceImpl method updateClientMfiInfo.
@Override
public final void updateClientMfiInfo(UserContext userContext, ClientMfiInfoUpdate clientMfiInfoUpdate) throws CustomerException {
ClientBO client = (ClientBO) this.customerDao.findCustomerById(clientMfiInfoUpdate.getClientId());
client.validateVersion(clientMfiInfoUpdate.getOrginalClientVersionNumber());
client.updateDetails(userContext);
try {
hibernateTransactionHelper.startTransaction();
hibernateTransactionHelper.beginAuditLoggingFor(client);
PersonnelBO personnel = this.personnelDao.findPersonnelById(clientMfiInfoUpdate.getPersonnelId());
client.updateMfiInfo(personnel, clientMfiInfoUpdate);
customerDao.save(client);
hibernateTransactionHelper.commitTransaction();
} catch (CustomerException e) {
hibernateTransactionHelper.rollbackTransaction();
throw e;
} catch (Exception e) {
hibernateTransactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
hibernateTransactionHelper.closeSession();
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class CustomerServiceImpl method transferGroupTo.
@Override
public final String transferGroupTo(GroupBO group, OfficeBO transferToOffice) throws CustomerException {
group.validateNewOffice(transferToOffice);
group.validateNoActiveAccountsExist();
customerDao.validateGroupNameIsNotTakenForOffice(group.getDisplayName(), transferToOffice.getOfficeId());
try {
hibernateTransactionHelper.startTransaction();
hibernateTransactionHelper.beginAuditLoggingFor(group);
group.makeCustomerMovementEntries(transferToOffice);
group.setPersonnel(null);
if (group.isActive()) {
group.setCustomerStatus(new CustomerStatusEntity(CustomerStatus.GROUP_HOLD));
}
CustomerBO oldParentOfGroup = group.getParentCustomer();
if (oldParentOfGroup != null) {
oldParentOfGroup.incrementChildCount();
customerDao.save(oldParentOfGroup);
}
this.hibernateTransactionHelper.flushSession();
group.generateSearchId();
group.setUpdateDetails();
customerDao.save(group);
Set<CustomerBO> clients = group.getChildren();
if (clients != null) {
for (CustomerBO client : clients) {
client.setUserContext(group.getUserContext());
((ClientBO) client).handleGroupTransfer();
client.setUpdateDetails();
customerDao.save(client);
}
}
hibernateTransactionHelper.commitTransaction();
return group.getGlobalCustNum();
} catch (Exception e) {
hibernateTransactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
hibernateTransactionHelper.closeSession();
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class CustomerServiceImpl method updateClientFamilyInfo.
@Override
public void updateClientFamilyInfo(UserContext userContext, ClientFamilyInfoUpdate clientFamilyInfoUpdate) throws CustomerException {
ClientBO client = (ClientBO) this.customerDao.findCustomerById(clientFamilyInfoUpdate.getCustomerId());
client.validateVersion(clientFamilyInfoUpdate.getOldVersionNum());
client.updateDetails(userContext);
try {
hibernateTransactionHelper.startTransaction();
hibernateTransactionHelper.beginAuditLoggingFor(client);
client.updateFamilyInfo(clientFamilyInfoUpdate);
customerDao.save(client);
hibernateTransactionHelper.commitTransaction();
} catch (Exception e) {
hibernateTransactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
hibernateTransactionHelper.closeSession();
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class CenterBO method validateMeetingAndFees.
public void validateMeetingAndFees(List<AccountFeesEntity> accountFees) throws CustomerException {
if (this.getCustomerMeeting() == null || this.getCustomerMeetingValue() == null) {
if (accountFees.size() > 0) {
throw new CustomerException(CustomerConstants.MEETING_REQUIRED_EXCEPTION);
}
throw new CustomerException(CustomerConstants.ERRORS_SPECIFY_MEETING);
}
for (AccountFeesEntity accountFee : accountFees) {
if (accountFee.getFees().isPeriodic()) {
MeetingBO feeMeeting = accountFee.getFees().getFeeFrequency().getFeeMeetingFrequency();
if (!feeMeeting.hasSameRecurrenceAs(this.getCustomerMeetingValue())) {
throw new CustomerException(CustomerConstants.ERRORS_FEE_FREQUENCY_MISMATCH);
}
FeeBO fee = accountFee.getFees();
if (AccountFeesEntity.isPeriodicFeeDuplicated(accountFees, fee)) {
throw new CustomerException(CustomerConstants.ERRORS_DUPLICATE_PERIODIC_FEE);
}
}
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class GroupBO method update.
/**
* @deprecated - use DAOs to do CRUD operations
*/
@Deprecated
@Override
public void update() throws CustomerException {
try {
setUpdateDetails();
getCustomerPersistence().createOrUpdate(this);
} catch (PersistenceException e) {
throw new CustomerException(CustomerConstants.UPDATE_FAILED_EXCEPTION, e);
}
}
Aggregations