use of org.mifos.dto.domain.AccountUpdateStatus in project head by mifos.
the class AccountStatusAction method update.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse httpservletresponse) throws Exception {
AccountStatusActionForm accountStatusActionForm = (AccountStatusActionForm) form;
List<AccountUpdateStatus> accountsForUpdate = new ArrayList<AccountUpdateStatus>();
List<AccountUpdateStatus> individualAccountsForUpdate = new ArrayList<AccountUpdateStatus>();
for (String accountId : accountStatusActionForm.getAccountRecords()) {
if (StringUtils.isNotBlank(accountId)) {
Long accountIdValue = Long.parseLong(accountId);
//GLIM
List<LoanBO> individualLoans = this.loanDao.findIndividualLoans(Integer.valueOf(accountId));
for (LoanBO indivdual : individualLoans) {
Short newStatusId = getShortValue(accountStatusActionForm.getNewStatus());
individualAccountsForUpdate.add(new AccountUpdateStatus(indivdual.getAccountId().longValue(), newStatusId, null, accountStatusActionForm.getComments()));
}
this.loanAccountServiceFacade.updateSeveralLoanAccountStatuses(individualAccountsForUpdate, null);
Short newStatusId = getShortValue(accountStatusActionForm.getNewStatus());
Short flagId = null;
String comment = accountStatusActionForm.getComments();
accountsForUpdate.add(new AccountUpdateStatus(accountIdValue, newStatusId, flagId, comment));
}
}
List<String> accountNumbers = this.loanAccountServiceFacade.updateSeveralLoanAccountStatuses(accountsForUpdate, null);
request.setAttribute(LoanConstants.ACCOUNTS_LIST, accountNumbers);
return mapping.findForward(ActionForwards.changeAccountStatusConfirmation_success.toString());
}
use of org.mifos.dto.domain.AccountUpdateStatus in project head by mifos.
the class LoanAccountServiceFacadeWebTier method updateSeveralLoanAccountStatuses.
@Override
public List<String> updateSeveralLoanAccountStatuses(List<AccountUpdateStatus> accountsForUpdate, Date transactionDate) {
List<String> updatedAccountNumbers = new ArrayList<String>();
for (AccountUpdateStatus accountUpdate : accountsForUpdate) {
String accountNumber = updateLoanAccountStatus(accountUpdate, transactionDate);
updatedAccountNumbers.add(accountNumber);
}
return updatedAccountNumbers;
}
use of org.mifos.dto.domain.AccountUpdateStatus in project head by mifos.
the class EditStatusAction method update.
@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
UserContext userContext = getUserContext(request);
EditStatusActionForm editStatusActionForm = (EditStatusActionForm) form;
Integer accountId = Integer.valueOf(editStatusActionForm.getAccountId());
AccountBO accountBO = new AccountBusinessService().getAccount(accountId);
Short flagId = null;
Short newStatusId = null;
String updateComment = editStatusActionForm.getNotes();
if (StringUtils.isNotBlank(editStatusActionForm.getFlagId())) {
flagId = getShortValue(editStatusActionForm.getFlagId());
}
if (StringUtils.isNotBlank(editStatusActionForm.getNewStatusId())) {
newStatusId = getShortValue(editStatusActionForm.getNewStatusId());
}
Date trxnDate = editStatusActionForm.getTransactionDateValue(userContext.getPreferredLocale());
if (editStatusActionForm.getNewStatusId().equals(AccountState.LOAN_APPROVED) && !AccountingRules.isBackDatedApprovalAllowed()) {
trxnDate = new DateTimeService().getCurrentJavaDateTime();
}
checkPermission(accountBO, getUserContext(request), newStatusId, flagId);
if (accountBO.isLoanAccount() || accountBO.isGroupLoanAccount()) {
initializeLoanQuestionnaire(accountBO.getGlobalAccountNum(), newStatusId != null ? newStatusId.toString() : null);
loanQuestionnaire.saveResponses(request, editStatusActionForm, accountId);
//GLIM
List<LoanBO> individualLoans = this.loanDao.findIndividualLoans(accountId);
List<AccountUpdateStatus> updateStatus = new ArrayList<AccountUpdateStatus>(individualLoans.size() + 1);
updateStatus.add(new AccountUpdateStatus(accountId.longValue(), newStatusId, flagId, updateComment));
for (LoanBO individual : individualLoans) {
updateStatus.add(new AccountUpdateStatus(individual.getAccountId().longValue(), newStatusId, flagId, updateComment));
}
try {
if (individualLoans.size() == 0) {
this.loanAccountServiceFacade.updateSingleLoanAccountStatus(updateStatus.get(0), trxnDate);
} else {
this.loanAccountServiceFacade.updateSeveralLoanAccountStatuses(updateStatus, trxnDate);
}
} catch (AccessDeniedException e) {
throw new ServiceException(SecurityConstants.KEY_ACTIVITY_APPROVE_LOAN_NOT_ALLOWED);
}
return mapping.findForward(ActionForwards.loan_detail_page.toString());
}
if (accountBO.isSavingsAccount()) {
AccountUpdateStatus updateStatus = new AccountUpdateStatus(accountId.longValue(), newStatusId, flagId, updateComment);
this.savingsServiceFacade.updateSavingsAccountStatus(updateStatus);
return mapping.findForward(ActionForwards.savings_details_page.toString());
}
// nothing but loan of savings account should be detected. customer account status change goes through separate action.
return null;
}
use of org.mifos.dto.domain.AccountUpdateStatus in project head by mifos.
the class MaxLoanAmountForApprovePermission method isAllowed.
@Override
public boolean isAllowed(Authentication authentication, Object targetDomainObject) throws ServiceException {
if (targetDomainObject instanceof AccountUpdateStatus) {
AccountUpdateStatus accountUpdateStatus = (AccountUpdateStatus) targetDomainObject;
MifosUser user = (MifosUser) authentication.getPrincipal();
return checkPermissionByAccountUpdateStatus(user, accountUpdateStatus);
} else if (targetDomainObject instanceof List) {
boolean isAllowed = true;
List<AccountUpdateStatus> accountsUpdateStatus = (List<AccountUpdateStatus>) targetDomainObject;
MifosUser user = (MifosUser) authentication.getPrincipal();
for (AccountUpdateStatus accountUpdateStatus : accountsUpdateStatus) {
isAllowed = checkPermissionByAccountUpdateStatus(user, accountUpdateStatus);
if (!isAllowed) {
return false;
}
}
return isAllowed;
}
return true;
}
Aggregations