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);
}
}
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);
}
Aggregations