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()));
}
}
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);
}
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);
}
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);
}
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;
}
Aggregations