Example #1
0
  /**
   * Metodo que obtiene la consulta de un fondo de inversión.
   *
   * @param branch Número del branch.
   * @param strDeal Número de operación.
   * @param sc Contexto de seguridad.
   * @return respFondosVO Contiene los datos a mostrar.
   * @throws Exception En caso que ocurra un error.
   */
  public final RespuestaFondosVO consultaFondos(
      final String branch, final String strDeal, final SantanderSecurityContext sc)
      throws Exception {

    RespuestaFondosVO respFondosVO = new RespuestaFondosVO();
    RespuestaFondosVO respDAO = new RespuestaFondosVO();

    respDAO = capturaFondosDAO.consultaFondos(branch, strDeal, sc);

    if (respDAO != null) {

      log.debug("MutFundind " + respDAO.getMutFundind());
      log.debug("Fixincind " + respDAO.getFixincind());
      log.debug("Revdate " + respDAO.getRevDate());
      log.debug("Cuenta " + respDAO.getContrato());

      if (respDAO.getMutFundind().trim().equals("0") || respDAO.getFixincind().trim().equals("1")) {
        log.debug("La operación no es un fondo de inversión.");
        respFondosVO.setError(ErrorKeys.ERR_NO_ES_FONDO_INVERSION);
        return respFondosVO;
      }

      if (respDAO.getRevDate() == null) {
        log.debug("La operacion ha sido cancelada.");
        respFondosVO.setError(ErrorKeys.ERR_OPERACION_CANCELADA);
        return respFondosVO;
      }

      respFondosVO.setOperacion(respDAO.getOperacion().trim());
      respFondosVO.setContrato(respDAO.getContrato().trim());
      respFondosVO.setInstitucion(respDAO.getInstitucion());
      respFondosVO.setMoneda(respDAO.getMoneda().trim());
      respFondosVO.setFechaValor(respDAO.getFechaValor());
      respFondosVO.setMonto(Math.abs(respDAO.getMonto()));
      respFondosVO.setTitulos(Math.abs(respDAO.getTitulos()));
      respFondosVO.setEmisora(respDAO.getEmisora().trim());
      respFondosVO.setCompraVenta(respDAO.getCompraVenta().trim());
      respFondosVO.setBitacora(respDAO.getBitacora().trim());
      respFondosVO.setEjecucion(respDAO.getEjecucion());
      respFondosVO.setFolio(respDAO.getFolio());

      /*
       * Se valida el contrato que se obtuvo en la consulta.
       */
      String ctaContrato = respFondosVO.getContrato();
      String user = sc.getPrivilegiosUsuario().getTrad();

      respFondosVO.setStatus(commonDAO.validaContrato(branch, ctaContrato, user).getStatus());

      return respFondosVO;
    } else {
      respFondosVO.setError(ErrorKeys.ERR_REGISTRO_NO_ENCONTRADO);
      return respFondosVO;
    }
  }
Example #2
0
  /**
   * Método para hacer una operación de un fondo de inversión.
   *
   * @param fondosVO Parametros para hacer la validación de la operación que se desea realizar.
   * @param sc Contexto de seguridad.
   * @param efectivoVO Parametros para hacer operaciones de Efectivo
   * @return RespuestaFondosVO Regresa los valores que se muestran en la pantalla de confirmación ó
   *     el número de operación.
   * @throws Exception Encaso de que ocurra un error.
   */
  public final RespuestaFondosVO procesamientoDatosFondos(
      final ParFondosVO fondosVO,
      final SantanderSecurityContext sc,
      final ParametrosEfectivoVO efectivoVO)
      throws Exception {

    String brContrato = "";
    String ctaContrato = "";
    String user = "";
    String contrapartesCom = "";
    String contrapartesIva = "";
    String perfil = "";

    ValidaContratoVO contratoVO = new ValidaContratoVO();
    RespuestaFondosVO respFondosVOConf = new RespuestaFondosVO();
    RespuestaFondosVO respProcesaFondos = new RespuestaFondosVO();
    RespuestaFondosVO respFondos = new RespuestaFondosVO();

    brContrato = fondosVO.getBranch();
    ctaContrato = fondosVO.getContrato();
    user = sc.getPrivilegiosUsuario().getTrad();

    contrapartesCom = getCommonService().contrapartes(brContrato, "COMM");
    contrapartesIva = getCommonService().contrapartes(brContrato, "IVA");

    /*
    if (contrapartesCom.equals("") || contrapartesIva.equals("")) {
    			log.debug("No se encontrarón definiciones"
    					+ " de las contrapartes para el sistema.");
    		}
    */

    try {
      contratoVO = commonDAO.validaContrato(brContrato, ctaContrato, user);

      respFondosVOConf =
          capturaFondosDAO.procesaFondosConfirmacion(
              fondosVO.getBranch(),
              fondosVO.getContrato(),
              contratoVO.getCno(),
              fondosVO.getEmisora(),
              fondosVO.getMoneda(),
              fondosVO.getMonto(),
              fondosVO.getTitulos(),
              fondosVO.getCompraVenta(),
              fondosVO.getFechaProc(),
              fondosVO.getPromotor(),
              contratoVO.getNostrovostro(),
              sc);

      if (respFondosVOConf != null) {

        if ((respFondosVOConf.getError() == null
                || respFondosVOConf.getError().trim().length() == 0)
            && respFondosVOConf.getStatus() == 0) {

          int decimales = fondosVO.getDecimalsMoneda();
          String strDec = "";
          for (int iter = 0; iter < decimales; iter++) {
            strDec = strDec + "0";
          }
          String pattern = "#,###,##0." + strDec;

          // Compra / Venta
          if (respFondosVOConf.getCompraVenta().equals("S")) {
            respFondos.setCompraVenta("Venta");
          } else {
            respFondos.setCompraVenta("Compra");
          }
          // Emisora
          respFondos.setEmisora(respFondosVOConf.getEmisora());
          // Moneda
          respFondos.setMoneda(respFondosVOConf.getMoneda());
          // Titulos
          respFondos.setStrCalcQty(
              Formateador.format(String.valueOf(respFondosVOConf.getDblCalcQty()), pattern));
          // Precio
          String patternPrice = "#,###,##0.########";
          respFondos.setStrFundPrice(
              Formateador.format(String.valueOf(respFondosVOConf.getStrFundPrice()), patternPrice));
          // Monto Neto
          // Se valida regla: Importes inferiores a 100,000
          Integer montoValue = Mensajes.MAX_MONTO_DEFAULT;
          if (capturaCapitalesDAO != null) {
            montoValue = capturaCapitalesDAO.getMontoInferior();
          }
          if (fondosVO.getEjecucion() != null
              && Ejecucion.formatString(fondosVO.getEjecucion())
                  .equalsIgnoreCase(Ejecucion.formatString(Ejecucion.EXCEPCIONES.getName()))
              && (montoUnsigned(respFondosVOConf.getDblMontoNeto()) >= montoValue)) {
            if (fondosVO.getBranch() == null
                || fondosVO.getContrato() == null
                || !capturaCapitalesDAO.isContratoDiscrecional(
                    fondosVO.getBranch(), fondosVO.getContrato())) {
              if (respFondos.getCompraVenta().equals("Venta")
                  || respFondosVOConf.getEmisora() == null
                  || respFondosVOConf.getEmisora().equals("")
                  || !capturaCapitalesDAO.existEmisora(respFondosVOConf.getEmisora())) {
                String serr = Mensajes.ERR_EJECUCION;
                log.error(serr);
                respFondos.setError(serr);
                throw new CondicionesInconsistentesException(respFondos.getError());
              }
            }
          }
          respFondos.setStrMontoNeto(
              Formateador.format(String.valueOf(respFondosVOConf.getDblMontoNeto()), pattern));
          // Porcentaje Comisión.
          if (!respFondosVOConf.getOnCommrate().equals("")) {
            respFondos.setOnCommrate(
                Formateador.formatCCY(respFondosVOConf.getOnCommrate(), decimales));
          } else {
            respFondos.setOnCommrate("0.00");
          }
          // Comisión
          String strComision = String.valueOf(respFondosVOConf.getDblComision());
          if (!strComision.equals("")) {
            respFondos.setStrComision(Formateador.formatCCY(strComision, decimales));
          } else {
            respFondos.setStrComision("0.00");
          }
          // IVA
          String strIva =
              Formateador.stringWithOutComma(String.valueOf(respFondosVOConf.getDblIva()));
          if (!strIva.equals("")) {
            respFondos.setStrIva(Formateador.formatCCY(strIva, decimales));
          } else {
            respFondos.setStrIva("0.00");
          }
          // Fecha de liquidación
          if (respFondosVOConf.getSettDate() != null) {
            respFondos.setFechaLiq(
                Formateador.formateaFechaDisplay(respFondosVOConf.getSettDate()));
          } else {
            respFondos.setFechaLiq("");
          }
          // Plazo de permanencia
          respFondos.setOcMinTerms(respFondosVOConf.getOcMinTerms());
          // Fecha de recompra
          if (respFondosVOConf.getExpirdate() != null) {
            respFondos.setFechaExpira(FechaUtils.dateToString(respFondosVOConf.getExpirdate()));
          } else {
            respFondos.setFechaExpira("");
          }
          // Producto.
          if (respFondosVOConf.getOcProduct() != null) {
            respFondos.setOcProduct(respFondosVOConf.getOcProduct());
          } else {
            respFondos.setOcProduct("");
          }
          // Tipo de Producto.
          if (respFondosVOConf.getOcProdType() != null) {
            respFondos.setOcProdType(respFondosVOConf.getOcProdType());
          } else {
            respFondos.setOcProdType("");
          }

          /*
           * Perfil.
           */
          perfil =
              getCommonService()
                  .validaPerfilContrato(
                      fondosVO.getBranch(),
                      fondosVO.getContrato(),
                      getCommonService().MDO_FONDOS,
                      fondosVO.getMoneda(),
                      fondosVO.getEmisora(),
                      fondosVO.getMonto(),
                      "", // Producto
                      "", // TipoProducto
                      getCommonService().CICLO_ANTES_DE_VALIDAR,
                      null);

          log.debug("Perfil '" + perfil + "'");

          respFondos.setPerfil(perfil);

        } else if (respFondosVOConf.getStatus() != 0) {
          log.debug("Status en respFondosVOConf");
          respFondos.setStatus(respFondosVOConf.getStatus());
          return respFondos; // ANZ OCT 2011
          // ANZ OCT 2011. Se comenta para que no mande Exception
          // throw new CondicionesInconsistentesException(
          //		String.valueOf(respFondos.getStatus()));
        } else {
          log.debug("Mensaje de error en respFondosVOConf " + respFondosVOConf.getError());
          respFondos.setError(respFondosVOConf.getError());
          return respFondos; // ANZ OCT 2011
          // ANZ OCT 2011. Se comenta para que no mande Exception
          // throw new CondicionesInconsistentesException(
          //		respFondos.getError());
        }

        /*
         * Se ejecuta cuando se le da click en aceptar
         * a la pantalla de Confirmación.
         */

        if (fondosVO.isConfirmacion()) {
          respProcesaFondos =
              capturaFondosDAO.procesaFondos(
                  fondosVO, contratoVO, respFondosVOConf, contrapartesCom, contrapartesIva, sc);
          if (respProcesaFondos != null) {
            if ((respProcesaFondos.getError() == null
                    || respProcesaFondos.getError().trim().length() == 0)
                && respProcesaFondos.getStatus() == 0) {
              respFondos.setOperacion(respProcesaFondos.getOperacion());
              log.info("Número de operación " + respProcesaFondos.getOperacion());

              /** Bitacora */
              log.debug("Bitacora " + fondosVO.getBitacora());
              getBitacoraService()
                  .registraFondos(
                      respProcesaFondos.getOperacion(),
                      fondosVO.getBranch(),
                      fondosVO.getBitacora(),
                      fondosVO.getEjecucion(),
                      fondosVO.getFolio(),
                      null,
                      FCBitacoraService.MODO_NUEVA_OPERACION,
                      sc);

              if (fondosVO.isEfectivo()) {
                RespuestaDepRet respbean = new RespuestaDepRet();
                try {
                  efectivoVO.setOperacion(respFondos.getOperacion().trim());
                  log.info(
                      "Entre a la operacion de efectivo. Operacion="
                          + efectivoVO.getOperacion()
                          + "; datos para efectivo ="
                          + efectivoVO.getDataList());
                  log.info("COMENZANDO A PROCESAR EFECTIVO");

                  respbean = capturaEfectivoService.procesaEfectivo(efectivoVO, sc);
                  respFondos.setOperacionEfe(respbean.getSemfyield());
                } catch (Exception e) {
                  String serr = "No se termino la operación " + "de fondos con efectivo";
                  if (e instanceof CondicionesInconsistentesException) {
                    log.error(serr, e);
                    respFondos.setError(e.getMessage());
                    throw new CondicionesInconsistentesException(respFondos.getError());
                  } else {
                    log.error(serr, e);
                    respFondos.setError(ErrorKeys.ERR_EFECTIVO);
                    throw new CondicionesInconsistentesException(respFondos.getError());
                  }
                }
              }

            } else if (respProcesaFondos.getStatus() != 0) {
              respFondos.setStatus(respProcesaFondos.getStatus());
              return respFondos; // ANZ OCT 2011
              // ANZ OCT 2011. Se comenta para que no mande Exception
              // throw new CondicionesInconsistentesException(
              //		String.valueOf(respFondos.getStatus()));
            } else {
              respFondos.setError(respProcesaFondos.getError());
              return respFondos; // ANZ OCT 2011
              // ANZ OCT 2011. Se comenta para que no mande Exception
              // throw new CondicionesInconsistentesException(
              //		respFondos.getError());
            }
          }
        }
      }
    } catch (Exception e) {
      log.error("ERROR", e);
      respFondos.setError(ErrorKeys.ERR_EFECTIVO);
      if (e instanceof CondicionesInconsistentesException) {
        throw e;
      } else {
        throw new CondicionesInconsistentesException(ErrorKeys.ERR_EFECTIVO);
      }
    }
    return respFondos;
  }