Search in sources :

Example 6 with LoanAccountDetailsDto

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

the class LoanAccountActionForm method validateSumOfTheAmountsSpecified.

void validateSumOfTheAmountsSpecified(ActionErrors errors) {
    List<String> ids_clients_selected = getClients();
    double totalAmount = new Double(0);
    boolean foundInvalidAmount = false;
    for (LoanAccountDetailsDto loanDetail : getClientDetails()) {
        if (!foundInvalidAmount) {
            if (ids_clients_selected.contains(loanDetail.getClientId())) {
                if (isAmountZeroOrNull(loanDetail.getLoanAmount())) {
                    addError(errors, LoanExceptionConstants.CUSTOMER_LOAN_AMOUNT_FIELD);
                    foundInvalidAmount = true;
                } else {
                    totalAmount = totalAmount + new LocalizationConverter().getDoubleValueForCurrentLocale(loanDetail.getLoanAmount());
                }
            }
        }
    }
    if (!foundInvalidAmount && (StringUtils.isBlank(Double.valueOf(totalAmount).toString()) || !amountRange.isInRange(totalAmount))) {
        addError(errors, LoanConstants.LOANAMOUNT, LoanExceptionConstants.SUM_OF_INDIVIDUAL_AMOUNTS_IS_NOT_IN_THE_RANGE_OF_ALLOWED_AMOUNTS, getStringValue(amountRange.getMinLoanAmount()), getStringValue(amountRange.getMaxLoanAmount()));
    }
}
Also used : LocalizationConverter(org.mifos.framework.util.LocalizationConverter) LoanAccountDetailsDto(org.mifos.dto.domain.LoanAccountDetailsDto)

Example 7 with LoanAccountDetailsDto

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

the class LoanAccountActionStrutsTest method testShouldPopulateClientDetailsFromLoan.

@Test
public void testShouldPopulateClientDetailsFromLoan() throws Exception {
    ClientBO clientMock1 = createMock(ClientBO.class);
    expect(clientMock1.getCustomerId()).andReturn(1).anyTimes();
    expect(clientMock1.getDisplayName()).andReturn("client 1");
    ClientBO clientMock2 = createMock(ClientBO.class);
    expect(clientMock2.getCustomerId()).andReturn(2).anyTimes();
    expect(clientMock2.getDisplayName()).andReturn("client 2");
    LoanBO loanMock = createMock(LoanBO.class);
    expect(loanMock.getCustomer()).andReturn(clientMock1).anyTimes();
    expect(loanMock.getBusinessActivityId()).andReturn(3);
    expect(loanMock.getLoanAmount()).andReturn(new Money(getCurrency(), "100")).anyTimes();
    LoanAccountDetailsDto clientDetails1 = new LoanAccountDetailsDto();
    clientDetails1.setClientId("1");
    clientDetails1.setClientName("client 1");
    clientDetails1.setBusinessActivity("3");
    clientDetails1.setLoanAmount("100.0");
    LoanAccountDetailsDto clientDetails2 = new LoanAccountDetailsDto();
    clientDetails2.setClientId("2");
    clientDetails2.setClientName("client 2");
    replay(clientMock1, clientMock2, loanMock);
    List<LoanAccountDetailsDto> clientDetails = new LoanAccountAction().populateClientDetailsFromLoan(Arrays.asList(clientMock1, clientMock2), Arrays.asList(loanMock), new ArrayList<ValueListElement>());
    Assert.assertEquals(Arrays.asList(clientDetails1, clientDetails2), clientDetails);
    verify(clientMock1, clientMock2, loanMock);
}
Also used : Money(org.mifos.framework.util.helpers.Money) ClientBO(org.mifos.customers.client.business.ClientBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanAccountDetailsDto(org.mifos.dto.domain.LoanAccountDetailsDto) ValueListElement(org.mifos.dto.domain.ValueListElement) Test(org.junit.Test)

Example 8 with LoanAccountDetailsDto

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

the class LoanAccountActionIndividualLoansIntegrationTest method testShouldCallDeleteMethodIfExistingMembersRemoved.

@Test
public void testShouldCallDeleteMethodIfExistingMembersRemoved() throws Exception {
    GlimLoanUpdater glimLoanUpdaterMock = createMock(GlimLoanUpdater.class);
    LoanAccountAction loanAccountAction = new LoanAccountAction(ApplicationContextProvider.getBean(LoanBusinessService.class), new ConfigurationBusinessService(), glimLoanUpdaterMock);
    LoanBO loanMock = createMock(LoanBO.class);
    Locale locale = Locale.ENGLISH;
    expect(loanMock.getAccountId()).andReturn(2).anyTimes();
    ClientBO customerMock = createMock(ClientBO.class);
    expect(loanMock.getCustomer()).andReturn(customerMock).anyTimes();
    expect(customerMock.getGlobalCustNum()).andReturn("3").anyTimes();
    LoanAccountActionForm loanAccountActionForm = new LoanAccountActionForm();
    List<LoanAccountDetailsDto> clientDetails = new ArrayList<LoanAccountDetailsDto>();
    List<LoanBO> loans = new ArrayList<LoanBO>();
    loans.add(loanMock);
    glimLoanUpdaterMock.delete(loanMock);
    expectLastCall().atLeastOnce();
    replay(glimLoanUpdaterMock, loanMock, customerMock);
    loanAccountAction.handleIndividualLoans(loanMock, loanAccountActionForm, true, clientDetails, loans, locale);
    verify(glimLoanUpdaterMock, loanMock, customerMock);
}
Also used : Locale(java.util.Locale) LoanAccountActionForm(org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm) LoanBusinessService(org.mifos.accounts.loan.business.service.LoanBusinessService) LoanBO(org.mifos.accounts.loan.business.LoanBO) ClientBO(org.mifos.customers.client.business.ClientBO) ConfigurationBusinessService(org.mifos.config.business.service.ConfigurationBusinessService) ArrayList(java.util.ArrayList) LoanAccountDetailsDto(org.mifos.dto.domain.LoanAccountDetailsDto) Test(org.junit.Test)

Example 9 with LoanAccountDetailsDto

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

the class LoanAccountActionIndividualLoansIntegrationTest method testShouldCallUpdateMethodIfExistingMembersChanged.

@Test
public void testShouldCallUpdateMethodIfExistingMembersChanged() throws Exception {
    GlimLoanUpdater glimLoanUpdaterMock = createMock(GlimLoanUpdater.class);
    LoanAccountAction loanAccountAction = new LoanAccountAction(ApplicationContextProvider.getBean(LoanBusinessService.class), new ConfigurationBusinessService(), glimLoanUpdaterMock);
    LoanBO loanMock = createMock(LoanBO.class);
    Locale locale = Locale.ENGLISH;
    expect(loanMock.getAccountId()).andReturn(2).anyTimes();
    ClientBO customerMock = createMock(ClientBO.class);
    expect(loanMock.getCustomer()).andReturn(customerMock).anyTimes();
    expect(customerMock.getCustomerId()).andReturn(3).anyTimes();
    LoanAccountActionForm loanAccountActionForm = new LoanAccountActionForm();
    List<LoanAccountDetailsDto> clientDetails = new ArrayList<LoanAccountDetailsDto>();
    LoanAccountDetailsDto LOAN_ACCOUNT_DETAILS_WITH_LOAN_AMOUNT_300 = LoanAccountDetailsDto.createInstanceForTest("3", "2", "300.0", "2");
    clientDetails.add(LOAN_ACCOUNT_DETAILS_WITH_LOAN_AMOUNT_300);
    List<LoanBO> loans = new ArrayList<LoanBO>();
    loans.add(loanMock);
    glimLoanUpdaterMock.updateIndividualLoan(null, null, null, LOAN_ACCOUNT_DETAILS_WITH_LOAN_AMOUNT_300, loanMock);
    expectLastCall().atLeastOnce();
    replay(glimLoanUpdaterMock, loanMock, customerMock);
    loanAccountAction.handleIndividualLoans(loanMock, loanAccountActionForm, true, clientDetails, loans, locale);
    verify(glimLoanUpdaterMock, loanMock, customerMock);
}
Also used : Locale(java.util.Locale) LoanAccountActionForm(org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm) LoanBusinessService(org.mifos.accounts.loan.business.service.LoanBusinessService) LoanBO(org.mifos.accounts.loan.business.LoanBO) ClientBO(org.mifos.customers.client.business.ClientBO) ConfigurationBusinessService(org.mifos.config.business.service.ConfigurationBusinessService) ArrayList(java.util.ArrayList) LoanAccountDetailsDto(org.mifos.dto.domain.LoanAccountDetailsDto) Test(org.junit.Test)

Example 10 with LoanAccountDetailsDto

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

the class LoanAccountAction method populateDetailsForSelectedClients.

private List<LoanAccountDetailsDto> populateDetailsForSelectedClients(final List<LoanAccountDetailsDto> clientDetails, final List<String> selectedClients) {
    List<LoanAccountDetailsDto> loanAccountDetailsView = new ArrayList<LoanAccountDetailsDto>();
    for (final String clientId : selectedClients) {
        if (StringUtils.isNotEmpty(clientId)) {
            LoanAccountDetailsDto matchingClientDetail = (LoanAccountDetailsDto) CollectionUtils.find(clientDetails, new Predicate() {

                @Override
                public boolean evaluate(final Object object) {
                    return ((LoanAccountDetailsDto) object).getClientId().equals(clientId);
                }
            });
            if (matchingClientDetail != null) {
                setGovernmentIdAndPurpose(matchingClientDetail);
                loanAccountDetailsView.add(matchingClientDetail);
            }
        }
    }
    return loanAccountDetailsView;
}
Also used : ArrayList(java.util.ArrayList) LoanAccountDetailsDto(org.mifos.dto.domain.LoanAccountDetailsDto) Predicate(org.apache.commons.collections.Predicate)

Aggregations

LoanAccountDetailsDto (org.mifos.dto.domain.LoanAccountDetailsDto)24 ArrayList (java.util.ArrayList)13 LoanBO (org.mifos.accounts.loan.business.LoanBO)11 ClientBO (org.mifos.customers.client.business.ClientBO)8 ValueListElement (org.mifos.dto.domain.ValueListElement)8 LoanAccountActionForm (org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm)6 CustomerBO (org.mifos.customers.business.CustomerBO)5 MultipleLoanAccountDetailsDto (org.mifos.dto.screen.MultipleLoanAccountDetailsDto)5 MessageLookup (org.mifos.application.master.MessageLookup)4 MifosRuntimeException (org.mifos.core.MifosRuntimeException)4 LoanActivityDto (org.mifos.dto.domain.LoanActivityDto)4 LoanInformationDto (org.mifos.dto.screen.LoanInformationDto)4 HashSet (java.util.HashSet)3 Predicate (org.apache.commons.collections.Predicate)3 LocalDate (org.joda.time.LocalDate)3 Test (org.junit.Test)3 ConfigurationBusinessService (org.mifos.config.business.service.ConfigurationBusinessService)3 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)3 Locale (java.util.Locale)2 LoanBusinessService (org.mifos.accounts.loan.business.service.LoanBusinessService)2