use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.
the class SavingsServiceFacadeWebTier method retrieveAccountStatuses.
@Override
public AccountStatusDto retrieveAccountStatuses(Long savingsId) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
SavingsBO savingsAccount = this.savingsDao.findById(savingsId);
try {
List<ListElement> savingsStatesList = new ArrayList<ListElement>();
AccountStateMachines.getInstance().initializeSavingsStates();
List<AccountStateEntity> statusList = AccountStateMachines.getInstance().getSavingsStatusList(savingsAccount.getAccountState());
for (AccountStateEntity accountState : statusList) {
savingsStatesList.add(new ListElement(accountState.getId().intValue(), accountState.getName()));
}
return new AccountStatusDto(savingsStatesList);
} catch (StatesInitializationException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.
the class AccountStatusAction method getLoanOfficers.
@TransactionDemarcate(joinToken = true)
public ActionForward getLoanOfficers(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse httpservletresponse) throws Exception {
AccountStatusActionForm accountStatusActionForm = (AccountStatusActionForm) form;
Short officeId = Short.valueOf(accountStatusActionForm.getOfficeId());
ChangeAccountStatusDto changeAccountStatusDto = this.loanAccountServiceFacade.retrieveLoanOfficerDetailsForBranch(officeId);
SessionUtils.setCollectionAttribute(LoanConstants.LOAN_OFFICERS, changeAccountStatusDto.getLoanOfficers(), request);
if (officeId != null) {
AccountStateEntity accountStateEntity = legacyMasterDao.getPersistentObject(AccountStateEntity.class, changeAccountStatusDto.getAccountState());
SessionUtils.setAttribute(LoanConstants.LOANACCOUNTSTAES, accountStateEntity, request);
}
return mapping.findForward(ActionForwards.changeAccountStatus_success.toString());
}
use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.
the class LoanAdjustmentsIntegrationTest method testWhenARepaymentIsAdjustedItGoesBackToBadStandingIfNecessary.
@Test
public void testWhenARepaymentIsAdjustedItGoesBackToBadStandingIfNecessary() throws Exception {
// relates to mifos-3479
new DateTimeService().setCurrentDateTimeFixed(date(2010, 10, 13));
loan = createLoan();
loan.updateDetails(TestUtils.makeUserWithLocales());
// pay 2 installments
makePayment(loan, "222.0");
loan.updateDetails(TestUtils.makeUserWithLocales());
// pay 1 more installment
makePayment(loan, "111.0");
loan.updateDetails(TestUtils.makeUserWithLocales());
// Ensure that after the adjustment the loan is calculated to be in bad standing.
new DateTimeService().setCurrentDateTimeFixed(date(2010, 11, 13));
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_ACTIVE_IN_GOOD_STANDING and a new status of
// LOAN_ACTIVE_IN_BAD_STANDING
AccountStateEntity oldStatus = loan.getAccountStatusChangeHistory().get(listSize - 1).getOldStatus();
AccountStateEntity newStatus = loan.getAccountStatusChangeHistory().get(listSize - 1).getNewStatus();
assertTrue("Old Status Should Have Been LOAN_ACTIVE_IN_GOOD_STANDING", oldStatus.isInState(AccountState.LOAN_ACTIVE_IN_GOOD_STANDING));
assertTrue("New Status Should Have Been LOAN_ACTIVE_IN_BAD_STANDING", newStatus.isInState(AccountState.LOAN_ACTIVE_IN_BAD_STANDING));
}
use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.
the class SavingsBO method goActiveDueToDepositOrWithdrawalOnAccount.
private void goActiveDueToDepositOrWithdrawalOnAccount(PersonnelBO updatedBy) {
if (!this.isActive()) {
AccountStateEntity oldAccountState = this.getAccountState();
AccountStateEntity newAccountState = new AccountStateEntity(AccountState.SAVINGS_ACTIVE);
this.setAccountState(newAccountState);
AccountStatusChangeHistoryEntity savingsAccountToActive = new AccountStatusChangeHistoryEntity(oldAccountState, newAccountState, updatedBy, this);
this.accountStatusChangeHistory.add(savingsAccountToActive);
}
}
use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.
the class SavingsBO method closeAccount.
public void closeAccount(final AccountPaymentEntity payment, final AccountNotesEntity notes, final CustomerBO customer, PersonnelBO loggedInUser) {
AccountStateEntity previousAccountState = this.getAccountState();
AccountStateEntity closedAccountState = new AccountStateEntity(AccountState.SAVINGS_CLOSED);
AccountStatusChangeHistoryEntity statusChangeHistory = new AccountStatusChangeHistoryEntity(previousAccountState, closedAccountState, loggedInUser, this);
this.addAccountStatusChangeHistory(statusChangeHistory);
this.setAccountState(closedAccountState);
Money interestOutstanding = payment.getAmount().subtract(this.savingsBalance);
if (interestOutstanding.isGreaterThanZero()) {
LocalDate currentPostingDate = new LocalDate(payment.getPaymentDate());
LocalDate nextPostingDate = new LocalDate();
doPostInterest(currentPostingDate, interestOutstanding, loggedInUser);
updatePostingDetails(nextPostingDate);
}
Date transactionDate = new DateTimeService().getCurrentDateMidnight().toDate();
if (payment.getAmount().isGreaterThanZero()) {
SavingsTrxnDetailEntity withdrawal = SavingsTrxnDetailEntity.savingsWithdrawal(payment, customer, this.savingsBalance, payment.getAmount(), loggedInUser, transactionDate, transactionDate, transactionDate);
payment.addAccountTrxn(withdrawal);
this.addAccountPayment(payment);
SavingsActivityEntity interestPostingActivity = SavingsActivityEntity.savingsWithdrawal(this, loggedInUser, this.savingsBalance, payment.getAmount(), payment.getPaymentDate());
savingsActivityDetails.add(interestPostingActivity);
this.savingsPerformance.setTotalWithdrawals(this.savingsPerformance.getTotalWithdrawals().add(payment.getAmount()));
try {
buildFinancialEntries(payment.getAccountTrxns());
} catch (AccountException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
this.addAccountNotes(notes);
// this.lastIntCalcDate = transactionDate;
this.lastIntPostDate = transactionDate;
// this.interIntCalcDate = null;
this.savingsBalance = new Money(getCurrency());
this.interestToBePosted = new Money(getCurrency());
this.setClosedDate(new DateTimeService().getCurrentJavaDateTime());
}
Aggregations