use of org.mifos.security.MifosUser in project head by mifos.
the class SavingsServiceFacadeWebTier method postInterestForLastPostingPeriod.
/**
* This method is responsible for posting interest for the last posting period only.
*
* It assumes that interest calculation and interest posting frequencies cannot change on savings product of savings
* account. It assumes that the interest posting date is correct and valid with respect to the interest posting
* frequency of the product/account.
*/
@Override
public void postInterestForLastPostingPeriod(LocalDate dateBatchJobIsScheduled) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
PersonnelBO createdBy = this.personnelDao.findPersonnelById(userContext.getId());
List<Integer> accountIds = this.savingsDao.retrieveAllActiveAndInActiveSavingsAccountsPendingInterestPostingOn(dateBatchJobIsScheduled);
for (Integer savingsId : accountIds) {
postInterestForAccount(savingsId, userContext, createdBy, false);
}
}
use of org.mifos.security.MifosUser in project head by mifos.
the class SavingsServiceFacadeWebTier method updateSavingsAccountStatus.
@Override
public void updateSavingsAccountStatus(AccountUpdateStatus updateStatus) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
SavingsBO savingsAccount = this.savingsDao.findById(updateStatus.getSavingsId());
savingsAccount.updateDetails(userContext);
try {
this.transactionHelper.startTransaction();
this.transactionHelper.beginAuditLoggingFor(savingsAccount);
AccountState newStatus = AccountState.fromShort(updateStatus.getNewStatusId());
// FIXME - keithw - refactor savings specific logic out of changeStatus and create savings statue machine
// wrapper.
savingsAccount.changeStatus(newStatus, updateStatus.getFlagId(), updateStatus.getComment(), 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.security.MifosUser in project head by mifos.
the class SavingsServiceFacadeWebTier method retrieveDepositDueDetails.
@Override
public SavingsAccountDepositDueDto retrieveDepositDueDetails(String globalAccountNum) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
SavingsBO savingsAccount = this.savingsDao.findBySystemId(globalAccountNum);
try {
personnelDao.checkAccessPermission(userContext, savingsAccount.getOfficeId(), savingsAccount.getCustomer().getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException(e.getMessage(), e);
}
List<DueOnDateDto> previousDueDates = new ArrayList<DueOnDateDto>();
SavingsScheduleEntity nextInstallment = (SavingsScheduleEntity) savingsAccount.getDetailsOfNextInstallment();
Money totalDepositDue = Money.zero(savingsAccount.getCurrency());
LocalDate nextDueDate = new LocalDate();
if (nextInstallment != null) {
nextDueDate = new LocalDate(nextInstallment.getActionDate());
totalDepositDue = nextInstallment.getTotalDepositDue();
}
List<AccountActionDateEntity> scheduledDeposits = savingsAccount.getAccountActionDatesSortedByInstallmentId();
for (AccountActionDateEntity scheduledDeposit : scheduledDeposits) {
if (!scheduledDeposit.isPaid() && scheduledDeposit.isBefore(nextDueDate)) {
SavingsScheduleEntity savingsScheduledDeposit = (SavingsScheduleEntity) scheduledDeposit;
previousDueDates.add(new DueOnDateDto(scheduledDeposit.getActionDate(), MoneyUtils.currencyRound(savingsScheduledDeposit.getTotalDepositDue()).toString()));
}
}
DueOnDateDto nextDueDetail = new DueOnDateDto(new java.sql.Date(nextDueDate.toDateMidnight().toDate().getTime()), MoneyUtils.currencyRound(totalDepositDue).toString());
AccountStateEntity accountStateEntity = savingsAccount.getAccountState();
return new SavingsAccountDepositDueDto(nextDueDetail, previousDueDates, accountStateEntity.getId(), accountStateEntity.getName());
}
use of org.mifos.security.MifosUser 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.security.MifosUser in project head by mifos.
the class SavingsServiceFacadeWebTier method retrieveCustomerThatQualifyForSavings.
@Override
public List<CustomerSearchResultDto> retrieveCustomerThatQualifyForSavings(CustomerSearchDto customerSearchDto) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
List<CustomerSearchResultDto> pagedDetails = new ArrayList<CustomerSearchResultDto>();
QueryResult customerForSavings = new CustomerPersistence().searchCustForSavings(customerSearchDto.getSearchTerm(), userContext.getId());
int position = this.resultsetOffset(customerSearchDto.getPage(), customerSearchDto.getPageSize());
List<AccountSearchResultsDto> pagedResults = customerForSavings.get(position, customerSearchDto.getPageSize());
int i = 1;
for (AccountSearchResultsDto customerBO : pagedResults) {
CustomerSearchResultDto customer = new CustomerSearchResultDto();
customer.setCustomerId(customerBO.getClientId());
customer.setBranchName(customerBO.getOfficeName());
customer.setGlobalId(customerBO.getGlobelNo());
customer.setSearchIndex(i);
customer.setCenterName(StringUtils.defaultIfEmpty(customerBO.getCenterName(), "--"));
customer.setGroupName(StringUtils.defaultIfEmpty(customerBO.getGroupName(), "--"));
customer.setClientName(customerBO.getClientName());
pagedDetails.add(customer);
i++;
}
return pagedDetails;
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
} catch (HibernateSearchException e) {
throw new MifosRuntimeException(e);
}
}
Aggregations