Search in sources :

Example 1 with LoanDisbursalDto

use of org.mifos.dto.screen.LoanDisbursalDto in project head by mifos.

the class LoanAccountServiceFacadeWebTier method retrieveLoanDisbursalDetails.

@Override
public LoanDisbursalDto retrieveLoanDisbursalDetails(Integer loanAccountId) {
    try {
        LoanBO loan = this.loanDao.findById(loanAccountId);
        new ProductMixValidator().checkIfProductsOfferingCanCoexist(loan);
        Date proposedDate = new DateTimeService().getCurrentJavaDateTime();
        boolean backDatedTransactionsAllowed = AccountingRules.isBackDatedTxnAllowed();
        if (backDatedTransactionsAllowed) {
            proposedDate = loan.getDisbursementDate();
        }
        Short currencyId = Short.valueOf("0");
        boolean multiCurrencyEnabled = AccountingRules.isMultiCurrencyEnabled();
        if (multiCurrencyEnabled) {
            currencyId = loan.getCurrency().getCurrencyId();
        }
        boolean repaymentIndependentOfMeetingSchedule = configurationPersistence.isRepaymentIndepOfMeetingEnabled();
        return new LoanDisbursalDto(loan.getAccountId(), proposedDate, loan.getLoanAmount().toString(), loan.getAmountTobePaidAtdisburtail().toString(), backDatedTransactionsAllowed, repaymentIndependentOfMeetingSchedule, multiCurrencyEnabled, currencyId);
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    } catch (AccountException e) {
        throw new BusinessRuleException(e.getKey(), e.getValues());
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : ProductMixValidator(org.mifos.accounts.loan.struts.action.validate.ProductMixValidator) BusinessRuleException(org.mifos.service.BusinessRuleException) AccountException(org.mifos.accounts.exceptions.AccountException) ServiceException(org.mifos.framework.exceptions.ServiceException) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanDisbursalDto(org.mifos.dto.screen.LoanDisbursalDto) PersistenceException(org.mifos.framework.exceptions.PersistenceException) DateTimeService(org.mifos.framework.util.DateTimeService) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with LoanDisbursalDto

use of org.mifos.dto.screen.LoanDisbursalDto in project head by mifos.

the class LoanDisbursementAction method load.

@TransactionDemarcate(joinToken = true)
public ActionForward load(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
    LoanDisbursementActionForm loanDisbursementActionForm = (LoanDisbursementActionForm) form;
    loanDisbursementActionForm.clear();
    loanDisbursementActionForm.setAmountCannotBeZero(false);
    Integer loanAccountId = Integer.valueOf(loanDisbursementActionForm.getAccountId());
    LoanDisbursalDto loanDisbursalDto = loanAccountServiceFacade.retrieveLoanDisbursalDetails(loanAccountId);
    UserContext uc = getUserContext(request);
    SessionUtils.setAttribute(LoanConstants.PROPOSED_DISBURSAL_DATE, loanDisbursalDto.getProposedDate(), request);
    loanDisbursementActionForm.setTransactionDate(getUserLocaleDate(uc.getPreferredLocale(), loanDisbursalDto.getProposedDate()));
    loanDisbursementActionForm.setAmount(loanDisbursalDto.getAmountPaidAtDisbursement());
    loanDisbursementActionForm.setLoanAmount(loanDisbursalDto.getLoanAmount());
    if (loanDisbursalDto.isMultiCurrencyEnabled()) {
        loanDisbursementActionForm.setCurrencyId(loanDisbursalDto.getCurrencyId());
    }
    Short repaymentIndependentOfMeetingScheduleValue = loanDisbursalDto.isRepaymentIndependentOfMeetingSchedule() ? Short.valueOf("1") : Short.valueOf("0");
    SessionUtils.setAttribute(LoanConstants.REPAYMENT_SCHEDULES_INDEPENDENT_OF_MEETING_IS_ENABLED, repaymentIndependentOfMeetingScheduleValue, request);
    SessionUtils.setAttribute(AccountingRulesConstants.BACKDATED_TRANSACTIONS_ALLOWED, loanDisbursalDto.isBackDatedTransactionsAllowed(), request);
    List<PaymentTypeEntity> disbursementTypes = legacyAcceptedPaymentTypeDao.getAcceptedPaymentTypesForATransaction(uc.getLocaleId(), TrxnTypes.loan_disbursement.getValue());
    SessionUtils.setCollectionAttribute(MasterConstants.PAYMENT_TYPE, disbursementTypes, request);
    List<PaymentTypeEntity> feesTypes = legacyAcceptedPaymentTypeDao.getAcceptedPaymentTypesForATransaction(uc.getLocaleId(), TrxnTypes.loan_repayment.getValue());
    SessionUtils.setCollectionAttribute(MasterConstants.FEE_PAYMENT_TYPE, feesTypes, request);
    SessionUtils.setAttribute(LoanConstants.PAYMENT_TYPE_TRANSFER_FROM_SAVINGS_ID, legacyAcceptedPaymentTypeDao.getSavingsTransferId(), request);
    SessionUtils.setCollectionAttribute(Constants.ACCOUNTS_FOR_TRANSFER, accountServiceFacade.getActiveSavingsAccountsForClientByLoanId(loanAccountId), request);
    return mapping.findForward(Constants.LOAD_SUCCESS);
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) LoanDisbursementActionForm(org.mifos.accounts.loan.struts.actionforms.LoanDisbursementActionForm) UserContext(org.mifos.security.util.UserContext) LoanDisbursalDto(org.mifos.dto.screen.LoanDisbursalDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

LoanDisbursalDto (org.mifos.dto.screen.LoanDisbursalDto)2 Date (java.util.Date)1 LocalDate (org.joda.time.LocalDate)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 ProductMixValidator (org.mifos.accounts.loan.struts.action.validate.ProductMixValidator)1 LoanDisbursementActionForm (org.mifos.accounts.loan.struts.actionforms.LoanDisbursementActionForm)1 PaymentTypeEntity (org.mifos.application.master.business.PaymentTypeEntity)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1 ServiceException (org.mifos.framework.exceptions.ServiceException)1 DateTimeService (org.mifos.framework.util.DateTimeService)1 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)1 UserContext (org.mifos.security.util.UserContext)1 BusinessRuleException (org.mifos.service.BusinessRuleException)1