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));
}
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));
}
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;
}
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());
}
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);
}
}
Aggregations