use of org.mifos.accounts.business.AccountNotesEntity in project head by mifos.
the class SavingsDaoHibernate method searchNotes.
@SuppressWarnings("unchecked")
@Override
public NotesSearchResultsDto searchNotes(NoteSearchDto noteSearch) {
Session session = StaticHibernateUtil.getSessionTL();
Criteria criteriaQuery = session.createCriteria(AccountNotesEntity.class);
criteriaQuery.add(Restrictions.eq("account.accountId", noteSearch.getAccountId()));
criteriaQuery.addOrder(Order.desc("commentId"));
Integer totalNumberOfSavingsNotes = 10;
int firstResult = (noteSearch.getPage() * noteSearch.getPageSize()) - noteSearch.getPageSize();
criteriaQuery.setFirstResult(firstResult);
criteriaQuery.setMaxResults(noteSearch.getPageSize());
List<AccountNotesEntity> pagedResults = criteriaQuery.list();
List<CustomerNoteDto> pageDtoResults = new ArrayList<CustomerNoteDto>();
for (AccountNotesEntity note : pagedResults) {
pageDtoResults.add(new CustomerNoteDto(note.getCommentDate(), note.getComment(), note.getPersonnelName()));
}
SearchDetailsDto searchDetails = new SearchDetailsDto(totalNumberOfSavingsNotes.intValue(), firstResult, noteSearch.getPage(), noteSearch.getPageSize());
NotesSearchResultsDto resultsDto = new NotesSearchResultsDto(searchDetails, pageDtoResults);
return resultsDto;
}
use of org.mifos.accounts.business.AccountNotesEntity in project head by mifos.
the class SavingsBO method toDto.
public SavingsAccountDetailDto toDto() {
List<SavingsRecentActivityDto> recentActivity = this.getRecentAccountActivity(3);
List<CustomerNoteDto> recentNoteDtos = new ArrayList<CustomerNoteDto>();
List<AccountNotesEntity> recentNotes = this.getRecentAccountNotes();
for (AccountNotesEntity accountNotesEntity : recentNotes) {
recentNoteDtos.add(new CustomerNoteDto(accountNotesEntity.getCommentDate(), accountNotesEntity.getComment(), accountNotesEntity.getPersonnelName()));
}
SavingsPerformanceHistoryDto savingsPerformanceHistoryDto = new SavingsPerformanceHistoryDto(getActivationDate(), savingsPerformance.getTotalDeposits().toString(), savingsPerformance.getTotalWithdrawals().toString(), savingsPerformance.getTotalInterestEarned().toString(), savingsPerformance.getMissedDeposits() != null ? savingsPerformance.getMissedDeposits().toString() : "0");
AccountActionDateEntity nextInstallment = getDetailsOfNextInstallment();
return new SavingsAccountDetailDto(this.savingsOffering.toFullDto(), recentActivity, recentNoteDtos, this.recommendedAmount.toString(), this.globalAccountNum, getAccountId(), getState().getValue(), getState().name(), getSavingsBalance().toString(), nextInstallment != null ? nextInstallment.getActionDate() : null, getTotalAmountDue().toString(), getTotalAmountDueForNextInstallment().toString(), getTotalAmountInArrears().toString(), savingsPerformanceHistoryDto, this.savingsOffering.getSavingsTypeAsEnum().name(), this.customer.getCustomerId());
}
use of org.mifos.accounts.business.AccountNotesEntity in project head by mifos.
the class SavingsServiceFacadeWebTier method addNote.
@Override
public void addNote(CreateAccountNote accountNote) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
PersonnelBO createdBy = this.personnelDao.findPersonnelById(accountNote.getCreatedById().shortValue());
SavingsBO savingsAccount = this.savingsDao.findById(accountNote.getAccountId().longValue());
AccountNotesEntity accountNotes = new AccountNotesEntity(new java.sql.Date(accountNote.getCommentDate().toDateMidnight().toDate().getTime()), accountNote.getComment(), createdBy, savingsAccount);
try {
this.transactionHelper.startTransaction();
savingsAccount.updateDetails(userContext);
savingsAccount.addAccountNotes(accountNotes);
this.savingsDao.save(savingsAccount);
this.transactionHelper.commitTransaction();
} catch (Exception e) {
this.transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
this.transactionHelper.closeSession();
}
}
use of org.mifos.accounts.business.AccountNotesEntity 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);
}
}
}
use of org.mifos.accounts.business.AccountNotesEntity in project head by mifos.
the class SaveCollectionSheetStructureValidatorIntegrationTest method ignore_testShouldGetINVALID_SAVINGS_ACCOUNT_STATUSIfSavingsAccountClosed.
public void ignore_testShouldGetINVALID_SAVINGS_ACCOUNT_STATUSIfSavingsAccountClosed() throws Exception {
LocalDate transactionDate = new LocalDate();
// create a center hierarchy with savings accounts
collectionSheetRetrieveSavingsAccountsUtils.createSampleCenterHierarchy();
// retrieve the collection sheet for today
CollectionSheetService collectionSheetService = ApplicationContextProvider.getBean(CollectionSheetService.class);
CollectionSheetDto collectionSheet = collectionSheetService.retrieveCollectionSheet(collectionSheetRetrieveSavingsAccountsUtils.getCenter().getCustomerId(), transactionDate);
// assemble dto for saving collection sheet
SaveCollectionSheetDto saveCollectionSheet = saveCollectionSheetUtils.assembleSaveCollectionSheetDto(collectionSheet, transactionDate);
// close a savings account that is about to be saved
UserContext userContext = TestUtils.makeUser();
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());
StaticHibernateUtil.flushSession();
// Save collection sheet and test for errors returned
verifyInvalidReason(saveCollectionSheet, InvalidSaveCollectionSheetReason.INVALID_SAVINGS_ACCOUNT_STATUS);
}
Aggregations