Search in sources :

Example 81 with AccountBO

use of org.mifos.accounts.business.AccountBO in project head by mifos.

the class ClientPerformanceHistoryEntity method getDelinquentPortfolioAmount.

public Money getDelinquentPortfolioAmount() {
    // we don't know what currency to use when we start totaling these
    // so don't initialize them with a currency
    Money amountOverDue = null;
    Money totalOutStandingAmount = null;
    for (AccountBO accountBO : client.getAccounts()) {
        if (accountBO.isLoanAccount() && ((LoanBO) accountBO).isAccountActive()) {
            Money totalPrincipalAmountInArrears = ((LoanBO) accountBO).getTotalPrincipalAmountInArrears();
            if (amountOverDue == null) {
                amountOverDue = totalPrincipalAmountInArrears;
            } else {
                amountOverDue = amountOverDue.add(totalPrincipalAmountInArrears);
            }
            Money originalPrincipal = ((LoanBO) accountBO).getLoanSummary().getOriginalPrincipal();
            if (totalOutStandingAmount == null) {
                totalOutStandingAmount = originalPrincipal;
            } else {
                totalOutStandingAmount = totalOutStandingAmount.add(originalPrincipal);
            }
        }
    }
    // FIXME: this seems like it should just be returning a BigDecimal rather than a Money object
    if (totalOutStandingAmount != null && !totalOutStandingAmount.getAmount().equals(BigDecimal.ZERO)) {
        return new Money(amountOverDue.getCurrency(), amountOverDue.divide(totalOutStandingAmount));
    }
    return new Money(getCurrency());
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountBO(org.mifos.accounts.business.AccountBO) LoanBO(org.mifos.accounts.loan.business.LoanBO)

Example 82 with AccountBO

use of org.mifos.accounts.business.AccountBO in project head by mifos.

the class AccountAppAction method getTrxnHistory.

@TransactionDemarcate(joinToken = true)
public ActionForward getTrxnHistory(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    String globalAccountNum = request.getParameter("globalAccountNum");
    AccountBO accountBO = getAccountBusinessService().findBySystemId(globalAccountNum);
    List<TransactionHistoryDto> transactionHistoryDto = this.centerServiceFacade.retrieveAccountTransactionHistory(globalAccountNum);
    if (accountBO.isGroupLoanAccount() && null == ((LoanBO) accountBO).getParentAccount()) {
        SessionUtils.setAttribute(Constants.TYPE_OF_GROUP_LOAN, "parentAcc", request);
    } else if (accountBO.isGroupLoanAccount() && null != ((LoanBO) accountBO).getParentAccount()) {
        SessionUtils.setAttribute(Constants.TYPE_OF_GROUP_LOAN, "memberAcc", request);
    }
    SessionUtils.setCollectionAttribute(SavingsConstants.TRXN_HISTORY_LIST, transactionHistoryDto, request);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, accountBO, request);
    request.setAttribute("GlNamesMode", AccountingRules.getGlNamesMode());
    return mapping.findForward("getTransactionHistory_success");
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) TransactionHistoryDto(org.mifos.dto.screen.TransactionHistoryDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 83 with AccountBO

use of org.mifos.accounts.business.AccountBO in project head by mifos.

the class AccountAppAction method waiveChargeOverDue.

@TransactionDemarcate(joinToken = true)
public ActionForward waiveChargeOverDue(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USERCONTEXT, request.getSession());
    Integer accountId = getIntegerValue(request.getParameter("accountId"));
    WaiveEnum waiveEnum = getWaiveType(request.getParameter(AccountConstants.WAIVE_TYPE));
    this.centerServiceFacade.waiveChargesOverDue(accountId, waiveEnum.ordinal());
    AccountBO account = getAccountBusinessService().getAccount(accountId);
    account.updateDetails(uc);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, account, request);
    return mapping.findForward("waiveChargesOverDue_Success");
}
Also used : WaiveEnum(org.mifos.accounts.util.helpers.WaiveEnum) AccountBO(org.mifos.accounts.business.AccountBO) UserContext(org.mifos.security.util.UserContext) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 84 with AccountBO

use of org.mifos.accounts.business.AccountBO in project head by mifos.

the class AccountAppAction method waiveChargeDue.

@TransactionDemarcate(joinToken = true)
public ActionForward waiveChargeDue(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USERCONTEXT, request.getSession());
    Integer accountId = getIntegerValue(request.getParameter("accountId"));
    WaiveEnum waiveEnum = getWaiveType(request.getParameter(AccountConstants.WAIVE_TYPE));
    this.centerServiceFacade.waiveChargesDue(accountId, waiveEnum.ordinal());
    AccountBO account = getAccountBusinessService().getAccount(accountId);
    account.updateDetails(uc);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, account, request);
    return mapping.findForward("waiveChargesDue_Success");
}
Also used : WaiveEnum(org.mifos.accounts.util.helpers.WaiveEnum) AccountBO(org.mifos.accounts.business.AccountBO) UserContext(org.mifos.security.util.UserContext) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 85 with AccountBO

use of org.mifos.accounts.business.AccountBO in project head by mifos.

the class AccountServiceIntegrationTest method testGetAppllicableFees.

@Test
public void testGetAppllicableFees() throws Exception {
    AccountBusinessService accountBusinessService = new AccountBusinessService();
    accountBO = getLoanAccount();
    StaticHibernateUtil.flushSession();
    center = TestObjectFactory.getCustomer(center.getCustomerId());
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
    UserContext uc = TestUtils.makeUser();
    List<ApplicableCharge> applicableChargeList = accountBusinessService.getAppllicableFees(accountBO.getAccountId(), uc);
    Assert.assertEquals(2, applicableChargeList.size());
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) UserContext(org.mifos.security.util.UserContext) ApplicableCharge(org.mifos.dto.domain.ApplicableCharge) Test(org.junit.Test)

Aggregations

AccountBO (org.mifos.accounts.business.AccountBO)106 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)39 LoanBO (org.mifos.accounts.loan.business.LoanBO)35 ArrayList (java.util.ArrayList)30 Money (org.mifos.framework.util.helpers.Money)30 UserContext (org.mifos.security.util.UserContext)29 Test (org.junit.Test)27 MifosRuntimeException (org.mifos.core.MifosRuntimeException)26 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)20 ServiceException (org.mifos.framework.exceptions.ServiceException)19 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)18 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)16 AccountException (org.mifos.accounts.exceptions.AccountException)15 MifosUser (org.mifos.security.MifosUser)14 Date (java.util.Date)13 LocalDate (org.joda.time.LocalDate)12 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)12 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)11 PersistenceException (org.mifos.framework.exceptions.PersistenceException)10 FeeBO (org.mifos.accounts.fees.business.FeeBO)9