use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class SavingsServiceFacadeWebTier method waiveNextDepositAmountDue.
@Override
public void waiveNextDepositAmountDue(Long savingsId) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
SavingsBO savingsAccount = this.savingsDao.findById(savingsId);
savingsAccount.updateDetails(userContext);
PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
try {
this.transactionHelper.startTransaction();
savingsAccount.waiveNextDepositAmountDue(loggedInUser);
this.savingsDao.save(savingsAccount);
this.transactionHelper.commitTransaction();
} catch (BusinessRuleException e) {
this.transactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getMessageKey(), e);
} catch (Exception e) {
this.transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
this.transactionHelper.closeSession();
}
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class SavingsServiceFacadeWebTier method recalculateInterestPostings.
private void recalculateInterestPostings(Integer accountId, LocalDate affectingPaymentDate) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
PersonnelBO createdBy = this.personnelDao.findPersonnelById(userContext.getId());
SavingsBO account = this.savingsDao.findById(accountId);
Date paymentDate = affectingPaymentDate.toDateMidnight().toDate();
int removedPostings = account.countInterestPostingsForRecalculation(paymentDate);
if (removedPostings > 0) {
this.savingsDao.prepareForInterestRecalculation(account, paymentDate);
this.transactionHelper.flushSession();
for (int i = 0; i < removedPostings; i++) {
postInterestForAccount(accountId, userContext, createdBy, true);
}
}
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class SavingsServiceFacadeWebTier method createSavingsAccount.
@Override
public Long createSavingsAccount(SavingsAccountCreationDto savingsAccountCreation, List<QuestionGroupDetail> questionGroups) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
LocalDate createdDate = new LocalDate();
Integer createdById = user.getUserId();
PersonnelBO createdBy = this.personnelDao.findPersonnelById(createdById.shortValue());
CustomerBO customer = this.customerDao.findCustomerById(savingsAccountCreation.getCustomerId());
SavingsOfferingBO savingsProduct = this.savingsProductDao.findById(savingsAccountCreation.getProductId());
Money recommendedOrMandatory = new Money(savingsProduct.getCurrency(), savingsAccountCreation.getRecommendedOrMandatoryAmount());
AccountState savingsAccountState = AccountState.fromShort(savingsAccountCreation.getAccountState());
CalendarEvent calendarEvents = this.holidayDao.findCalendarEventsForThisYearAndNext(customer.getOfficeId());
SavingsAccountTypeInspector savingsAccountWrapper = new SavingsAccountTypeInspector(customer, savingsProduct.getRecommendedAmntUnit());
try {
SavingsBO savingsAccount = null;
if (savingsAccountWrapper.isIndividualSavingsAccount()) {
savingsAccount = SavingsBO.createIndividalSavingsAccount(customer, savingsProduct, recommendedOrMandatory, savingsAccountState, createdDate, createdById, calendarEvents, createdBy);
} else if (savingsAccountWrapper.isJointSavingsAccountWithClientTracking()) {
List<CustomerBO> activeAndOnHoldClients = new CustomerPersistence().getActiveAndOnHoldChildren(customer.getSearchId(), customer.getOfficeId(), CustomerLevel.CLIENT);
savingsAccount = SavingsBO.createJointSavingsAccount(customer, savingsProduct, recommendedOrMandatory, savingsAccountState, createdDate, createdById, calendarEvents, createdBy, activeAndOnHoldClients);
}
try {
personnelDao.checkAccessPermission(userContext, savingsAccount.getOfficeId(), savingsAccount.getCustomer().getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
this.transactionHelper.startTransaction();
this.savingsDao.save(savingsAccount);
this.transactionHelper.flushSession();
savingsAccount.generateSystemId(createdBy.getOffice().getGlobalOfficeNum());
this.savingsDao.save(savingsAccount);
this.transactionHelper.flushSession();
// save question groups
if (!questionGroups.isEmpty()) {
Integer eventSourceId = questionnaireServiceFacade.getEventSourceId("Create", "Savings");
QuestionGroupDetails questionGroupDetails = new QuestionGroupDetails(Integer.valueOf(user.getUserId()).shortValue(), savingsAccount.getAccountId(), eventSourceId, questionGroups);
questionnaireServiceFacade.saveResponses(questionGroupDetails);
}
this.transactionHelper.commitTransaction();
return savingsAccount.getAccountId().longValue();
} catch (BusinessRuleException e) {
this.transactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getMessageKey(), e);
} catch (Exception e) {
this.transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
this.transactionHelper.closeSession();
}
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class PersonAction method unLockUserAccount.
@SuppressWarnings("unused")
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward unLockUserAccount(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
PersonnelBO personnel = (PersonnelBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
UserContext userContext = getUserContext(request);
this.personnelServiceFacade.unLockUserAccount(personnel.getGlobalPersonnelNum());
return mapping.findForward(ActionForwards.unLockUserAccount_success.toString());
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class PersonAction method search.
@Override
@TransactionDemarcate(saveToken = true)
public ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
ActionForward actionForward = null;
UserContext userContext = getUserContext(request);
PersonnelBO personnel = this.personnelDao.findPersonnelById(userContext.getId());
String searchString = ((PersonActionForm) form).getSearchString();
addSeachValues(searchString, personnel.getOffice().getOfficeId().toString(), personnel.getOffice().getOfficeName(), request);
searchString = org.mifos.framework.util.helpers.SearchUtils.normalizeSearchString(searchString);
actionForward = super.search(mapping, form, request, response);
SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, legacyPersonnelDao.search(searchString, userContext.getId()), request);
return actionForward;
}
Aggregations