use of org.mifos.dto.domain.UserReferenceDto in project head by mifos.
the class StandardAccountServiceTest method testMakeLoanPayment.
@Ignore
@Test
public void testMakeLoanPayment() throws Exception {
short userId = 1;
int accountId = 100;
int customerId = 1;
UserReferenceDto userMakingPayment = new UserReferenceDto(userId);
AccountReferenceDto loanAccount = new AccountReferenceDto(accountId);
BigDecimal paymentAmount = new BigDecimal("100");
LocalDate paymentDate = new LocalDate(2009, 10, 1);
String comment = "some comment";
java.sql.Date lastMeetingDate = new java.sql.Date(paymentDate.minusWeeks(3).toDateMidnight().getMillis());
when(customerBO.getCustomerId()).thenReturn(customerId);
when(legacyAccountDao.getAccount(accountId)).thenReturn(accountBO);
// when(accountBO.isTrxnDateValid(paymentDate.toDateMidnight().toDate())).thenReturn(true);
when(configurationPersistence.isRepaymentIndepOfMeetingEnabled()).thenReturn(false);
when(customerPersistence.getLastMeetingDateForCustomer(anyInt())).thenReturn(lastMeetingDate);
when(personnelPersistence.getPersonnel(anyShort())).thenReturn(personnelBO);
// FIXME - work in progress Vanmh
// standardLoanAccountService.makeLoanPayment(new AccountPaymentParametersDTO(userMakingPayment, loanAccount,
// paymentAmount, paymentDate, PaymentTypeDTO.CASH, comment));
}
use of org.mifos.dto.domain.UserReferenceDto in project head by mifos.
the class StandardAccountServiceTest method testDisbursalAmountMustMatchFullLoanAmount.
@Test
public void testDisbursalAmountMustMatchFullLoanAmount() throws Exception {
when(mockLoanAccount.getLoanAmount()).thenReturn(new Money(TestUtils.EURO, "300"));
AccountPaymentParametersDto disbursal = new AccountPaymentParametersDto(new UserReferenceDto((short) 1), new AccountReferenceDto(1), new BigDecimal("299"), new LocalDate(), new PaymentTypeDto((short) 1, "CASH"), "");
List<InvalidPaymentReason> errors = new ArrayList<InvalidPaymentReason>();
standardAccountService.disbursalAmountMatchesFullLoanAmount(disbursal.getPaymentAmount(), errors, mockLoanAccount);
assertThat(errors.get(0), is(InvalidPaymentReason.INVALID_LOAN_DISBURSAL_AMOUNT));
}
use of org.mifos.dto.domain.UserReferenceDto 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();
}
use of org.mifos.dto.domain.UserReferenceDto in project head by mifos.
the class LoanAccountRESTController method repay.
@RequestMapping(value = "/account/loan/num-{globalAccountNum}/repay", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> repay(@PathVariable String globalAccountNum, @RequestParam BigDecimal amount, @RequestParam(required = false) String paymentDate, @RequestParam(required = false) Short receiptId, @RequestParam(required = false) String receiptDate, @RequestParam(required = false) Short paymentModeId) throws Exception {
validateAmount(amount);
LoanBO loan = loanDao.findByGlobalAccountNum(globalAccountNum);
validateLoanAccountState(loan);
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserReferenceDto userDto = new UserReferenceDto((short) user.getUserId());
Money outstandingBeforePayment = loan.getLoanSummary().getOutstandingBalance();
AccountReferenceDto accountDto = new AccountReferenceDto(loan.getAccountId());
DateTime today = new DateTime();
DateTime paymentDateTime = today;
if (paymentDate != null && !paymentDate.isEmpty()) {
paymentDateTime = validateDateString(paymentDate, format);
}
String receiptIdString = null;
if (receiptId != null) {
receiptIdString = receiptId.toString();
}
LocalDate receiptLocalDate = null;
if (receiptDate != null && !receiptDate.isEmpty()) {
receiptLocalDate = validateDateString(receiptDate, format).toLocalDate();
}
PaymentTypeDto paymentType = new PaymentTypeDto(paymentModeId, "");
validatePaymentTypeId(paymentType, accountService.getLoanPaymentTypes());
CustomerBO client = loan.getCustomer();
CustomerDto customer = new CustomerDto();
customer.setCustomerId(client.getCustomerId());
AccountPaymentParametersDto payment = new AccountPaymentParametersDto(userDto, accountDto, amount, paymentDateTime.toLocalDate(), paymentType, globalAccountNum, receiptLocalDate, receiptIdString, customer);
accountService.makePayment(payment);
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("paymentDate", today.toLocalDate().toString());
map.put("paymentTime", today.toLocalTime().toString());
map.put("paymentAmount", loan.getLastPmnt().getAmount().toString());
map.put("paymentMadeBy", personnelDao.findPersonnelById((short) user.getUserId()).getDisplayName());
map.put("outstandingBeforePayment", outstandingBeforePayment.toString());
map.put("outstandingAfterPayment", loan.getLoanSummary().getOutstandingBalance().toString());
return map;
}
Aggregations