Search in sources :

Example 11 with UserReferenceDto

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));
}
Also used : UserReferenceDto(org.mifos.dto.domain.UserReferenceDto) Money(org.mifos.framework.util.helpers.Money) AccountReferenceDto(org.mifos.dto.domain.AccountReferenceDto) ArrayList(java.util.ArrayList) AccountPaymentParametersDto(org.mifos.dto.domain.AccountPaymentParametersDto) PaymentTypeDto(org.mifos.dto.domain.PaymentTypeDto) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 12 with UserReferenceDto

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;
}
Also used : HashMap(java.util.HashMap) AccountReferenceDto(org.mifos.dto.domain.AccountReferenceDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) CustomerDto(org.mifos.dto.domain.CustomerDto) MifosUser(org.mifos.security.MifosUser) PaymentTypeDto(org.mifos.dto.domain.PaymentTypeDto) AccountPaymentParametersDto(org.mifos.dto.domain.AccountPaymentParametersDto) DateTime(org.joda.time.DateTime) UserReferenceDto(org.mifos.dto.domain.UserReferenceDto) Money(org.mifos.framework.util.helpers.Money) CustomerBO(org.mifos.customers.business.CustomerBO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 13 with UserReferenceDto

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;
}
Also used : PluginManager(org.mifos.framework.plugin.PluginManager) UserReferenceDto(org.mifos.dto.domain.UserReferenceDto) TransactionImport(org.mifos.accounts.api.TransactionImport)

Example 14 with UserReferenceDto

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());
}
Also used : UserReferenceDto(org.mifos.dto.domain.UserReferenceDto) UserContext(org.mifos.security.util.UserContext) AccountReferenceDto(org.mifos.dto.domain.AccountReferenceDto) AccountPaymentDto(org.mifos.accounts.servicefacade.AccountPaymentDto) AccountApplyPaymentActionForm(org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 15 with UserReferenceDto

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());
}
Also used : UserReferenceDto(org.mifos.dto.domain.UserReferenceDto) UserContext(org.mifos.security.util.UserContext) AccountReferenceDto(org.mifos.dto.domain.AccountReferenceDto) AccountPaymentDto(org.mifos.accounts.servicefacade.AccountPaymentDto) AccountApplyPaymentActionForm(org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

UserReferenceDto (org.mifos.dto.domain.UserReferenceDto)24 AccountReferenceDto (org.mifos.dto.domain.AccountReferenceDto)22 AccountPaymentParametersDto (org.mifos.dto.domain.AccountPaymentParametersDto)18 BigDecimal (java.math.BigDecimal)17 LocalDate (org.joda.time.LocalDate)15 Test (org.junit.Test)11 PaymentTypeDto (org.mifos.dto.domain.PaymentTypeDto)11 UserContext (org.mifos.security.util.UserContext)8 AccountPaymentDto (org.mifos.accounts.servicefacade.AccountPaymentDto)7 CustomerDto (org.mifos.dto.domain.CustomerDto)7 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)7 LoanBO (org.mifos.accounts.loan.business.LoanBO)6 AccountApplyPaymentActionForm (org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm)6 Money (org.mifos.framework.util.helpers.Money)6 CloseSession (org.mifos.framework.util.helpers.CloseSession)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 ActionForward (org.apache.struts.action.ActionForward)3 MifosUser (org.mifos.security.MifosUser)3 DateTime (org.joda.time.DateTime)2