use of org.mifos.accounts.business.AccountStatusChangeHistoryEntity in project head by mifos.
the class SavingsBO method save.
/**
* @deprecated use {@link SavingsDao#save(SavingsBO)} to persist savings account.
*/
@Deprecated
public void save() throws AccountException {
logger.info("In SavingsBO::save(), Before Saving , accountId: " + getAccountId());
try {
this.addAccountStatusChangeHistory(new AccountStatusChangeHistoryEntity(this.getAccountState(), this.getAccountState(), getPersonnelPersistence().getPersonnel(userContext.getId()), this));
getSavingsPersistence().createOrUpdate(this);
OfficeBO branch = getSavingsPersistence().getPersistentObject(OfficeBO.class, userContext.getBranchId());
this.globalAccountNum = generateId(branch.getGlobalOfficeNum());
getSavingsPersistence().createOrUpdate(this);
} catch (PersistenceException e) {
throw new AccountException(e);
}
logger.info("In SavingsBO::save(), Successfully saved , accountId: " + getAccountId());
}
use of org.mifos.accounts.business.AccountStatusChangeHistoryEntity 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.AccountStatusChangeHistoryEntity 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());
}
use of org.mifos.accounts.business.AccountStatusChangeHistoryEntity in project head by mifos.
the class SavingsServiceFacadeWebTier method retrieveStatusChangeHistory.
@Override
public List<SavingsStatusChangeHistoryDto> retrieveStatusChangeHistory(String globalAccountNum) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
SavingsBO savingsAccount = this.savingsDao.findBySystemId(globalAccountNum);
savingsAccount.updateDetails(userContext);
List<SavingsStatusChangeHistoryDto> dtoList = new ArrayList<SavingsStatusChangeHistoryDto>();
List<AccountStatusChangeHistoryEntity> statusChangeHistory = savingsAccount.getAccountStatusChangeHistory();
for (AccountStatusChangeHistoryEntity accountStatusChangeHistory : statusChangeHistory) {
dtoList.add(accountStatusChangeHistory.toDto());
}
return dtoList;
}
use of org.mifos.accounts.business.AccountStatusChangeHistoryEntity in project head by mifos.
the class ApplyAdjustmentActionStrutsTest method testApplyAdjustment.
@Ignore
@Test
public void testApplyAdjustment() throws Exception {
PersonnelBO personnel = legacyPersonnelDao.getPersonnel(PersonnelConstants.SYSTEM_USER);
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
loan = (LoanBO) getLoanAccount();
applyPayment(loan, 212);
loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
applyPayment(loan, 700);
loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
AccountStatusChangeHistoryEntity historyEntity = new AccountStatusChangeHistoryEntity(new AccountStateEntity(AccountState.LOAN_ACTIVE_IN_GOOD_STANDING), new AccountStateEntity(AccountState.LOAN_ACTIVE_IN_GOOD_STANDING), personnel, loan);
AccountTestUtils.addToAccountStatusChangeHistory(loan, historyEntity);
TestObjectFactory.updateObject(loan);
StaticHibernateUtil.flushAndClearSession();
loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
loan.setUserContext(userContext);
for (AccountStatusChangeHistoryEntity accountStatus : loan.getAccountStatusChangeHistory()) {
Assert.assertEquals(loan.getAccountId(), accountStatus.getAccount().getAccountId());
Assert.assertNotNull(accountStatus.getAccountStatusChangeId());
Assert.assertEquals(AccountState.LOAN_ACTIVE_IN_GOOD_STANDING.getValue(), accountStatus.getNewStatus().getId());
Assert.assertEquals(personnel.getPersonnelId(), accountStatus.getPersonnel().getPersonnelId());
Assert.assertEquals(personnel.getDisplayName(), accountStatus.getPersonnel().getDisplayName());
Assert.assertEquals("-", accountStatus.getOldStatusName());
Assert.assertNotNull(accountStatus.getNewStatusName());
Assert.assertNull(accountStatus.getLocale());
Assert.assertNotNull(accountStatus.getUserPrefferedTransactionDate());
}
SessionUtils.setAttribute(Constants.BUSINESS_KEY, loan, request);
setRequestPathInfo("/applyAdjustment");
addRequestParameter("method", "applyAdjustment");
addRequestParameter("adjustmentNote", "Loan adjustment testing");
addRequestParameter("globalAccountNum", loan.getGlobalAccountNum());
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
setUpSecurityContext();
getRequest().getSession().setAttribute(Constants.USERCONTEXT, TestUtils.makeUser());
actionPerform();
loan = (LoanBO) TestObjectFactory.getObject(AccountBO.class, loan.getAccountId());
verifyForward("applyadj_success");
}
Aggregations