Search in sources :

Example 31 with CustomerDto

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

the class BulkEntryActionStrutsTest method createDefaultCollectionSheetDto.

private CollectionSheetEntryFormDto createDefaultCollectionSheetDto() {
    List<OfficeDetailsDto> activeBranches = new ArrayList<OfficeDetailsDto>();
    List<ListItem<Short>> paymentTypesDtoList = new ArrayList<ListItem<Short>>();
    List<CustomerDto> customerList = new ArrayList<CustomerDto>();
    List<PersonnelDto> loanOfficerList = new ArrayList<PersonnelDto>();
    final Short reloadFormAutomatically = Constants.YES;
    final Short backDatedTransactionAllowed = Constants.NO;
    final Short centerHierarchyExists = Constants.YES;
    final Date meetingDate = new Date();
    return new CollectionSheetEntryFormDto(activeBranches, paymentTypesDtoList, loanOfficerList, customerList, reloadFormAutomatically, centerHierarchyExists, backDatedTransactionAllowed, meetingDate);
}
Also used : ArrayList(java.util.ArrayList) CustomerDto(org.mifos.dto.domain.CustomerDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) ListItem(org.mifos.application.servicefacade.ListItem) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) Date(java.util.Date) CollectionSheetEntryFormDto(org.mifos.application.servicefacade.CollectionSheetEntryFormDto)

Example 32 with CustomerDto

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

the class BulkEntryActionStrutsTest method getCusomerView.

private CustomerDto getCusomerView(final CustomerBO customer) {
    CustomerDto customerDto = new CustomerDto();
    customerDto.setCustomerId(customer.getCustomerId());
    customerDto.setCustomerLevelId(customer.getCustomerLevel().getId());
    customerDto.setCustomerSearchId(customer.getSearchId());
    customerDto.setDisplayName(customer.getDisplayName());
    customerDto.setGlobalCustNum(customer.getGlobalCustNum());
    customerDto.setOfficeId(customer.getOffice().getOfficeId());
    if (null != customer.getParentCustomer()) {
        customerDto.setParentCustomerId(customer.getParentCustomer().getCustomerId());
    }
    customerDto.setPersonnelId(customer.getPersonnel().getPersonnelId());
    customerDto.setStatusId(customer.getCustomerStatus().getId());
    return customerDto;
}
Also used : CustomerDto(org.mifos.dto.domain.CustomerDto)

Example 33 with CustomerDto

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

the class BulkEntryActionStrutsTest method setMasterListInSession.

private void setMasterListInSession(final Integer customerId) throws PageExpiredException {
    OfficeDetailsDto office = new OfficeDetailsDto(Short.valueOf("3"), "Branch", OfficeConstants.BRANCHOFFICE, Integer.valueOf("0"));
    List<OfficeDetailsDto> branchOfficesList = new ArrayList<OfficeDetailsDto>();
    branchOfficesList.add(office);
    SessionUtils.setCollectionAttribute(OfficeConstants.OFFICESBRANCHOFFICESLIST, branchOfficesList, request);
    PersonnelDto personnel = new PersonnelDto(Short.valueOf("3"), "John");
    List<PersonnelDto> personnelList = new ArrayList<PersonnelDto>();
    personnelList.add(personnel);
    SessionUtils.setCollectionAttribute(CustomerConstants.LOAN_OFFICER_LIST, personnelList, request);
    CustomerDto parentCustomer = new CustomerDto(customerId, "Center_Active", Short.valueOf(CustomerLevel.CENTER.getValue()), "1.1");
    List<CustomerDto> customerList = new ArrayList<CustomerDto>();
    customerList.add(parentCustomer);
    SessionUtils.setCollectionAttribute(CollectionSheetEntryConstants.CUSTOMERSLIST, customerList, request);
}
Also used : ArrayList(java.util.ArrayList) CustomerDto(org.mifos.dto.domain.CustomerDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto)

Example 34 with CustomerDto

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

the class CustomerStatusUpdateTest method rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs.

@Test(expected = MifosRuntimeException.class)
public void rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs() throws Exception {
    // setup
    UserContext userContext = TestUtils.makeUser();
    CustomerStatusUpdate customerStatusUpdate = new CustomerStatusUpdateBuilder().with(CustomerStatus.CENTER_INACTIVE).build();
    CenterBO existingCenter = new CenterBuilder().withVersion(customerStatusUpdate.getVersionNum()).active().build();
    CustomerDto customer1 = new CustomerDto();
    List<CustomerDto> clientsThatAreNotCancelledOrClosed = new ArrayList<CustomerDto>();
    clientsThatAreNotCancelledOrClosed.add(customer1);
    // stubbing
    when(customerDao.findCustomerById(customerStatusUpdate.getCustomerId())).thenReturn(existingCenter);
    doThrow(new RuntimeException()).when(customerDao).save(existingCenter);
    // exercise test
    customerService.updateCustomerStatus(userContext, customerStatusUpdate);
    // verification
    verify(hibernateTransaction).rollbackTransaction();
    verify(hibernateTransaction).closeSession();
}
Also used : CustomerStatusUpdate(org.mifos.application.servicefacade.CustomerStatusUpdate) MifosRuntimeException(org.mifos.core.MifosRuntimeException) UserContext(org.mifos.security.util.UserContext) CustomerDto(org.mifos.dto.domain.CustomerDto) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) CustomerStatusUpdateBuilder(org.mifos.domain.builders.CustomerStatusUpdateBuilder) Test(org.junit.Test)

Example 35 with CustomerDto

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

the class K2RESTController method processLoanPayment.

private Map<String, String> processLoanPayment(LoanBO loanBO, String k2TransactionId, String acNo, String mmSystemId, LocalDate transactionDate, BigDecimal amount, String currency) throws Exception {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserReferenceDto userDto = new UserReferenceDto((short) user.getUserId());
    AccountReferenceDto accountReferenceDto = new AccountReferenceDto(loanBO.getAccountId());
    PaymentTypeDto paymentTypeDto = null;
    List<PaymentTypeDto> loanPaymentTypes = accountService.getLoanPaymentTypes();
    for (PaymentTypeDto paymentTypeDtoIterator : loanPaymentTypes) {
        if (paymentTypeDtoIterator.getName().equals(mmSystemId)) {
            paymentTypeDto = paymentTypeDtoIterator;
            break;
        }
    }
    if (paymentTypeDto == null || !loanBO.getCurrency().getCurrencyCode().equals(currency)) {
        return invalidPayment();
    }
    CustomerDto customerDto = loanBO.getCustomer().toCustomerDto();
    LocalDate receiptLocalDate = transactionDate;
    String receiptIdString = k2TransactionId;
    AccountPaymentParametersDto payment = new AccountPaymentParametersDto(userDto, accountReferenceDto, amount, transactionDate, paymentTypeDto, acNo, receiptLocalDate, receiptIdString, customerDto);
    accountService.makePayment(payment);
    return accepted();
}
Also used : UserReferenceDto(org.mifos.dto.domain.UserReferenceDto) AccountReferenceDto(org.mifos.dto.domain.AccountReferenceDto) CustomerDto(org.mifos.dto.domain.CustomerDto) MifosUser(org.mifos.security.MifosUser) PaymentTypeDto(org.mifos.dto.domain.PaymentTypeDto) AccountPaymentParametersDto(org.mifos.dto.domain.AccountPaymentParametersDto) LocalDate(org.joda.time.LocalDate)

Aggregations

CustomerDto (org.mifos.dto.domain.CustomerDto)38 ArrayList (java.util.ArrayList)15 PersonnelDto (org.mifos.dto.domain.PersonnelDto)12 Test (org.junit.Test)11 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)10 MifosRuntimeException (org.mifos.core.MifosRuntimeException)7 UserReferenceDto (org.mifos.dto.domain.UserReferenceDto)7 DateTime (org.joda.time.DateTime)6 CustomerBO (org.mifos.customers.business.CustomerBO)6 AccountPaymentParametersDto (org.mifos.dto.domain.AccountPaymentParametersDto)6 AccountReferenceDto (org.mifos.dto.domain.AccountReferenceDto)6 MifosUser (org.mifos.security.MifosUser)6 UserContext (org.mifos.security.util.UserContext)6 Date (java.util.Date)5 LocalDate (org.joda.time.LocalDate)5 Money (org.mifos.framework.util.helpers.Money)5 HashMap (java.util.HashMap)4 LoanBO (org.mifos.accounts.loan.business.LoanBO)4 PaymentTypeDto (org.mifos.dto.domain.PaymentTypeDto)4 BigDecimal (java.math.BigDecimal)3