Search in sources :

Example 6 with CustomerNoteDto

use of org.mifos.dto.domain.CustomerNoteDto 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;
}
Also used : SearchDetailsDto(org.mifos.dto.screen.SearchDetailsDto) CustomerNoteDto(org.mifos.dto.domain.CustomerNoteDto) ArrayList(java.util.ArrayList) AccountNotesEntity(org.mifos.accounts.business.AccountNotesEntity) NotesSearchResultsDto(org.mifos.dto.screen.NotesSearchResultsDto) Criteria(org.hibernate.Criteria) Session(org.hibernate.Session)

Example 7 with CustomerNoteDto

use of org.mifos.dto.domain.CustomerNoteDto 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());
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) CustomerNoteDto(org.mifos.dto.domain.CustomerNoteDto) ArrayList(java.util.ArrayList) SavingsRecentActivityDto(org.mifos.dto.screen.SavingsRecentActivityDto) AccountNotesEntity(org.mifos.accounts.business.AccountNotesEntity) SavingsPerformanceHistoryDto(org.mifos.dto.domain.SavingsPerformanceHistoryDto) SavingsAccountDetailDto(org.mifos.dto.domain.SavingsAccountDetailDto)

Example 8 with CustomerNoteDto

use of org.mifos.dto.domain.CustomerNoteDto in project head by mifos.

the class CustomerDaoHibernate method getRecentCustomerNoteDto.

@Override
public List<CustomerNoteDto> getRecentCustomerNoteDto(Integer customerId) {
    Integer recent = 3;
    List<CustomerNoteDto> customerNotes = getCustomerNoteDto(customerId);
    if (customerNotes == null) {
        return null;
    }
    if (customerNotes.size() < (recent + 1)) {
        return customerNotes;
    }
    List<CustomerNoteDto> recentCustomerNotes = new ArrayList<CustomerNoteDto>(recent);
    for (int i = 0; i < recent; i++) {
        recentCustomerNotes.add(customerNotes.get(i));
    }
    return recentCustomerNotes;
}
Also used : BigInteger(java.math.BigInteger) CustomerNoteDto(org.mifos.dto.domain.CustomerNoteDto) ArrayList(java.util.ArrayList)

Example 9 with CustomerNoteDto

use of org.mifos.dto.domain.CustomerNoteDto in project head by mifos.

the class CustomerDaoHibernate method getCustomerNoteDto.

@SuppressWarnings("unchecked")
private List<CustomerNoteDto> getCustomerNoteDto(Integer customerId) {
    Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("CUSTOMER_ID", customerId);
    List<Object[]> queryResult = (List<Object[]>) this.genericDao.executeNamedQuery("Customer.getCustomerNoteDto", queryParameters);
    if (queryResult.size() == 0) {
        return null;
    }
    List<CustomerNoteDto> customerNotes = new ArrayList<CustomerNoteDto>();
    Date commentDate;
    String comment;
    String personnelName;
    for (Object[] customerNote : queryResult) {
        commentDate = (Date) customerNote[0];
        comment = (String) customerNote[1];
        personnelName = (String) customerNote[2];
        customerNotes.add(new CustomerNoteDto(commentDate, comment, personnelName));
    }
    return customerNotes;
}
Also used : HashMap(java.util.HashMap) CustomerNoteDto(org.mifos.dto.domain.CustomerNoteDto) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Date(java.util.Date)

Aggregations

ArrayList (java.util.ArrayList)9 CustomerNoteDto (org.mifos.dto.domain.CustomerNoteDto)9 AccountException (org.mifos.accounts.exceptions.AccountException)5 MifosRuntimeException (org.mifos.core.MifosRuntimeException)5 SurveyDto (org.mifos.dto.domain.SurveyDto)5 MifosUser (org.mifos.security.MifosUser)5 UserContext (org.mifos.security.util.UserContext)5 AccountNotesEntity (org.mifos.accounts.business.AccountNotesEntity)4 LoanBO (org.mifos.accounts.loan.business.LoanBO)4 AccountBO (org.mifos.accounts.business.AccountBO)3 CustomerAccountSummaryDto (org.mifos.dto.domain.CustomerAccountSummaryDto)3 CustomerAddressDto (org.mifos.dto.domain.CustomerAddressDto)3 CustomerMeetingDto (org.mifos.dto.domain.CustomerMeetingDto)3 SavingsDetailDto (org.mifos.dto.domain.SavingsDetailDto)3 HashSet (java.util.HashSet)2 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)2 AccountPenaltiesEntity (org.mifos.accounts.business.AccountPenaltiesEntity)2 LoanPerformanceHistoryEntity (org.mifos.accounts.loan.business.LoanPerformanceHistoryEntity)2 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)2 CustomValueDto (org.mifos.application.master.business.CustomValueDto)2