use of org.mifos.dto.domain.UserReferenceDto in project head by mifos.
the class StandardAccountServiceTest method testDisbursalAmountScaleDifferenceDoesNotMatter.
@Test
public void testDisbursalAmountScaleDifferenceDoesNotMatter() throws Exception {
when(mockLoanAccount.getLoanAmount()).thenReturn(new Money(TestUtils.EURO, "300"));
AccountPaymentParametersDto disbursal = new AccountPaymentParametersDto(new UserReferenceDto((short) 1), new AccountReferenceDto(1), new BigDecimal("300.0000000000000"), new LocalDate(), new PaymentTypeDto((short) 1, "CASH"), "");
List<InvalidPaymentReason> errors = new ArrayList<InvalidPaymentReason>();
standardAccountService.disbursalAmountMatchesFullLoanAmount(disbursal.getPaymentAmount(), errors, mockLoanAccount);
assertThat(errors.isEmpty(), is(true));
}
use of org.mifos.dto.domain.UserReferenceDto 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.UserReferenceDto in project head by mifos.
the class ImportTransactionsServiceFacadeWebTier method getInitializedImportPlugin.
private TransactionImport getInitializedImportPlugin(String importPluginClassname, Short userId) {
final TransactionImport ti = new PluginManager().getImportPlugin(importPluginClassname);
final UserReferenceDto userReferenceDTO = new UserReferenceDto(userId);
ti.setUserReferenceDto(userReferenceDTO);
return ti;
}
use of org.mifos.dto.domain.UserReferenceDto in project head by mifos.
the class AccountApplyGroupIndividualAction method load.
@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
UserContext userContext = getUserContext(request);
AccountApplyPaymentActionForm actionForm = (AccountApplyPaymentActionForm) form;
actionForm.setReceiptDate(null);
actionForm.setReceiptId(null);
actionForm.setPaymentTypeId(null);
actionForm.setTransactionDate(DateUtils.makeDateAsSentFromBrowser());
actionForm.setPrintReceipt(false);
actionForm.setTruePrintReceipt(false);
final AccountReferenceDto accountReferenceDto = new AccountReferenceDto(Integer.valueOf(actionForm.getAccountId()));
AccountPaymentDto accountPaymentDto = accountServiceFacade.getAccountPaymentInformation(accountReferenceDto.getAccountId(), request.getParameter(Constants.INPUT), userContext.getLocaleId(), new UserReferenceDto(userContext.getId()), DateUtils.getCurrentJavaDateTime());
setValuesInSession(request, actionForm, accountPaymentDto);
actionForm.setLastPaymentDate(accountPaymentDto.getLastPaymentDate());
actionForm.setAmount(accountPaymentDto.getTotalPaymentDue());
actionForm.setTransferPaymentTypeId(this.legacyAcceptedPaymentTypeDao.getSavingsTransferId());
return mapping.findForward(ActionForwards.load_success.toString());
}
use of org.mifos.dto.domain.UserReferenceDto in project head by mifos.
the class AccountApplyPaymentAction method load.
@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
UserContext userContext = getUserContext(request);
AccountApplyPaymentActionForm actionForm = (AccountApplyPaymentActionForm) form;
actionForm.setReceiptDate(null);
actionForm.setReceiptId(null);
actionForm.setPaymentTypeId(null);
actionForm.setTransactionDate(DateUtils.makeDateAsSentFromBrowser());
actionForm.setPrintReceipt(false);
actionForm.setTruePrintReceipt(false);
final AccountReferenceDto accountReferenceDto = new AccountReferenceDto(Integer.valueOf(actionForm.getAccountId()));
AccountPaymentDto accountPaymentDto = accountServiceFacade.getAccountPaymentInformation(accountReferenceDto.getAccountId(), request.getParameter(Constants.INPUT), userContext.getLocaleId(), new UserReferenceDto(userContext.getId()), DateUtils.getCurrentJavaDateTime());
setValuesInSession(request, actionForm, accountPaymentDto);
actionForm.setLastPaymentDate(accountPaymentDto.getLastPaymentDate());
actionForm.setAmount(accountPaymentDto.getTotalPaymentDue());
actionForm.setTransferPaymentTypeId(this.legacyAcceptedPaymentTypeDao.getSavingsTransferId());
return mapping.findForward(ActionForwards.load_success.toString());
}
Aggregations