Пример #1
0
  private void validateRTGS() {
    EntityType entity = null;
    List<ValidationError> errors = new ArrayList<ValidationError>();
    for (EgAdvanceRequisitionDetails advanceDetail :
        advanceRequisition.getEgAdvanceReqDetailses()) {
      if (!advanceDetail.getEgAdvanceReqpayeeDetailses().isEmpty()) {
        for (EgAdvanceReqPayeeDetails payeeDetail : advanceDetail.getEgAdvanceReqpayeeDetailses()) {
          try {
            entity =
                paymentService.getEntity(
                    payeeDetail.getAccountDetailType().getId(),
                    (Serializable) payeeDetail.getAccountdetailKeyId());
            if (entity == null) {
              throw new ValidationException(
                  Arrays.asList(
                      new ValidationError(
                          "no.entity.for.detailkey",
                          getText(
                              "no.entity.for.detailkey",
                              new String[] {entity.getCode() + "-" + entity.getName()}))));
            }
          } catch (ApplicationException e) {
            throw new ValidationException(
                Arrays.asList(
                    new ValidationError("Exception to get EntityType  ", e.getMessage())));
          }

          if ((StringUtils.isBlank(entity.getPanno())
              || StringUtils.isBlank(entity.getBankname())
              || StringUtils.isBlank(entity.getBankaccount())
              || StringUtils.isBlank(entity.getIfsccode()))) {
            populateBankAccounts(
                Integer.parseInt(commonBean.getBankId().split("-")[1]), fund.getId());
            LOGGER.error(
                getText(
                    "validate.paymentMode.rtgs.subledger.details",
                    new String[] {entity.getCode() + "-" + entity.getName()}));
            errors.add(
                new ValidationError(
                    "validate.paymentMode.rtgs.subledger.details",
                    getText(
                        "validate.paymentMode.rtgs.subledger.details",
                        new String[] {entity.getCode() + "-" + entity.getName()})));
            throw new ValidationException(errors);
          }
        }
      } else {
        throw new ValidationException(
            Arrays.asList(
                new ValidationError(
                    "no.subledger.cannot.create.rtgs.payment",
                    "arf.payment.no.subledger.cannot.create.rtgs.payment")));
      }
    }
  }
Пример #2
0
  private CVoucherHeader createVoucherAndledger() {
    try {
      final HashMap<String, Object> headerDetails = createHeaderAndMisDetails();
      headerDetails.put(
          VoucherConstant.SOURCEPATH, "/EGF/payment/advancePayment!view.action?voucherHeader.id=");
      HashMap<String, Object> detailMap = null;
      HashMap<String, Object> subledgertDetailMap = null;
      final List<HashMap<String, Object>> accountdetails = new ArrayList<HashMap<String, Object>>();
      final List<HashMap<String, Object>> subledgerDetails =
          new ArrayList<HashMap<String, Object>>();

      detailMap = new HashMap<String, Object>();
      detailMap.put(VoucherConstant.CREDITAMOUNT, advanceRequisition.getAdvanceRequisitionAmount());
      detailMap.put(VoucherConstant.DEBITAMOUNT, ZERO);
      Bankaccount account =
          (Bankaccount)
              HibernateUtil.getCurrentSession()
                  .load(Bankaccount.class, Integer.valueOf(commonBean.getAccountNumberId()));
      detailMap.put(VoucherConstant.GLCODE, account.getChartofaccounts().getGlcode());
      accountdetails.add(detailMap);
      Map<String, Object> glcodeMap = new HashMap<String, Object>();
      detailMap = new HashMap<String, Object>();

      detailMap.put(VoucherConstant.DEBITAMOUNT, advanceRequisition.getAdvanceRequisitionAmount());
      detailMap.put(VoucherConstant.CREDITAMOUNT, ZERO);
      for (EgAdvanceRequisitionDetails advanceRequisitionDetails :
          advanceRequisition.getEgAdvanceReqDetailses()) {
        detailMap.put(
            VoucherConstant.GLCODE, advanceRequisitionDetails.getChartofaccounts().getGlcode());
      }
      accountdetails.add(detailMap);
      glcodeMap.put(detailMap.get(VoucherConstant.GLCODE).toString(), VoucherConstant.DEBIT);

      subledgertDetailMap = new HashMap<String, Object>();
      for (EgAdvanceRequisitionDetails advanceDetail :
          advanceRequisition.getEgAdvanceReqDetailses()) {
        for (EgAdvanceReqPayeeDetails payeeDetail : advanceDetail.getEgAdvanceReqpayeeDetailses()) {
          subledgertDetailMap = new HashMap<String, Object>();
          subledgertDetailMap.put(VoucherConstant.DEBITAMOUNT, payeeDetail.getDebitAmount());
          subledgertDetailMap.put(VoucherConstant.CREDITAMOUNT, payeeDetail.getCreditAmount());
          subledgertDetailMap.put(
              VoucherConstant.DETAILTYPEID, payeeDetail.getAccountDetailType().getId());
          subledgertDetailMap.put(VoucherConstant.DETAILKEYID, payeeDetail.getAccountdetailKeyId());
          subledgertDetailMap.put(
              VoucherConstant.GLCODE, advanceDetail.getChartofaccounts().getGlcode());
          subledgerDetails.add(subledgertDetailMap);
        }
      }

      final CreateVoucher cv = new CreateVoucher();
      voucherHeader = cv.createPreApprovedVoucher(headerDetails, accountdetails, subledgerDetails);

    } catch (final HibernateException e) {
      LOGGER.error(e.getMessage(), e);
      throw new ValidationException(
          Arrays.asList(new ValidationError(EXCEPTION_WHILE_SAVING_DATA, FAILED)));
    } catch (final ApplicationRuntimeException e) {
      LOGGER.error(e.getMessage(), e);
      throw new ValidationException(
          Arrays.asList(new ValidationError(e.getMessage(), e.getMessage())));
    } catch (final ValidationException e) {
      LOGGER.error(e.getMessage(), e);
      throw e;
    } catch (final Exception e) {
      // handle engine exception
      LOGGER.error(e.getMessage(), e);
      throw new ValidationException(
          Arrays.asList(new ValidationError(e.getMessage(), e.getMessage())));
    }
    if (LOGGER.isDebugEnabled()) LOGGER.debug("Posted to Ledger " + voucherHeader.getId());
    return voucherHeader;
  }