use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class CustomerBO method getSavingsBalance.
public Money getSavingsBalance(MifosCurrency currency) {
Money amount = new Money(currency);
for (AccountBO account : getAccounts()) {
if (account.getType() == AccountTypes.SAVINGS_ACCOUNT) {
SavingsBO savingsBO = (SavingsBO) account;
amount = amount.add(savingsBO.getSavingsBalance());
}
}
return amount;
}
use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class CustomerBO method getMaxLoanAmount.
/**
* Returns the amount which this customer
*
**/
public Money getMaxLoanAmount(final LoanOfferingBO loanOffering) {
ArrayList<Money> loanAmounts = new ArrayList<Money>();
Set<AccountBO> accounts = getAccounts();
for (AccountBO accountBO : accounts) {
// account
if (!accountBO.isInState(AccountState.LOAN_CLOSED_OBLIGATIONS_MET)) {
continue;
}
if (accountBO.isLoanAccount() && ((LoanBO) accountBO).isOfProductOffering(loanOffering)) {
loanAmounts.add(((LoanBO) accountBO).getLoanAmount());
}
}
if (loanAmounts.isEmpty()) {
loanAmounts.add(zero());
}
return Collections.max(loanAmounts);
}
use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class ApplyAdjustment method checkVersionMismatchForAccountBO.
private void checkVersionMismatchForAccountBO(HttpServletRequest request, ApplyAdjustmentActionForm appAdjustActionForm) throws ApplicationException {
AccountBO accountBOInSession = (AccountBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
AccountBO accountBO = getBizService().findBySystemId(appAdjustActionForm.getGlobalAccountNum());
checkVersionMismatch(accountBOInSession.getVersionNo(), accountBO.getVersionNo());
}
use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class ApplyChargeAction method load.
@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
ApplyChargeActionForm applyChargeActionForm = (ApplyChargeActionForm) form;
AccountBO account = ApplicationContextProvider.getBean(LegacyAccountDao.class).getAccount(Integer.valueOf(applyChargeActionForm.getAccountId()));
SessionUtils.setAttribute(Constants.BUSINESS_KEY, account, request);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, account, request.getSession());
applyChargeActionForm.clear();
request.removeAttribute(AccountConstants.APPLICABLE_CHARGE_LIST);
Integer accountId = Integer.valueOf(request.getParameter("accountId"));
List<ApplicableCharge> applicableCharges = this.accountServiceFacade.getApplicableFees(accountId);
LoanBO loan = loanDao.findById(accountId);
if (loan != null) {
for (int i = applicableCharges.size() - 1; i >= 0; --i) {
if (applicableCharges.get(i).getFeeId().equals(AccountConstants.MISC_PENALTY)) {
applicableCharges.remove(i);
break;
}
}
applicableCharges.addAll(this.loanAccountServiceFacade.getApplicablePenalties(accountId));
}
SessionUtils.setCollectionAttribute(AccountConstants.APPLICABLE_CHARGE_LIST, applicableCharges, request);
if (null != loan && (null == loan.getParentAccount() && loan.isGroupLoanAccount())) {
SessionUtils.setAttribute(Constants.ACCOUNT_TYPE, "newGlim", request);
}
return mapping.findForward(ActionForwards.load_success.toString());
}
use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class EditStatusAction method load.
@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
EditStatusActionForm actionForm = (EditStatusActionForm) form;
actionForm.setSelectedItems(null);
actionForm.setNotes(null);
actionForm.setNewStatusId(null);
actionForm.setFlagId(null);
actionForm.setQuestionGroups(null);
actionForm.setTransactionDate(DateUtils.makeDateAsSentFromBrowser());
actionForm.setAllowBackDatedApprovals(AccountingRules.isBackDatedApprovalAllowed());
request.getSession().removeAttribute(Constants.BUSINESS_KEY);
UserContext userContext = getUserContext(request);
Integer accountId = Integer.valueOf(actionForm.getAccountId());
AccountBO accountBO = new AccountBusinessService().getAccount(accountId);
java.util.Date lastPaymentDate = new java.util.Date(0);
AccountPaymentEntity lastPayment = accountBO.findMostRecentNonzeroPaymentByPaymentDate();
if (lastPayment != null) {
lastPaymentDate = lastPayment.getPaymentDate();
}
actionForm.setLastPaymentDate(lastPaymentDate);
if (accountBO.isLoanAccount() || accountBO.isGroupLoanAccount()) {
// NOTE - not using dto values at present but available when ui is refactored away from jsp
AccountStatusDto accountStatuses = this.loanAccountServiceFacade.retrieveAccountStatuses(accountId.longValue());
LoanBO loanAccount = this.loanDao.findById(accountId);
EditStatusActionForm editStatusActionForm = (EditStatusActionForm) form;
editStatusActionForm.setAccountTypeId(AccountTypes.LOAN_ACCOUNT.getValue().toString());
editStatusActionForm.setCurrentStatusId(loanAccount.getAccountState().getId().toString());
editStatusActionForm.setGlobalAccountNum(loanAccount.getGlobalAccountNum());
editStatusActionForm.setAccountName(loanAccount.getLoanOffering().getPrdOfferingName());
if (loanAccount.isGroupLoanAccount() && loanAccount.getParentAccount() == null) {
editStatusActionForm.setInput("grouploan");
} else {
editStatusActionForm.setInput("loan");
}
if (loanAccount.getAccountState().getId().equals(Short.valueOf("2"))) {
List<AdminDocumentBO> allAdminDocuments = legacyAdminDocumentDao.getAllActiveAdminDocuments();
List<AdminDocumentBO> loanAdminDocuments = new ArrayList();
for (AdminDocumentBO adminDocumentBO : allAdminDocuments) {
List<AdminDocAccStateMixBO> admindoclist = legacyAdminDocAccStateMixDao.getMixByAdminDocuments(adminDocumentBO.getAdmindocId());
if (!loanAdminDocuments.contains(adminDocumentBO) && admindoclist.size() > 0 && admindoclist.get(0).getAccountStateID().getPrdType().getProductTypeID().equals(loanAccount.getType().getValue().shortValue())) {
for (AdminDocAccStateMixBO admindoc : admindoclist) {
if (admindoc.getAccountStateID().getId().shortValue() == loanAccount.getAccountState().getId().shortValue()) {
loanAdminDocuments.add(adminDocumentBO);
}
}
}
}
SessionUtils.setCollectionAttribute("editAccountStatusDocumentsList", loanAdminDocuments, request);
} else {
SessionUtils.setCollectionAttribute("editAccountStatusDocumentsList", null, request);
}
}
if (accountBO.isSavingsAccount()) {
// NOTE - not using dto values at present but available when ui is refactored away from jsp
AccountStatusDto accountStatuses = this.savingsServiceFacade.retrieveAccountStatuses(accountId.longValue());
SavingsBO savingsAccount = this.savingsDao.findById(accountId.longValue());
EditStatusActionForm editStatusActionForm = (EditStatusActionForm) form;
editStatusActionForm.setAccountTypeId(AccountTypes.SAVINGS_ACCOUNT.getValue().toString());
editStatusActionForm.setCurrentStatusId(savingsAccount.getAccountState().getId().toString());
editStatusActionForm.setGlobalAccountNum(savingsAccount.getGlobalAccountNum());
editStatusActionForm.setAccountName(savingsAccount.getSavingsOffering().getPrdOfferingName());
editStatusActionForm.setInput("savings");
}
List<AccountStateEntity> accountStatuses = new AccountBusinessService().getStatusList(accountBO.getAccountState(), accountBO.getType(), userContext.getLocaleId());
for (AccountStateEntity customerStatusEntity : accountStatuses) {
for (AccountStateFlagEntity flag : customerStatusEntity.getFlagSet()) {
String statusMessageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(flag.getLookUpValue().getPropertiesKey());
flag.setStatusFlagMessageText(statusMessageText);
}
}
SessionUtils.setAttribute(Constants.BUSINESS_KEY, accountBO, request);
SessionUtils.setCollectionAttribute(SavingsConstants.STATUS_LIST, accountStatuses, request);
return mapping.findForward(ActionForwards.load_success.toString());
}
Aggregations