use of org.mifos.service.BusinessRuleException in project head by mifos.
the class GroupLoanAccountServiceFacadeWebTier method createNewMeetingForRepaymentDay.
private MeetingBO createNewMeetingForRepaymentDay(LocalDate disbursementDate, RecurringSchedule recurringSchedule, CustomerBO customer) {
MeetingBO newMeetingForRepaymentDay = null;
final int minDaysInterval = configurationPersistence.getConfigurationValueInteger(MIN_DAYS_BETWEEN_DISBURSAL_AND_FIRST_REPAYMENT_DAY);
final Date repaymentStartDate = disbursementDate.plusDays(minDaysInterval).toDateMidnight().toDateTime().toDate();
try {
if (recurringSchedule.isWeekly()) {
WeekDay weekDay = WeekDay.getWeekDay(recurringSchedule.getDay().shortValue());
Short recurEvery = recurringSchedule.getEvery().shortValue();
newMeetingForRepaymentDay = new MeetingBO(weekDay, recurEvery, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace());
} else if (recurringSchedule.isMonthly()) {
if (recurringSchedule.isMonthlyOnDayOfMonth()) {
Short dayOfMonth = recurringSchedule.getDay().shortValue();
Short dayRecurMonth = recurringSchedule.getEvery().shortValue();
newMeetingForRepaymentDay = new MeetingBO(dayOfMonth, dayRecurMonth, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace());
} else {
Short weekOfMonth = recurringSchedule.getDay().shortValue();
Short monthRank = recurringSchedule.getWeek().shortValue();
Short everyMonth = recurringSchedule.getEvery().shortValue();
newMeetingForRepaymentDay = new MeetingBO(weekOfMonth, everyMonth, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace(), monthRank);
}
} else {
Short recurEvery = recurringSchedule.getEvery().shortValue();
newMeetingForRepaymentDay = new MeetingBO(recurEvery, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace());
}
return newMeetingForRepaymentDay;
} catch (NumberFormatException nfe) {
throw new MifosRuntimeException(nfe);
} catch (MeetingException me) {
throw new BusinessRuleException(me.getKey(), me);
}
}
use of org.mifos.service.BusinessRuleException in project head by mifos.
the class GroupServiceFacadeWebTier method transferGroupToBranch.
@Override
public CustomerDetailDto transferGroupToBranch(String globalCustNum, Short officeId, Integer previousGroupVersionNo) {
try {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
GroupBO group = this.customerDao.findGroupBySystemId(globalCustNum);
group.updateDetails(userContext);
checkVersionMismatch(previousGroupVersionNo, group.getVersionNo());
OfficeBO transferToOffice = this.officeDao.findOfficeById(officeId);
transferToOffice.setUserContext(userContext);
String groupGlobalCustNum = this.customerService.transferGroupTo(group, transferToOffice);
GroupBO transferedGroup = this.customerDao.findGroupBySystemId(groupGlobalCustNum);
return transferedGroup.toCustomerDetailDto();
} catch (ApplicationException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.service.BusinessRuleException in project head by mifos.
the class GroupServiceFacadeWebTier method retrieveCustomerHistoricalData.
@Override
public CustomerHistoricalDataDto retrieveCustomerHistoricalData(String globalCustNum) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
CustomerBO customer = this.customerDao.findCustomerBySystemId(globalCustNum);
boolean client = false;
boolean group = false;
if (customer.isClient()) {
client = true;
} else if (customer.isGroup()) {
group = true;
}
CustomerHistoricalDataEntity customerHistoricalDataEntity = customer.getHistoricalData();
if (customerHistoricalDataEntity == null) {
customerHistoricalDataEntity = new CustomerHistoricalDataEntity(customer);
}
try {
String currentDate = DateUtils.getCurrentDate(userContext.getPreferredLocale());
java.sql.Date mfiJoiningDate = null;
if (customerHistoricalDataEntity.getMfiJoiningDate() == null) {
mfiJoiningDate = DateUtils.getLocaleDate(userContext.getPreferredLocale(), currentDate);
} else {
mfiJoiningDate = new Date(customerHistoricalDataEntity.getMfiJoiningDate().getTime());
}
return new CustomerHistoricalDataDto(client, group, mfiJoiningDate);
} catch (InvalidDateException e) {
throw new BusinessRuleException(e.getMessage(), e);
}
}
use of org.mifos.service.BusinessRuleException in project head by mifos.
the class GroupServiceFacadeWebTier method updateCustomerHistoricalData.
@Override
public void updateCustomerHistoricalData(String globalCustNum, CustomerHistoricalDataUpdateRequest historicalData) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
CustomerBO customerBO = this.customerDao.findCustomerBySystemId(globalCustNum);
customerBO.updateDetails(userContext);
try {
CustomerHistoricalDataEntity customerHistoricalDataEntity = customerBO.getHistoricalData();
if (customerBO.getPersonnel() != null) {
checkPermissionForAddingHistoricalData(customerBO.getLevel(), userContext, customerBO.getOffice().getOfficeId(), customerBO.getPersonnel().getPersonnelId());
} else {
checkPermissionForAddingHistoricalData(customerBO.getLevel(), userContext, customerBO.getOffice().getOfficeId(), userContext.getId());
}
// Integer oldLoanCycleNo = 0;
if (customerHistoricalDataEntity == null) {
customerHistoricalDataEntity = new CustomerHistoricalDataEntity(customerBO);
customerHistoricalDataEntity.setCreatedBy(customerBO.getUserContext().getId());
customerHistoricalDataEntity.setCreatedDate(new DateTimeService().getCurrentJavaDateTime());
} else {
// oldLoanCycleNo =
// customerHistoricalDataEntity.getLoanCycleNumber();
customerHistoricalDataEntity.setUpdatedDate(new DateTimeService().getCurrentJavaDateTime());
customerHistoricalDataEntity.setUpdatedBy(customerBO.getUserContext().getId());
}
customerHistoricalDataEntity.setInterestPaid(StringUtils.isBlank(historicalData.getInterestPaid()) ? null : new Money(Money.getDefaultCurrency(), historicalData.getInterestPaid()));
customerHistoricalDataEntity.setLoanAmount(StringUtils.isBlank(historicalData.getLoanAmount()) ? null : new Money(Money.getDefaultCurrency(), historicalData.getLoanAmount()));
customerHistoricalDataEntity.setLoanCycleNumber(historicalData.getLoanCycleNumber());
customerHistoricalDataEntity.setMissedPaymentsCount(historicalData.getMissedPaymentsCount());
customerHistoricalDataEntity.setNotes(historicalData.getNotes());
customerHistoricalDataEntity.setProductName(historicalData.getProductName());
customerHistoricalDataEntity.setTotalAmountPaid(StringUtils.isBlank(historicalData.getTotalAmountPaid()) ? null : new Money(Money.getDefaultCurrency(), historicalData.getTotalAmountPaid()));
customerHistoricalDataEntity.setTotalPaymentsCount(historicalData.getTotalPaymentsCount());
customerHistoricalDataEntity.setMfiJoiningDate(historicalData.getMfiJoiningDate());
this.transactionHelper.startTransaction();
this.transactionHelper.beginAuditLoggingFor(customerBO);
customerBO.updateHistoricalData(customerHistoricalDataEntity);
this.customerDao.save(customerBO);
this.transactionHelper.commitTransaction();
} catch (ApplicationException e) {
this.transactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.service.BusinessRuleException in project head by mifos.
the class ClientServiceFacadeWebTier method updateClientPersonalInfo.
@Override
public void updateClientPersonalInfo(ClientPersonalInfoUpdate personalInfo, String clientStatus, short loanOfficerId) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
this.customerService.updateClientPersonalInfo(userContext, personalInfo);
} catch (CustomerException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
Aggregations