use of org.mifos.dto.domain.CustomerDto in project head by mifos.
the class LoanAccountRESTController method disburseLoan.
@RequestMapping(value = "/account/loan/num-{globalAccountNum}/disburse", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> disburseLoan(@PathVariable String globalAccountNum, @RequestParam String disbursalDate, @RequestParam(required = false) Short receiptId, @RequestParam(required = false) String receiptDate, @RequestParam Short disbursePaymentTypeId, @RequestParam(required = false) Short paymentModeOfPayment) throws Exception {
String format = "dd-MM-yyyy";
DateTime trnxDate = validateDateString(disbursalDate, format);
validateDisbursementDate(trnxDate);
DateTime receiptDateTime = null;
if (receiptDate != null && !receiptDate.isEmpty()) {
receiptDateTime = validateDateString(receiptDate, format);
validateDisbursementDate(receiptDateTime);
}
validateDisbursementPaymentTypeId(disbursePaymentTypeId, accountService.getLoanDisbursementTypes());
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
LoanBO loan = loanDao.findByGlobalAccountNum(globalAccountNum);
String comment = "";
Short paymentTypeId = Short.valueOf(disbursePaymentTypeId);
Money outstandingBeforeDisbursement = loan.getLoanSummary().getOutstandingBalance();
CustomerDto customerDto = null;
PaymentTypeDto paymentType = null;
AccountPaymentParametersDto loanDisbursement;
if (receiptId == null || receiptDateTime == null) {
loanDisbursement = new AccountPaymentParametersDto(new UserReferenceDto((short) user.getUserId()), new AccountReferenceDto(loan.getAccountId()), loan.getLoanAmount().getAmount(), trnxDate.toLocalDate(), paymentType, comment);
} else {
loanDisbursement = new AccountPaymentParametersDto(new UserReferenceDto((short) user.getUserId()), new AccountReferenceDto(loan.getAccountId()), loan.getLoanAmount().getAmount(), trnxDate.toLocalDate(), paymentType, comment, receiptDateTime.toLocalDate(), receiptId.toString(), customerDto);
}
// TODO : Pass the account for transfer id properly
this.loanAccountServiceFacade.disburseLoan(loanDisbursement, paymentTypeId, PaymentTypes.CASH.getValue(), null);
CustomerBO client = loan.getCustomer();
Map<String, String> map = new HashMap<String, String>();
map.put("status", "success");
map.put("clientName", client.getDisplayName());
map.put("clientNumber", client.getGlobalCustNum());
map.put("loanDisplayName", loan.getLoanOffering().getPrdOfferingName());
map.put("disbursementDate", trnxDate.toLocalDate().toString());
map.put("disbursementTime", new DateTime().toLocalTime().toString());
map.put("disbursementAmount", loan.getLastPmnt().getAmount().toString());
map.put("disbursementMadeBy", personnelDao.findPersonnelById((short) user.getUserId()).getDisplayName());
map.put("outstandingBeforeDisbursement", outstandingBeforeDisbursement.toString());
map.put("outstandingAfterDisbursement", loan.getLoanSummary().getOutstandingBalance().toString());
return map;
}
use of org.mifos.dto.domain.CustomerDto in project head by mifos.
the class CustomerViewTest method testCustomerView.
public void testCustomerView() throws Exception {
CustomerDto customerDto = new CustomerDto(Integer.valueOf("1"), "Customer", "001global", Short.valueOf("2"));
Assert.assertEquals(1, customerDto.getCustomerId().intValue());
Assert.assertEquals("Customer", customerDto.getDisplayName());
Assert.assertEquals("001global", customerDto.getGlobalCustNum());
Assert.assertEquals(2, customerDto.getStatusId().shortValue());
CustomerDto customerView1 = new CustomerDto(Integer.valueOf("1"), "Customer", "001global", Short.valueOf("2"), Short.valueOf("2"), Integer.valueOf("1"), Short.valueOf("2"), Short.valueOf("3"));
Assert.assertEquals(2, customerView1.getCustomerLevelId().shortValue());
Assert.assertEquals(2, customerView1.getOfficeId().shortValue());
Assert.assertEquals(3, customerView1.getPersonnelId().shortValue());
Assert.assertEquals(1, customerView1.getVersionNo().intValue());
}
use of org.mifos.dto.domain.CustomerDto in project head by mifos.
the class CustomerStatusUpdateTest method throwsCheckedExceptionWhenCenterTransitionsToInActiveStateAndCenterHasActiveGroups.
@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenCenterTransitionsToInActiveStateAndCenterHasActiveGroups() 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);
when(customerDao.findGroupsThatAreNotCancelledOrClosed(existingCenter.getSearchId(), existingCenter.getOffice().getOfficeId())).thenReturn(clientsThatAreNotCancelledOrClosed);
// exercise test
customerService.updateCustomerStatus(userContext, customerStatusUpdate);
// verification
verify(messageLookupHelper).lookupLabel(ConfigurationConstants.GROUP);
}
use of org.mifos.dto.domain.CustomerDto in project head by mifos.
the class CustomerStatusUpdateTest method throwsCheckedExceptionWhenCenterTransitionsToInActiveStateAndCenterHasActiveClients.
@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenCenterTransitionsToInActiveStateAndCenterHasActiveClients() 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);
when(customerDao.findClientsThatAreNotCancelledOrClosed(existingCenter.getSearchId(), existingCenter.getOffice().getOfficeId())).thenReturn(clientsThatAreNotCancelledOrClosed);
// exercise test
customerService.updateCustomerStatus(userContext, customerStatusUpdate);
// verification
verify(messageLookupHelper).lookupLabel(ConfigurationConstants.GROUP);
}
use of org.mifos.dto.domain.CustomerDto in project head by mifos.
the class CreateSavingsAccountController method customerSelected.
public void customerSelected(Integer customerId, CreateSavingsAccountFormBean formBean) {
CustomerDto customer = savingsServiceFacade.retreieveCustomerDetails(customerId);
formBean.setCustomer(customer);
}
Aggregations