use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class LegacyAccountDao method search.
public QueryResult search(String queryString, Short officeId) throws PersistenceException {
AccountBO accountBO = findBySystemId(queryString);
if (accountBO == null) {
return null;
}
if (accountBO.getType() == AccountTypes.CUSTOMER_ACCOUNT || accountBO.getType() == AccountTypes.INDIVIDUAL_LOAN_ACCOUNT) {
return null;
}
QueryResult queryResult = QueryFactory.getQueryResult(CustomerSearchConstants.LOANACCOUNTIDSEARCH);
((QueryResultAccountIdSearch) queryResult).setSearchString(queryString);
String[] namedQuery = new String[2];
List<Param> paramList = new ArrayList<Param>();
QueryInputs queryInputs = new QueryInputs();
String[] aliasNames = { "customerId", "centerName", "centerGlobalCustNum", "customerType", "branchGlobalNum", "branchName", "loanOfficerName", "loanOffcerGlobalNum", "customerStatus", "groupName", "groupGlobalCustNum", "clientName", "clientGlobalCustNum", "loanGlobalAccountNumber" };
queryInputs.setPath("org.mifos.customers.business.CustomerSearchDto");
queryInputs.setAliasNames(aliasNames);
if (officeId != null) {
if (officeId.shortValue() == 0) {
namedQuery[0] = NamedQueryConstants.ACCOUNT_ID_SEARCH_NOOFFICEID_COUNT;
namedQuery[1] = NamedQueryConstants.ACCOUNT_ID_SEARCH_NOOFFICEID;
} else {
namedQuery[0] = NamedQueryConstants.ACCOUNT_ID_SEARCH_COUNT;
namedQuery[1] = NamedQueryConstants.ACCOUNT_ID_SEARCH;
paramList.add(typeNameValue("Short", "OFFICEID", officeId));
}
paramList.add(typeNameValue("String", "SEARCH_STRING", queryString));
}
queryInputs.setQueryStrings(namedQuery);
queryInputs.setParamList(paramList);
try {
queryResult.setQueryInputs(queryInputs);
} catch (HibernateSearchException e) {
throw new PersistenceException(e);
}
return queryResult;
}
use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class LoanAccountServiceFacadeWebTier method removeLoanPenalty.
@Override
public void removeLoanPenalty(Integer loanId, Short penaltyId) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
AccountBO account = new AccountBusinessService().getAccount(loanId);
if (account instanceof LoanBO) {
LoanBO loanAccount = (LoanBO) account;
List<LoanBO> individualLoans = this.loanDao.findIndividualLoans(account.getAccountId());
if (individualLoans != null && individualLoans.size() > 0) {
for (LoanBO individual : individualLoans) {
individual.updateDetails(userContext);
individual.removePenalty(penaltyId, userContext.getId());
this.customerDao.save(individual);
}
}
account.updateDetails(userContext);
if (account.getPersonnel() != null) {
new AccountBusinessService().checkPermissionForRemovePenalties(account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), account.getPersonnel().getPersonnelId());
} else {
new AccountBusinessService().checkPermissionForRemovePenalties(account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), userContext.getId());
}
this.transactionHelper.startTransaction();
loanAccount.removePenalty(penaltyId, userContext.getId());
this.loanDao.save(loanAccount);
this.transactionHelper.commitTransaction();
}
} catch (ServiceException e) {
this.transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} catch (AccountException e) {
this.transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
this.transactionHelper.closeSession();
}
}
use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class SaveCollectionSheetAssembler method customerAccountAssemblerFromDto.
public List<AccountBO> customerAccountAssemblerFromDto(final List<SaveCollectionSheetCustomerDto> saveCollectionSheetCustomers, final AccountPaymentEntity payment, final List<String> failedCustomerAccountPaymentNums) {
final List<AccountBO> customerAccountList = new ArrayList<AccountBO>();
for (SaveCollectionSheetCustomerDto saveCollectionSheetCustomer : saveCollectionSheetCustomers) {
SaveCollectionSheetCustomerAccountDto saveCollectionSheetCustomerAccount = saveCollectionSheetCustomer.getSaveCollectionSheetCustomerAccount();
if (null != saveCollectionSheetCustomerAccount) {
final BigDecimal amount = saveCollectionSheetCustomerAccount.getTotalCustomerAccountCollectionFee();
if (null != amount && amount.compareTo(BigDecimal.ZERO) > 0) {
final PaymentData accountPaymentDataView = getCustomerAccountPaymentDataView(new Money(Money.getDefaultCurrency(), amount.toString()), payment);
final Integer accountId = saveCollectionSheetCustomer.getSaveCollectionSheetCustomerAccount().getAccountId();
CustomerAccountBO account = null;
try {
account = findCustomerAccountById(accountId);
account.applyPayment(accountPaymentDataView);
customerAccountList.add(account);
} catch (AccountException ae) {
logger.warn("Payment of collection/fee on account [" + accountId + "] failed. Account changes will not be persisted due to: " + ae.getMessage());
failedCustomerAccountPaymentNums.add(accountId.toString());
StaticHibernateUtil.getSessionTL().evict(account);
}
}
}
}
return customerAccountList;
}
use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class ApplyChargeActionForm method validate.
@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
Locale locale = getUserContext(request).getPreferredLocale();
ActionErrors errors = new ActionErrors();
String methodCalled = request.getParameter(MethodNameConstants.METHOD);
boolean groupLoanWithMembers = AccountingRules.isGroupLoanWithMembers();
AccountBusinessService service = new AccountBusinessService();
AccountBO accountBO = null;
if (groupLoanWithMembers) {
try {
accountBO = service.getAccount(Integer.valueOf(getAccountId()));
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
}
}
if (groupLoanWithMembers && accountBO.isParentGroupLoanAccount()) {
if (methodCalled != null && methodCalled.equals("divide")) {
if (StringUtils.isNotBlank(selectedChargeFormula)) {
validateRate(errors, request);
}
validateAmount(errors, locale);
}
if (methodCalled != null && methodCalled.equals("update")) {
validateHashMap(errors);
}
if (!errors.isEmpty()) {
request.setAttribute(Globals.ERROR_KEY, errors);
if (methodCalled.equals("divide")) {
request.setAttribute("methodCalled", "update");
} else if (methodCalled.equals("update")) {
request.setAttribute("methodCalled", "create");
} else {
request.setAttribute("methodCalled", methodCalled);
}
}
} else {
if (null != methodCalled) {
if ((Methods.update.toString()).equals(methodCalled)) {
if (StringUtils.isNotBlank(selectedChargeFormula)) {
validateRate(errors, request);
}
validateAmount(errors, locale);
}
}
if (!errors.isEmpty()) {
request.setAttribute(Globals.ERROR_KEY, errors);
request.setAttribute("methodCalled", methodCalled);
}
}
return errors;
}
use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class LegacyAccountDaoIntegrationTest method testSuccessLoadBusinessObject.
@Test
public void testSuccessLoadBusinessObject() throws Exception {
AccountBO readAccount = legacyAccountDao.getAccount(groupLoan.getAccountId());
Assert.assertEquals(AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, readAccount.getState());
}
Aggregations