Search in sources :

Example 91 with AccountBO

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

the class CustAction method getClosedAccounts.

@TransactionDemarcate(joinToken = true)
public ActionForward getClosedAccounts(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In CustAction::getClosedAccounts()");
    UserContext userContext = getUserContext(request);
    Integer customerId = getIntegerValue(((CustActionForm) form).getCustomerId());
    List<ClosedAccountDto> allClosedAccounts = this.centerServiceFacade.retrieveAllClosedAccounts(customerId);
    List<AccountBO> loanAccountsList = new CustomerPersistence().getAllClosedAccount(customerId, AccountTypes.LOAN_ACCOUNT.getValue());
    loanAccountsList.addAll(new CustomerPersistence().getAllClosedAccount(customerId, AccountTypes.GROUP_LOAN_ACCOUNT.getValue()));
    List<AccountBO> savingsAccountList = new CustomerPersistence().getAllClosedAccount(customerId, AccountTypes.SAVINGS_ACCOUNT.getValue());
    SessionUtils.setCollectionAttribute(AccountConstants.CLOSEDLOANACCOUNTSLIST, loanAccountsList, request);
    SessionUtils.setCollectionAttribute(AccountConstants.CLOSEDSAVINGSACCOUNTSLIST, savingsAccountList, request);
    return mapping.findForward(ActionForwards.getAllClosedAccounts.toString());
}
Also used : ClosedAccountDto(org.mifos.dto.screen.ClosedAccountDto) AccountBO(org.mifos.accounts.business.AccountBO) UserContext(org.mifos.security.util.UserContext) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 92 with AccountBO

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

the class CollectionSheetServiceImplRetrieveSavingsAccountsIntegrationTest method testCollectionSheetRetrieveOnlyReturnsActiveAndInactiveSavingsAccounts.

/**
     * need to clean up test data set up
     */
@Ignore
@Test
public void testCollectionSheetRetrieveOnlyReturnsActiveAndInactiveSavingsAccounts() throws Exception {
    UserContext userContext = TestUtils.makeUser();
    collectionSheetRetrieveSavingsAccountsUtils.createSampleCenterHierarchy();
    SavingsBO centerSavingsAccount = (SavingsBO) legacyAccountDao.getAccount(collectionSheetRetrieveSavingsAccountsUtils.getCenterSavingsAccount().getAccountId());
    centerSavingsAccount.setUserContext(userContext);
    PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
    centerSavingsAccount.changeStatus(AccountState.SAVINGS_INACTIVE, Short.valueOf("1"), "Make Center Savings Account Inactive", loggedInUser);
    SavingsBO clientSavings = (SavingsBO) legacyAccountDao.getAccount(collectionSheetRetrieveSavingsAccountsUtils.getClientOfGroupCompleteGroupSavingsAccount().getAccountId());
    AccountPaymentEntity payment = new AccountPaymentEntity(clientSavings, new Money(clientSavings.getCurrency()), null, null, new PaymentTypeEntity(Short.valueOf("1")), new Date());
    AccountNotesEntity notes = new AccountNotesEntity(new java.sql.Date(System.currentTimeMillis()), "close client savings account", TestObjectFactory.getPersonnel(userContext.getId()), clientSavings);
    clientSavings.setUserContext(userContext);
    clientSavings.closeAccount(payment, notes, clientSavings.getCustomer(), loggedInUser);
    IntegrationTestObjectMother.saveSavingsAccount(clientSavings);
    StaticHibernateUtil.flushSession();
    CollectionSheetDto collectionSheet = collectionSheetService.retrieveCollectionSheet(collectionSheetRetrieveSavingsAccountsUtils.getCenter().getCustomerId(), new LocalDate());
    List<CollectionSheetCustomerDto> customers = collectionSheet.getCollectionSheetCustomer();
    for (CollectionSheetCustomerDto customer : customers) {
        for (CollectionSheetCustomerSavingDto customerSaving : customer.getCollectionSheetCustomerSaving()) {
            Boolean accountIsActiveOrInactive = false;
            AccountBO accountBO = legacyAccountDao.getAccount(customerSaving.getAccountId());
            if ((accountBO.getState().equals(AccountState.SAVINGS_ACTIVE)) || (accountBO.getState().equals(AccountState.SAVINGS_INACTIVE))) {
                accountIsActiveOrInactive = true;
            }
            Assert.assertTrue("Found Account State: " + accountBO.getState().toString() + " - Only Active and Inactive Savings Accounts are Allowed", accountIsActiveOrInactive);
        }
    }
}
Also used : UserContext(org.mifos.security.util.UserContext) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) AccountNotesEntity(org.mifos.accounts.business.AccountNotesEntity) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) LocalDate(org.joda.time.LocalDate) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) Money(org.mifos.framework.util.helpers.Money) AccountBO(org.mifos.accounts.business.AccountBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 93 with AccountBO

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

the class ApplyPaymentActionStrutsTest method xtestApplyPaymentAndRetrievalForLoanWhenStatusIsChanged.

public void xtestApplyPaymentAndRetrievalForLoanWhenStatusIsChanged() throws Exception {
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    accountBO = createLoanAccount();
    SessionUtils.setAttribute(Constants.ACCOUNT_VERSION, accountBO.getVersionNo(), request);
    SessionUtils.setAttribute(Constants.ACCOUNT_TYPE, AccountTypes.getAccountType(accountBO.getAccountType().getAccountTypeId()).name(), request);
    SessionUtils.setAttribute(Constants.ACCOUNT_ID, accountBO.getAccountId(), request);
    accountBO.setUserContext(TestObjectFactory.getContext());
    PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
    accountBO.changeStatus(AccountState.LOAN_ACTIVE_IN_BAD_STANDING, null, "", loggedInUser);
    AccountApplyPaymentActionForm accountApplyPaymentActionForm = new AccountApplyPaymentActionForm();
    accountApplyPaymentActionForm.setAmount("212");
    request.getSession().setAttribute("applyPaymentActionForm", accountApplyPaymentActionForm);
    setRequestPathInfo("/applyPaymentAction");
    addRequestParameter("input", "loan");
    addRequestParameter("method", "applyPayment");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    addRequestParameter("accountId", accountBO.getAccountId().toString());
    addRequestParameter("receiptId", "101");
    String currentDate = DateUtils.makeDateAsSentFromBrowser();
    addRequestDateParameter("receiptDate", currentDate);
    addRequestDateParameter("transactionDate", currentDate);
    addRequestParameter("paymentTypeId", "1");
    actionPerform();
    verifyForward("loan_detail_page");
    center = TestObjectFactory.getCenter(center.getCustomerId());
    group = TestObjectFactory.getGroup(group.getCustomerId());
    accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
    Assert.assertEquals(new Money(getCurrency()), accountBO.getTotalPaymentDue());
    Assert.assertEquals(0, accountBO.getTotalInstallmentsDue().size());
    Assert.assertEquals(AccountStates.LOANACC_ACTIVEINGOODSTANDING, accountBO.getAccountState().getId().shortValue());
    setRequestPathInfo("/loanAccountAction");
    addRequestParameter("globalAccountNum", accountBO.getGlobalAccountNum());
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    addRequestParameter("method", "get");
    actionPerform();
    //LoanBO loan = (LoanBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    LoanBO loan = (LoanBO) StaticHibernateUtil.getSessionTL().load(LoanBO.class, accountBO.getAccountId());
    Assert.assertEquals(AccountStates.LOANACC_ACTIVEINGOODSTANDING, loan.getAccountState().getId().shortValue());
    Assert.assertNotNull(loan.getAccountState().getName());
    accountBO = (AccountBO) StaticHibernateUtil.getSessionTL().load(AccountBO.class, accountBO.getAccountId());
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) Money(org.mifos.framework.util.helpers.Money) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) AccountApplyPaymentActionForm(org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm)

Example 94 with AccountBO

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

the class CustomerActionStrutsTest method ignore_testForwardWaiveChargeOverDue.

public void ignore_testForwardWaiveChargeOverDue() {
    createInitialObjects();
    setRequestPathInfo("/customerAction.do");
    addRequestParameter("method", "waiveChargeOverDue");
    addRequestParameter("type", "Client");
    AccountBO accountBO = client.getCustomerAccount();
    addRequestParameter("accountId", accountBO.getAccountId().toString());
    getRequest().getSession().setAttribute("security_param", "Client");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyForward("waiveChargesOverDue_Success");
    verifyNoActionErrors();
    verifyNoActionMessages();
    Assert.assertNotNull(request.getAttribute(Constants.CURRENTFLOWKEY));
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO)

Example 95 with AccountBO

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

the class CustomerPersistenceIntegrationTest method testGetTotalAmountForAllClientsOfGroupForMultipleCurrencies.

/*
     * When trying to sum amounts across loans with different currencies, we should get an exception
     */
@Test
public void testGetTotalAmountForAllClientsOfGroupForMultipleCurrencies() throws Exception {
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    configMgr.setProperty(AccountingRulesConstants.ADDITIONAL_CURRENCY_CODES, TestUtils.EURO.getCurrencyCode());
    AccountBO clientAccount1;
    AccountBO clientAccount2;
    try {
        MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
        center = createCenter("new_center");
        group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
        client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
        clientAccount1 = getLoanAccount(client, meeting, "fdbdhgsgh", "54hg", TestUtils.RUPEE);
        clientAccount2 = getLoanAccount(client, meeting, "fasdfdsfasdf", "1qwe", TestUtils.EURO);
        try {
            customerPersistence.getTotalAmountForAllClientsOfGroup(group.getOffice().getOfficeId(), AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, group.getSearchId() + ".%");
            Assert.fail("didn't get the expected CurrencyMismatchException");
        } catch (CurrencyMismatchException e) {
            // if we got here then we got the exception we were expecting
            Assert.assertNotNull(e);
        } catch (Exception e) {
            Assert.fail("didn't get the expected CurrencyMismatchException");
        }
    } finally {
        configMgr.clearProperty(AccountingRulesConstants.ADDITIONAL_CURRENCY_CODES);
    }
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) CurrencyMismatchException(org.mifos.core.CurrencyMismatchException) MeetingBO(org.mifos.application.meeting.business.MeetingBO) SystemException(org.mifos.framework.exceptions.SystemException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) CurrencyMismatchException(org.mifos.core.CurrencyMismatchException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager) 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