Search in sources :

Example 26 with AccountStateEntity

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

the class LoanAdjustmentsIntegrationTest method testWhenACompletedLoanIsAdjustedThatAnAccountStatusChangeHistoryEntryisCreated.

@Test
public void testWhenACompletedLoanIsAdjustedThatAnAccountStatusChangeHistoryEntryisCreated() throws Exception {
    // relates to mifos-3479
    new DateTimeService().setCurrentDateTimeFixed(date(2010, 10, 13));
    loan = createLoan();
    loan.updateDetails(TestUtils.makeUserWithLocales());
    // pay 3 installments
    makePayment(loan, "333.0");
    loan.updateDetails(TestUtils.makeUserWithLocales());
    makeEarlyPayment(loan);
    loan.updateDetails(TestUtils.makeUserWithLocales());
    adjustLastLoanPayment(loan);
    loan.updateDetails(TestUtils.makeUserWithLocales());
    assertNotNull("Account Status Change History Should Not Be Null", loan.getAccountStatusChangeHistory());
    Integer listSize = loan.getAccountStatusChangeHistory().size();
    assertFalse(listSize == 0);
    // check if the last entry has an oldstatus LOAN_CLOSED_OBLIGATIONS_MET and a new status of
    // LOAN_ACTIVE_IN_GOOD_STANDING
    AccountStateEntity oldStatus = loan.getAccountStatusChangeHistory().get(listSize - 1).getOldStatus();
    AccountStateEntity newStatus = loan.getAccountStatusChangeHistory().get(listSize - 1).getNewStatus();
    assertTrue("Old Status Should Have Been LOAN_CLOSED_OBLIGATIONS_MET", oldStatus.isInState(AccountState.LOAN_CLOSED_OBLIGATIONS_MET));
    assertTrue("New Status Should Have Been LOAN_ACTIVE_IN_GOOD_STANDING", newStatus.isInState(AccountState.LOAN_ACTIVE_IN_GOOD_STANDING));
}
Also used : AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) DateTimeService(org.mifos.framework.util.DateTimeService) Test(org.junit.Test)

Example 27 with AccountStateEntity

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

the class LoanAdjustmentsIntegrationTest method testWhenACompletedLoanIsAdjustedItGoesBackToBadStandingIfNecessary.

@Test
public void testWhenACompletedLoanIsAdjustedItGoesBackToBadStandingIfNecessary() throws Exception {
    // relates to mifos-3479
    new DateTimeService().setCurrentDateTimeFixed(date(2010, 10, 13));
    loan = createLoan();
    loan.updateDetails(TestUtils.makeUserWithLocales());
    // pay 3 installments
    makePayment(loan, "333.0");
    loan.updateDetails(TestUtils.makeUserWithLocales());
    makeEarlyPayment(loan);
    loan.updateDetails(TestUtils.makeUserWithLocales());
    // ensure loan is in bad standing when reopened
    new DateTimeService().setCurrentDateTimeFixed(date(2010, 11, 13));
    adjustLastLoanPayment(loan);
    loan.updateDetails(TestUtils.makeUserWithLocales());
    AccountStateEntity currentStatus = loan.getAccountState();
    assertTrue("Current Status Should Have Been LOAN_ACTIVE_IN_BAD_STANDING", currentStatus.isInState(AccountState.LOAN_ACTIVE_IN_BAD_STANDING));
}
Also used : AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) DateTimeService(org.mifos.framework.util.DateTimeService) Test(org.junit.Test)

Example 28 with AccountStateEntity

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

the class CheckListPersistence method retrieveAllAccountStateList.

@SuppressWarnings("unchecked")
public List<CheckListStatesView> retrieveAllAccountStateList(Short prdTypeId, Short localeId) throws PersistenceException {
    List<CheckListStatesView> checkListStatesView = new ArrayList<CheckListStatesView>();
    HashMap<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("prdTypeId", prdTypeId);
    List<AccountStateEntity> queryResult = executeNamedQuery(NamedQueryConstants.CHECKLIST_GET_VALID_ACCOUNT_STATES, queryParameters);
    for (AccountStateEntity accountStatus : queryResult) {
        checkListStatesView.add(new CheckListStatesView(accountStatus.getId(), accountStatus.getName(), accountStatus.getPrdType().getProductTypeID()));
    }
    return checkListStatesView;
}
Also used : CheckListStatesView(org.mifos.dto.screen.CheckListStatesView) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity)

Example 29 with AccountStateEntity

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

the class AccountServiceIntegrationTest method testGetStatusList.

@Test
public void testGetStatusList() throws Exception {
    AccountStateMachines.getInstance().initialize(AccountTypes.SAVINGS_ACCOUNT, null);
    List<AccountStateEntity> statusListForSavings = service.getStatusList(new AccountStateEntity(AccountState.SAVINGS_PARTIAL_APPLICATION), AccountTypes.SAVINGS_ACCOUNT, TestUtils.makeUser().getLocaleId());
    Assert.assertEquals(2, statusListForSavings.size());
    AccountStateMachines.getInstance().initialize(AccountTypes.LOAN_ACCOUNT, null);
    List<AccountStateEntity> statusListForLoan = service.getStatusList(new AccountStateEntity(AccountState.LOAN_PARTIAL_APPLICATION), AccountTypes.LOAN_ACCOUNT, Short.valueOf("1"));
    Assert.assertEquals(2, statusListForLoan.size());
}
Also used : AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) Test(org.junit.Test)

Example 30 with AccountStateEntity

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

the class LoanBO method handleArrears.

public void handleArrears() throws AccountException {
    AccountStateEntity stateEntity;
    try {
        stateEntity = legacyMasterDao.getPersistentObject(AccountStateEntity.class, AccountStates.LOANACC_BADSTANDING);
    } catch (PersistenceException e) {
        throw new AccountException(e);
    }
    AccountStatusChangeHistoryEntity historyEntity = new AccountStatusChangeHistoryEntity(this.getAccountState(), stateEntity, this.getPersonnel(), this);
    this.addAccountStatusChangeHistory(historyEntity);
    this.setAccountState(stateEntity);
    try {
        String systemDate = DateUtils.getCurrentDate();
        Date currrentDate = DateUtils.getLocaleDate(systemDate);
        this.setUpdatedDate(currrentDate);
    } catch (InvalidDateException ide) {
        throw new AccountException(ide);
    }
    try {
        getlegacyLoanDao().createOrUpdate(this);
    } catch (PersistenceException e) {
        throw new AccountException(e);
    }
}
Also used : AccountException(org.mifos.accounts.exceptions.AccountException) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AccountStatusChangeHistoryEntity(org.mifos.accounts.business.AccountStatusChangeHistoryEntity) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) Date(java.util.Date) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) LocalDate(org.joda.time.LocalDate)

Aggregations

AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)49 Test (org.junit.Test)19 ArrayList (java.util.ArrayList)11 AccountStatusChangeHistoryEntity (org.mifos.accounts.business.AccountStatusChangeHistoryEntity)11 AccountException (org.mifos.accounts.exceptions.AccountException)8 PersistenceException (org.mifos.framework.exceptions.PersistenceException)7 Money (org.mifos.framework.util.helpers.Money)7 MifosRuntimeException (org.mifos.core.MifosRuntimeException)6 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)6 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)5 AdminDocAccStateMixBO (org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO)5 AdminDocumentBO (org.mifos.reports.admindocuments.business.AdminDocumentBO)5 Date (java.util.Date)4 List (java.util.List)4 LocalDate (org.joda.time.LocalDate)4 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)4 AccountStateFlagEntity (org.mifos.accounts.business.AccountStateFlagEntity)4 LoanBO (org.mifos.accounts.loan.business.LoanBO)4 DateTimeService (org.mifos.framework.util.DateTimeService)4 UserContext (org.mifos.security.util.UserContext)4