@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);

    return mapping.findForward(Constants.LOAD_SUCCESS);
  }
Esempio n. 2
0
  @Override
  public CenterDto retrieveCenterDetailsForUpdate(Integer centerId) {

    MifosUser user =
        (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);

    CustomerBO center = customerDao.findCustomerById(centerId);

    Short officeId = center.getOffice().getOfficeId();
    String searchId = center.getSearchId();
    Short loanOfficerId = extractLoanOfficerId(center);

    CenterCreation centerCreation =
        new CenterCreation(
            officeId,
            userContext.getId(),
            userContext.getLevelId(),
            userContext.getPreferredLocale());
    List<PersonnelDto> activeLoanOfficersForBranch =
        personnelDao.findActiveLoanOfficersForOffice(centerCreation);

    List<CustomerDto> customerList =
        customerDao.findClientsThatAreNotCancelledOrClosed(searchId, officeId);

    List<CustomerPositionDto> customerPositionDtos =
        generateCustomerPositionViews(center, userContext.getLocaleId());

    DateTime mfiJoiningDate = new DateTime();
    String mfiJoiningDateAsString = "";
    if (center.getMfiJoiningDate() != null) {
      mfiJoiningDate = new DateTime(center.getMfiJoiningDate());
      mfiJoiningDateAsString =
          DateUtils.getUserLocaleDate(
              userContext.getPreferredLocale(), center.getMfiJoiningDate().toString());
    }

    AddressDto address = null;
    if (center.getAddress() != null) {
      address = Address.toDto(center.getAddress());
    }
    return new CenterDto(
        loanOfficerId,
        center.getCustomerId(),
        center.getGlobalCustNum(),
        mfiJoiningDate,
        mfiJoiningDateAsString,
        center.getExternalId(),
        address,
        customerPositionDtos,
        customerList,
        activeLoanOfficersForBranch,
        true);
  }